⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ovldbreak.exp

📁 gdb-6.8 Linux下的调试程序 最新版本
💻 EXP
📖 第 1 页 / 共 2 页
字号:
# Copyright (C) 1998, 1999, 2001, 2004, 2007, 2008# Free Software Foundation, Inc.# This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 3 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program.  If not, see <http://www.gnu.org/licenses/>.# written by Elena Zannoni (ezannoni@cygnus.com)# modified by Michael Chastain (chastain@redhat.com)# This file is part of the gdb testsuite## tests for overloaded member functions. Set breakpoints on# overloaded member functions#if $tracelevel then {        strace $tracelevel        }## test running programs#set prms_id 0set bug_id 0if { [skip_cplus_tests] } { continue }set testfile "ovldbreak"set srcfile ${testfile}.ccset binfile ${objdir}/${subdir}/${testfile}if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {     untested ovldbreak.exp     return -1}gdb_exitgdb_startgdb_reinitialize_dir $srcdir/$subdirgdb_load ${binfile}# set it up at a breakpoint so we can play with the variable values#if ![runto_main] then {    perror "couldn't run to breakpoint"    continue}# When I ask gdb to set a breakpoint on an overloaded function,# gdb gives me a choice menu.  I might get stuck in that choice menu# (for example, if C++ name mangling is not working properly).## This procedure issues a command that works at either the menu# prompt or the command prompt to get back to the command prompt.## Note that an empty line won't do it (it means 'repeat the previous command'# at top level).  A line with a single space in it works nicely.proc take_gdb_out_of_choice_menu {} {    global gdb_prompt    send_gdb " \n"    gdb_expect {        -re ".*$gdb_prompt $" {        }        timeout {            perror "could not resynchronize to command prompt (timeout)"            continue        }    }}# This procedure sets an overloaded breakpoint.# When I ask for such a breakpoint, gdb gives me a menu of 'cancel' 'all'# and a bunch of choices.  I then choose from that menu by number.proc set_bp_overloaded {name expectedmenu mychoice bpnumber linenumber} {    global gdb_prompt hex srcfile    # Get into the overload menu.    send_gdb "break $name\n"    gdb_expect {        -re "$expectedmenu" {            pass "bp menu for $name choice $mychoice"            # Choose my choice.            send_gdb "$mychoice\n"            gdb_expect {                -re "Breakpoint $bpnumber at $hex: file.*$srcfile, line $linenumber.\r\n$gdb_prompt $" {                    pass "set bp $bpnumber on $name $mychoice line $linenumber"                }                -re ".*$gdb_prompt $" {                    fail "set bp $bpnumber on $name $mychoice line $linenumber (bad bp)"                }                timeout {                    fail "set bp $bpnumber on $name $mychoice line $linenumber (timeout)"                    take_gdb_out_of_choice_menu                }            }        }        -re ".*\r\n> " {            fail "bp menu for $name choice $mychoice (bad menu)"            take_gdb_out_of_choice_menu        }        -re ".*$gdb_prompt $" {            fail "bp menu for $name choice $mychoice (no menu)"        }        timeout {            fail "bp menu for $name choice $mychoice (timeout)"            take_gdb_out_of_choice_menu        }    }}# This is the expected menu for overload1arg.# Note the arg type variations on lines 6 and 13.# This accommodates different versions of g++.set menu_overload1arg "\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\] foo::overload1arg\\(double\\) at.*$srcfile:121\r\n\\\[3\\\] foo::overload1arg\\(float\\) at.*$srcfile:120\r\n\\\[4\\\] foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r\n\\\[5\\\] foo::overload1arg\\(long\\) at.*$srcfile:118\r\n\\\[6\\\] foo::overload1arg\\((unsigned int|unsigned)\\) at.*$srcfile:117\r\n\\\[7\\\] foo::overload1arg\\(int\\) at.*$srcfile:116\r\n\\\[8\\\] foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r\n\\\[9\\\] foo::overload1arg\\(short\\) at.*$srcfile:114\r\n\\\[10\\\] foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r\n\\\[11\\\] foo::overload1arg\\(signed char\\) at.*$srcfile:112\r\n\\\[12\\\] foo::overload1arg\\(char\\) at.*$srcfile:111\r\n\\\[13\\\] foo::overload1arg\\((void|)\\) at.*$srcfile:110\r\n> $"# Set breakpoints on foo::overload1arg, one by one.set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 12    2 111set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 11    3 112set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 10    4 113set_bp_overloaded "foo::overload1arg" "$menu_overload1arg"  9    5 114set_bp_overloaded "foo::overload1arg" "$menu_overload1arg"  8    6 115set_bp_overloaded "foo::overload1arg" "$menu_overload1arg"  7    7 116set_bp_overloaded "foo::overload1arg" "$menu_overload1arg"  6    8 117set_bp_overloaded "foo::overload1arg" "$menu_overload1arg"  5    9 118set_bp_overloaded "foo::overload1arg" "$menu_overload1arg"  4   10 119set_bp_overloaded "foo::overload1arg" "$menu_overload1arg"  3   11 120set_bp_overloaded "foo::overload1arg" "$menu_overload1arg"  2   12 121set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 13   13 110# Verify the breakpoints.gdb_test "info break" \    "Num     Type\[\t \]+Disp Enb Address\[\t \]+What.*\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in main at.*$srcfile:49\r\[\t \]+breakpoint already hit 1 time\r\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \    "breakpoint info (after setting one-by-one)"# Test choice "cancel".# This is copy-and-paste from set_bp_overloaded.send_gdb "break foo::overload1arg\n" gdb_expect {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -