a9e8793
--- /dev/null	2008-04-03 00:39:30.714021604 +0200
a9e8793
+++ gdb-6.3/gdb/testsuite/gdb.base/watchpoint-cond-gone-stripped.c	2008-04-05 20:26:29.000000000 +0200
a9e8793
@@ -0,0 +1,23 @@
a9e8793
+/* This testcase is part of GDB, the GNU debugger.
a9e8793
+
a9e8793
+   Copyright 2008 Free Software Foundation, Inc.
a9e8793
+
a9e8793
+   This program is free software; you can redistribute it and/or modify
a9e8793
+   it under the terms of the GNU General Public License as published by
a9e8793
+   the Free Software Foundation; either version 2 of the License, or
a9e8793
+   (at your option) any later version.
a9e8793
+
a9e8793
+   This program is distributed in the hope that it will be useful,
a9e8793
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
a9e8793
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a9e8793
+   GNU General Public License for more details.
a9e8793
+ 
a9e8793
+   You should have received a copy of the GNU General Public License
a9e8793
+   along with this program; if not, write to the Free Software
a9e8793
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
a9e8793
+
a9e8793
+void
a9e8793
+jumper (void (*jumpto) (void))
a9e8793
+{
a9e8793
+  (*jumpto) ();
a9e8793
+}
a9e8793
--- /dev/null	2008-04-03 00:39:30.714021604 +0200
a9e8793
+++ gdb-6.3/gdb/testsuite/gdb.base/watchpoint-cond-gone.c	2008-04-05 20:26:48.000000000 +0200
a9e8793
@@ -0,0 +1,37 @@
a9e8793
+/* This testcase is part of GDB, the GNU debugger.
a9e8793
+
a9e8793
+   Copyright 2008 Free Software Foundation, Inc.
a9e8793
+
a9e8793
+   This program is free software; you can redistribute it and/or modify
a9e8793
+   it under the terms of the GNU General Public License as published by
a9e8793
+   the Free Software Foundation; either version 2 of the License, or
a9e8793
+   (at your option) any later version.
a9e8793
+
a9e8793
+   This program is distributed in the hope that it will be useful,
a9e8793
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
a9e8793
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a9e8793
+   GNU General Public License for more details.
a9e8793
+ 
a9e8793
+   You should have received a copy of the GNU General Public License
a9e8793
+   along with this program; if not, write to the Free Software
a9e8793
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
a9e8793
+
a9e8793
+extern void jumper (void (*jumpto) (void));
a9e8793
+
a9e8793
+void
a9e8793
+func ()
a9e8793
+{
a9e8793
+	int a, b, c;
a9e8793
+
a9e8793
+	a = b = c = 5;
a9e8793
+	a = b = c = 10;	/* watchpoint-here */
a9e8793
+	c = a + b;
a9e8793
+}
a9e8793
+
a9e8793
+int
a9e8793
+main ()
a9e8793
+{
a9e8793
+	jumper (func);
a9e8793
+
a9e8793
+	return 0;
a9e8793
+}
a9e8793
--- /dev/null	2008-04-03 00:39:30.714021604 +0200
a9e8793
+++ gdb-6.3/gdb/testsuite/gdb.base/watchpoint-cond-gone.exp	2008-04-05 20:33:19.000000000 +0200
a9e8793
@@ -0,0 +1,59 @@
a9e8793
+# Copyright 2008 Free Software Foundation, Inc.
a9e8793
+
a9e8793
+# This program is free software; you can redistribute it and/or modify
a9e8793
+# it under the terms of the GNU General Public License as published by
a9e8793
+# the Free Software Foundation; either version 2 of the License, or
a9e8793
+# (at your option) any later version.
a9e8793
+#
a9e8793
+# This program is distributed in the hope that it will be useful,
a9e8793
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
a9e8793
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a9e8793
+# GNU General Public License for more details.
a9e8793
+#
a9e8793
+# You should have received a copy of the GNU General Public License
a9e8793
+# along with this program; if not, write to the Free Software
a9e8793
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
a9e8793
+
a9e8793
+if $tracelevel then {
a9e8793
+    strace $tracelevel
a9e8793
+}
a9e8793
+
a9e8793
+set testfile "watchpoint-cond-gone"
a9e8793
+set srcfile ${testfile}.c
a9e8793
+set srcfilestripped ${testfile}-stripped.c
a9e8793
+set objfilestripped ${objdir}/${subdir}/${testfile}-stripped.o
a9e8793
+set binfile ${objdir}/${subdir}/${testfile}
a9e8793
+
a9e8793
+# We need to generate a function without DWARF to crash older GDB.
a9e8793
+# Stepping into a dynamic function trampoline or stepping out of MAIN may work
a9e8793
+# but it is not a reliable FAIL case.
a9e8793
+
a9e8793
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfilestripped}" "${objfilestripped}" object {}] != "" } {
a9e8793
+    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
a9e8793
+}
a9e8793
+
a9e8793
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${objfilestripped}" "${binfile}" executable {debug}] != "" } {
a9e8793
+    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
a9e8793
+}
a9e8793
+
a9e8793
+gdb_exit
a9e8793
+gdb_start
a9e8793
+gdb_reinitialize_dir $srcdir/$subdir
a9e8793
+gdb_load ${binfile}
a9e8793
+
a9e8793
+# Problem does not occur otherwise.
a9e8793
+gdb_test "set can-use-hw-watchpoints 0"
a9e8793
+
a9e8793
+runto_main
a9e8793
+gdb_breakpoint [gdb_get_line_number "watchpoint-here"]
a9e8793
+gdb_continue_to_breakpoint "Place to set the watchpoint"
a9e8793
+
a9e8793
+# The condition `c == 30' is the tested culprit.
a9e8793
+gdb_test "watch c if c == 30" "" "Place the watchpoint"
a9e8793
+
a9e8793
+# No functionality, just to check the state.
a9e8793
+gdb_test "backtrace"
a9e8793
+
a9e8793
+gdb_test "finish" \
7db944e
+         "Watchpoint .* deleted because the program has left the block in.*which its expression is valid..*in (jumper|func).*" \
a9e8793
+         "Catch the no longer valid watchpoint"