Here's a patch that fixes it for me (obviously it needs generalising for os's/cpu configurations other than Linux/i386).

(The last time I submitted a patch for gdb's watchpoint code was november 2000!)

--- gdb-6.8/gdb/config/i386/nm-i386.h	2008-01-01 23:53:14.000000000 +0100
+++ gdb-6.8-jh/gdb/config/i386/nm-i386.h	2009-01-31 12:34:22.000000000 +0100
@@ -59,6 +59,12 @@
    Return 0 on success, -1 on failure.  */
 extern int  i386_remove_hw_breakpoint (struct bp_target_info *bp_tgt);
 
+extern int i386_stopped_by_watchpoint (void);
+
+/* Force all of these inquiries to indirect via current target. */
+
+#if 0
+
 /* Returns the number of hardware watchpoints of type TYPE that we can
    set.  Value is positive if we can set CNT watchpoints, zero if
    setting watchpoints of type TYPE is not supported, and negative if
@@ -90,8 +96,6 @@
 
 #define HAVE_CONTINUABLE_WATCHPOINT 1
 
-extern int i386_stopped_by_watchpoint (void);
-
 #define STOPPED_BY_WATCHPOINT(W)       (i386_stopped_by_watchpoint () != 0)
 
 #define target_stopped_data_address(target, x)  i386_stopped_data_address(x)
@@ -110,6 +114,8 @@
 #define target_remove_hw_breakpoint(bp_tgt) \
   i386_remove_hw_breakpoint (bp_tgt)
 
+#endif
+
 #endif /* I386_USE_GENERIC_WATCHPOINTS */
 
 #endif /* NM_I386_H */
--- gdb-6.8/gdb/i386-linux-nat.c	2008-01-01 23:53:10.000000000 +0100
+++ gdb-6.8-jh/gdb/i386-linux-nat.c	2009-01-31 12:31:56.000000000 +0100
@@ -812,6 +812,18 @@
   super_post_startup_inferior (ptid);
 }
 
+static int
+yes_we_can ()
+{
+	return 1;
+}
+
+static int
+our_i386_stopped_data_address (struct target_ops * target, CORE_ADDR * addr)
+{
+	return i386_stopped_data_address (addr);
+}
+
 void
 _initialize_i386_linux_nat (void)
 {
@@ -831,6 +843,18 @@
   t->to_fetch_registers = i386_linux_fetch_inferior_registers;
   t->to_store_registers = i386_linux_store_inferior_registers;
 
+  /* Add watchpoint methods */
+  t->to_insert_watchpoint = i386_insert_watchpoint;
+  t->to_remove_watchpoint = i386_remove_watchpoint;
+  t->to_insert_hw_breakpoint = i386_insert_hw_breakpoint;
+  t->to_remove_hw_breakpoint = i386_remove_hw_breakpoint;
+
+  t->to_can_use_hw_breakpoint = yes_we_can;
+  t->to_region_ok_for_hw_watchpoint = i386_region_ok_for_watchpoint;
+  t->to_have_continuable_watchpoint = 1;
+  t->to_stopped_by_watchpoint = i386_stopped_by_watchpoint;
+  t->to_stopped_data_address = our_i386_stopped_data_address;
+
   /* Register the target.  */
   linux_nat_add_target (t);
   linux_nat_set_new_thread (t, i386_linux_new_thread);

Reply via email to