read watchpoints ignored?

Johan Rydberg jrydberg@virtutech.com
Mon Nov 14 13:16:00 GMT 2005


Daniel Jacobowitz wrote:

> I thought this was fairly straightforward, so I didn't go into detail.
> Certainly there's no reason to disable rwatch.  Conditionalize "skip
> this watchpoint if the value has changed" on "this is really an access
> watchpoint because the target does not support read watchpoints".
> 
> It should be trivial to fix if you had a platform with read watchpoints
> handy.  Which I don't easily.

I happen to have access to a target that supports true read watchpoints,
and the following patch seems to do the trick, at least for the testcase
that Vladimir provided.

I also quickly tested it against the i386 target, and for that simple
test it does not seem to introduce any regressions.

Though I can not say that "this is the (right) way to do it", but you
could take a peek at it.  I suppose the comment in breakpoint.h should
be a bit more verbose.


2005-11-14  Johan Rydberg  <jrydberg@virtutech.com>

         * breakpoint.h: Document why hw_access should be used instead of
         hw_read for read watchpoints.

         * breakpoint.c (insert_bp_location): Use hw_access instead of
         hw_read for read watchpoints.



Index: breakpoint.h
===================================================================
RCS file: /repository/gdb/gdb/breakpoint.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 breakpoint.h
--- breakpoint.h        22 Aug 2005 15:45:43 -0000      1.1.1.1
+++ breakpoint.h        14 Nov 2005 13:01:54 -0000
@@ -177,6 +177,11 @@
      disp_donttouch             /* Leave it alone */
    };

+/* Most targets does not support true read watchpoints so GDB instead
+   uses access watchpoints, which almost every known target supports,
+   to provide the same functionality as true read watchpoints.  For
+   this reason, GDB will never insert a real read watchpoint (hw_read). */
+
  enum target_hw_bp_type
    {
      hw_write   = 0,            /* Common  HW watchpoint */
Index: breakpoint.c
===================================================================
RCS file: /repository/gdb/gdb/breakpoint.c,v
retrieving revision 1.2
diff -u -r1.2 breakpoint.c
--- breakpoint.c        20 Oct 2005 16:17:59 -0000      1.2
+++ breakpoint.c        14 Nov 2005 13:08:47 -0000
@@ -978,7 +978,11 @@
                       len = TYPE_LENGTH (VALUE_TYPE (v));
                       type = hw_write;
                       if (bpt->owner->type == bp_read_watchpoint)
-                       type = hw_read;
+                       {
+                         /* Use hw_access instead of hw_read for read
+                            watchpoints.  Why? See breakpoint.h */
+                         type = hw_access;
+                       }
                       else if (bpt->owner->type == bp_access_watchpoint)
                         type = hw_access;

@@ -1508,7 +1512,11 @@
                   len = TYPE_LENGTH (VALUE_TYPE (v));
                   type   = hw_write;
                   if (b->owner->type == bp_read_watchpoint)
-                   type = hw_read;
+                   {
+                     /* Use hw_access instead of hw_read for read
+                        watchpoints.  Why? See breakpoint.h */
+                     type = hw_access;
+                   }
                   else if (b->owner->type == bp_access_watchpoint)
                     type = hw_access;



More information about the Gdb mailing list