--- /dev/null 2008-04-03 00:39:30.714021604 +0200 +++ gdb-6.3/gdb/testsuite/gdb.base/watchpoint-cond-gone-stripped.c 2008-04-05 20:26:29.000000000 +0200 @@ -0,0 +1,23 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 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 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. */ + +void +jumper (void (*jumpto) (void)) +{ + (*jumpto) (); +} --- /dev/null 2008-04-03 00:39:30.714021604 +0200 +++ gdb-6.3/gdb/testsuite/gdb.base/watchpoint-cond-gone.c 2008-04-05 20:26:48.000000000 +0200 @@ -0,0 +1,37 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 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 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. */ + +extern void jumper (void (*jumpto) (void)); + +void +func () +{ + int a, b, c; + + a = b = c = 5; + a = b = c = 10; /* watchpoint-here */ + c = a + b; +} + +int +main () +{ + jumper (func); + + return 0; +} --- /dev/null 2008-04-03 00:39:30.714021604 +0200 +++ gdb-6.3/gdb/testsuite/gdb.base/watchpoint-cond-gone.exp 2008-04-05 20:33:19.000000000 +0200 @@ -0,0 +1,59 @@ +# Copyright 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 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. + +if $tracelevel then { + strace $tracelevel +} + +set testfile "watchpoint-cond-gone" +set srcfile ${testfile}.c +set srcfilestripped ${testfile}-stripped.c +set objfilestripped ${objdir}/${subdir}/${testfile}-stripped.o +set binfile ${objdir}/${subdir}/${testfile} + +# We need to generate a function without DWARF to crash older GDB. +# Stepping into a dynamic function trampoline or stepping out of MAIN may work +# but it is not a reliable FAIL case. + +if { [gdb_compile "${srcdir}/${subdir}/${srcfilestripped}" "${objfilestripped}" object {}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${objfilestripped}" "${binfile}" executable {debug}] != "" } { + 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} + +# Problem does not occur otherwise. +gdb_test "set can-use-hw-watchpoints 0" + +runto_main +gdb_breakpoint [gdb_get_line_number "watchpoint-here"] +gdb_continue_to_breakpoint "Place to set the watchpoint" + +# The condition `c == 30' is the tested culprit. +gdb_test "watch c if c == 30" "" "Place the watchpoint" + +# No functionality, just to check the state. +gdb_test "backtrace" + +gdb_test "finish" \ + "Watchpoint .* deleted because the program has left the block in.*which its expression is valid..*in (jumper|func).*" \ + "Catch the no longer valid watchpoint"