This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfa/testsuite] Add test for PR gdb/38


This patch adds a KFAILed test for PR gdb/38.  That PR is about
watchpoints set at the same location as breakpoints, which can cause
the watchpoint to get triggered late.  Right now, the only testsuite
case that tests this is in gdb.c++/annota2.exp, which is bad because
it has nothing to do with C++, nothing to do with annotation, and
because level 2 annotation is on its way out.  So I'd like to get the
bug recorded in a more correct location.

Tested on i686-pc-linux-gnu, GCC 3.1, DWARF 2.  I haven't been able to
test the pass branch, because it reliably fails on this platform, but
I did try to be careful with the pass regexp.

OK to commit?

David Carlton
carlton at math dot stanford dot edu

2003-03-17  David Carlton  <carlton at math dot stanford dot edu>

	* gdb.base/watchpoint.exp (test_watchpoint_and_breakpoint): New
	test, for PR breakpoints/38.
	Call test_watchpoint_and_breakpoint.
	* gdb.base/watchpoint.c (func3): New function.
	(main): Call func3.

Index: watchpoint.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/watchpoint.exp,v
retrieving revision 1.7
diff -u -p -r1.7 watchpoint.exp
--- watchpoint.exp	4 Feb 2003 22:49:19 -0000	1.7
+++ watchpoint.exp	17 Mar 2003 18:29:11 -0000
@@ -648,6 +648,27 @@ proc test_complex_watchpoint {} {
     }
 }
 
+proc test_watchpoint_and_breakpoint {} {
+    global gdb_prompt
+
+    # This is a test for PR gdb/38, which involves setting a
+    # watchpoint right after you've reached a breakpoint.
+
+    if [runto func3] then {
+	gdb_breakpoint [gdb_get_line_number "second x assignment"]
+	gdb_continue_to_breakpoint "second x assignment"
+	gdb_test "watch x" ".*atchpoint \[0-9\]+: x"
+	gdb_test_multiple "next" "next after watch x" {
+	    -re ".*atchpoint \[0-9\]+: x\r\n\r\nOld value = 0\r\nNew value = 1\r\n.*$gdb_prompt $" {
+		pass "next after watch x"
+	    }
+	    -re "\[0-9\]+\[\t \]+y = 1;\r\n$gdb_prompt $" {
+		kfail "gdb/38" "next after watch x"
+	    }
+	}
+    }
+}
+    
 # Start with a fresh gdb.
 
 gdb_exit
@@ -799,6 +820,17 @@ if [initialize] then {
         timeout {fail "(timeout) access watches disallowed"}
       }
     }
+
+    # See above.
+    if [istarget "mips-idt-*"] then {
+	gdb_exit
+	gdb_start
+	gdb_reinitialize_dir $srcdir/$subdir
+	gdb_load $binfile
+	initialize
+    }
+
+    test_watchpoint_and_breakpoint
 }
 
 # Restore old timeout
Index: watchpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/watchpoint.c,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 watchpoint.c
--- watchpoint.c	28 Jun 1999 16:04:22 -0000	1.1.1.2
+++ watchpoint.c	17 Mar 2003 18:29:07 -0000
@@ -83,6 +83,18 @@ func2 ()
   static_b = local_a;
 }
 
+void
+func3 ()
+{
+  int x;
+  int y;
+
+  x = 0;
+  x = 1;				/* second x assignment */
+  y = 1;
+  y = 2;
+}
+
 int
 func1 ()
 {
@@ -170,5 +182,8 @@ int main ()
   recurser (2);
 
   marker6 ();
+
+  func3 ();
+
   return 0;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]