This is the mail archive of the gdb-patches@sourceware.org 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]

[PATCH] hardware watchpoints turned off, inferior not yet started


The following seems confusing to me:

$ gdb -q watch.x
Reading symbols from /some/path/to/watch.x...done.
(gdb) set can-use-hw-watchpoints 0
(gdb) watch -l my_var 
Hardware watchpoint 1: -location my_var
(gdb) 

Notice that despite turning hardware watchpoints off
the watchpoint created is reported to be a hardware
watchpoint.  Once I actually start the inferior the
watchpoint is downgraded to a software watchpoint,
but still, this feels like it might cause confusion,
and is pretty easy to fix.

OK to apply?

Thanks,
Andrew


gdb/ChangeLog

2013-10-16  Andrew Burgess  <aburgess@broadcom.com>

	* breakpoint.c (update_watchpoint): Create software watchpoints if
	the inferior has not yet started and hardware watchpoints are
	turned off.

gdb/testsuite/ChangeLog

2013-10-16  Andrew Burgess  <aburgess@broadcom.com>

	* gdb.base/watchpoints.exp: Add test for setting software
	watchpoint before starting the inferior.


diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 5ce50de..2902dc1 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1800,6 +1800,8 @@ update_watchpoint (struct watchpoint *b, int reparse)
       /* Without execution, memory can't change.  No use to try and
 	 set watchpoint locations.  The watchpoint will be reset when
 	 the target gains execution, through breakpoint_re_set.  */
+      if (!can_use_hw_watchpoints)
+	b->base.type = bp_watchpoint;
     }
   else if (within_current_scope && b->exp)
     {
diff --git a/gdb/testsuite/gdb.base/watchpoints.exp b/gdb/testsuite/gdb.base/watchpoints.exp
index 7c10d81..2442bcd 100644
--- a/gdb/testsuite/gdb.base/watchpoints.exp
+++ b/gdb/testsuite/gdb.base/watchpoints.exp
@@ -29,6 +29,17 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
     return -1
 }
 
+    # Ensure that if we turn off hardware watchpoints and set a watch point
+    # before starting the inferior the watchpoint created will not be a
+    # hardware watchpoint.
+    gdb_test_no_output "set can-use-hw-watchpoints 0" ""
+    gdb_test "watch ival1" "Watchpoint \[0-9\]+: ival1" \
+        "Set software watchpoint before starting the inferior"
+
+    # This will turn hardware watchpoints back on and delete the watchpoint
+    # we just created.
+    clean_restart ${binfile}
+
     # Disable hardware watchpoints if necessary.
     if [target_info exists gdb,no_hardware_watchpoints] {
         gdb_test_no_output "set can-use-hw-watchpoints 0" ""



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