From: Jeff Johnston Date: Mon, 2 Feb 2004 21:14:33 +0000 (+0000) Subject: 2004-02-02 Jeff Johnston X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=18fe20335a444c79dd2de86ca31833189a85e234;p=binutils-gdb.git 2004-02-02 Jeff Johnston * lib/gdb.exp (gdb_breakpoint): Add pending breakpoint support. * gdb.base/langs.exp: Fix test which attempts to create breakpoint on non-existent function to handle new pending support. * gdb.base/shlib-call.exp: Use gdb_breakpoint to set a breakpoint. * gdb.base/pending.exp: New test. * gdb.base/pending.c: New file. * gdb.base/pendshr.c: Ditto. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 9a611bc0bcd..dabcc76bbe2 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,16 @@ +2004-02-02 Jeff Johnston + + * lib/gdb.exp (gdb_breakpoint): Add pending breakpoint + support. + * gdb.base/langs.exp: Fix test which attempts to create + breakpoint on non-existent function to handle new pending + support. + * gdb.base/shlib-call.exp: Use gdb_breakpoint to set + a breakpoint. + * gdb.base/pending.exp: New test. + * gdb.base/pending.c: New file. + * gdb.base/pendshr.c: Ditto. + 2004-02-02 David Carlton * gdb.cp/overload.exp: Add overloadNamespace tests. diff --git a/gdb/testsuite/gdb.base/langs.exp b/gdb/testsuite/gdb.base/langs.exp index 8006bbfd788..a81df664f7d 100644 --- a/gdb/testsuite/gdb.base/langs.exp +++ b/gdb/testsuite/gdb.base/langs.exp @@ -65,8 +65,15 @@ gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load $binfile -gdb_test "b langs0" "Function \"langs0\" not defined\.|Breakpoint .* (deferred).*" \ - "break on nonexistent function in langs.exp" +gdb_test_multiple "b langs0" "break on nonexistent function in langs.exp" { + -re "Function \"langs0\" not defined\..*Make breakpoint pending on future shared library load.*y or n. $" { + + gdb_test "n" "" "break on nonexistent function in langs.exp" + } + -re "Breakpoint .* (deferred).*$gdb_prompt $" { + pass "break on nonexistent function in langs.exp" + } +} if {$hp_aCC_compiler} { set isfixed 1 diff --git a/gdb/testsuite/gdb.base/pending.c b/gdb/testsuite/gdb.base/pending.c new file mode 100644 index 00000000000..42c3655e0b3 --- /dev/null +++ b/gdb/testsuite/gdb.base/pending.c @@ -0,0 +1,35 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2004 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@prep.ai.mit.edu */ + +#include + +int k = 0; + +extern void pendfunc1 (int x); + +int main() +{ + pendfunc1 (3); /* break main here */ + pendfunc1 (4); + k = 1; + pendfunc1 (3); + return 0; +} diff --git a/gdb/testsuite/gdb.base/pending.exp b/gdb/testsuite/gdb.base/pending.exp new file mode 100644 index 00000000000..0ecdf675342 --- /dev/null +++ b/gdb/testsuite/gdb.base/pending.exp @@ -0,0 +1,266 @@ +# Copyright 2003, 2004 +# 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was created by Jeff Johnston. (jjohnstn@redhat.com) +# The shared library compilation portion was copied from shlib-call.exp which was +# written by Elena Zannoni (ezannoni@redhat.com). + +if $tracelevel then { + strace $tracelevel +} + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +# are we on a target board? +if ![isnative] then { + return 0 +} + +set testfile "pending" +set libfile "pendshr" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile}] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}.o" object {debug}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +# Build the shared libraries this test case needs. +# + +if {$gcc_compiled == 0} { + if [istarget "hppa*-hp-hpux*"] then { + set additional_flags "additional_flags=+z" + } elseif { [istarget "mips-sgi-irix*"] } { + # Disable SGI compiler's implicit -Dsgi + set additional_flags "additional_flags=-Usgi" + } else { + # don't know what the compiler is... + set additional_flags "" + } +} else { + if { ([istarget "powerpc*-*-aix*"] + || [istarget "rs6000*-*-aix*"]) } { + set additional_flags "" + } else { + set additional_flags "additional_flags=-fpic" + } +} + +if {[gdb_compile "${srcdir}/${subdir}/${libfile}.c" "${objdir}/${subdir}/${libfile}.o" object [list debug $additional_flags]] != ""} { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [istarget "hppa*-*-hpux*"] { + remote_exec build "ld -b ${objdir}/${subdir}/${libfile}.o -o ${objdir}/${subdir}/${libfile}.sl" +} else { + set additional_flags "additional_flags=-shared" + if {[gdb_compile "${objdir}/${subdir}/${libfile}.o" "${objdir}/${subdir}/${libfile}.sl" executable [list debug $additional_flags]] != ""} { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." + } +} + +if { ($gcc_compiled + && ([istarget "powerpc*-*-aix*"] + || [istarget "rs6000*-*-aix*"] )) } { + set additional_flags "additional_flags=-L${objdir}/${subdir}" +} elseif { [istarget "mips-sgi-irix*"] } { + set additional_flags "additional_flags=-rpath ${objdir}/${subdir}" +} else { + set additional_flags "" +} +if {[gdb_compile "${objdir}/${subdir}/${testfile}.o ${objdir}/${subdir}/${libfile}.sl" "${binfile}" executable [list debug $additional_flags]] != ""} { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if [target_info exists gdb_stub] { + gdb_step_for_stub; +} +# +# Test setting, querying, and modifying pending breakpoints +# + +gdb_test_multiple "break pendfunc1" "set pending breakpoint" { + -re ".*Make breakpoint pending.*y or n. $" { + gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint" + } +} + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \ +"single pending breakpoint info" + +# +# Test breaking at existing function +# + +set mainline [gdb_get_line_number "break main here"] + +gdb_test "break main" \ + "Breakpoint.*at.* file .*$srcfile, line $mainline.*" \ + "breakpoint function" + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \ +"pending plus real breakpoint info" + + +# +# Test not setting a pending breakpoint +# +gdb_test_multiple "break pendfunc2" "Don't set pending breakpoint" { + -re ".*Make breakpoint pending.*y or n. $" { + gdb_test "n" "" "Don't set pending breakpoint" + } +} + +# +# Add condition to pending breakpoint +# + +gdb_test "condition 1 k == 1\n" "" + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.* +\[\t \]+stop only if k == 1.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \ +"pending plus condition" + +# +# Disable pending breakpoint +# + +gdb_test "disable 1\n" "" + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.* +\[\t \]+stop only if k == 1.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \ +"pending disabled" + +# +# Add commands to pending breakpoint +# +gdb_test "commands 1\nprint k\nend" "" \ + "Set commands for pending breakpoint" + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.* +\[\t \]+stop only if k == 1.* +\[\t \]+print k.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \ +"pending disabled plus commands" + +# +# Try a pending break for a line in a source file with a condition +# + +gdb_test_multiple "break pendshr.c:26 if x > 3" "Set pending breakpoint 2" { + -re ".*Make breakpoint pending.*y or n. $" { + gdb_test "y" "Breakpoint.*pendshr.c:26.*pending." \ + "Set pending breakpoint 2" + } +} + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.* +\[\t \]+stop only if k == 1.* +\[\t \]+print k.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.* +\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:26 if x > 3.*" \ +"multiple pending breakpoints" + +# +# Run to main which should resolve a pending breakpoint +# + +gdb_test "run" \ +"Breakpoint.*at.* +Pending breakpoint \"pendshr.c:26 if x > 3\" resolved.* +Breakpoint.*, main.*$mainline.*" \ +"running to main" + +# +# Re-enable the first pending breakpoint which should resolve +# + +gdb_test "enable 1" \ +"Breakpoint.*at.* +Pending breakpoint \"pendfunc1.* resolved.*" \ +"re-enabling pending breakpoint that can resolve instantly" + +# +# Continue to verify conditionals and commands for breakpoints are honored +# + +gdb_test "continue" \ +".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.*4;" \ +"continue to resolved breakpoint 2" + +gdb_test "continue" \ +".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.* +\[$\]1 = 1." \ +"continue to resolved breakpoint 1" + +delete_breakpoints + +gdb_breakpoint "main" + +# +# Set non-existent pending breakpoint +# +gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" { + -re ".*Make breakpoint pending.*y or n. $" { + gdb_test "y" "Breakpoint.*imaginary.*pending." \ + "set imaginary pending breakpoint" + } +} + +# +# rerun program and make sure that any pending breakpoint remains and no +# error messages are issued for the missing function +# + +rerun_to_main +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.* +\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*imaginary.*" \ +"verify pending breakpoint after restart" diff --git a/gdb/testsuite/gdb.base/pendshr.c b/gdb/testsuite/gdb.base/pendshr.c new file mode 100644 index 00000000000..5097f94f43b --- /dev/null +++ b/gdb/testsuite/gdb.base/pendshr.c @@ -0,0 +1,28 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2004 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@prep.ai.mit.edu */ + +#include + +void pendfunc1 (int x) +{ + int y = x + 4; + printf ("in pendfunc1, x is %d\n", x); +} diff --git a/gdb/testsuite/gdb.base/shlib-call.exp b/gdb/testsuite/gdb.base/shlib-call.exp index 8fe8b22da39..4205253e2f5 100644 --- a/gdb/testsuite/gdb.base/shlib-call.exp +++ b/gdb/testsuite/gdb.base/shlib-call.exp @@ -1,4 +1,4 @@ -# Copyright 1997, 1998, 1999, 2000 Free Software Foundation, Inc. +# Copyright 1997, 1998, 1999, 2000, 2004 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 @@ -291,7 +291,7 @@ send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $" # PR's 16495, 18213 # test that we can re-set breakpoints in shared libraries -gdb_test "break shr1" "Breakpoint 1.*" "set bp in shared library" +gdb_breakpoint "shr1" # FIXME: should not send "run" explicitly. Non-portable. diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 2de51151f1d..52ec55f2a10 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -269,6 +269,10 @@ proc gdb_breakpoint { function } { -re "Breakpoint \[0-9\]* at .*: file .*, line $decimal.\r\n$gdb_prompt $" {} -re "Breakpoint \[0-9\]*: file .*, line $decimal.\r\n$gdb_prompt $" {} -re "Breakpoint \[0-9\]* at .*$gdb_prompt $" {} + -re "Make breakpoint pending.*y or n. $" { + gdb_test "n" "" "setting breakpoint at $function" ; + return 1; + } -re "$gdb_prompt $" { fail "setting breakpoint at $function" ; return 0 } timeout { fail "setting breakpoint at $function (timeout)" ; return 0 } }