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]

Re: [RFA] Try 2: Use multiple locations for hardware watchpoints.


On Wednesday 28 November 2007 20:14:28 you wrote:
> 
> This is a revised patch to make watchpoint use regular locations
> mechanism for storing locations to be watched. Compared to the
> previous patch:
> 
> - The 'update_watchpoint' function now updates the value stored
> inside breakpoint, removing the need for a special code for that
> purpose inside 'insert_breakpoints', which code had a FIXME saying
> it should be moved elsewhere. Since we call evaluate_expression
> anyway, update_watchpoint only needs a little care with memory management
> to do that -- there's no extra overhead.
> 
> - The 'update_watchpoint' function also has 'reparse' parameter, which
> causes it to reparse the watched expression. The breakpoint_re_set_one,
> for the case of watchpoints, now merely calls update_watchpoint.
> 
> - Presently, if I set a watchpoint on a global variable in an
> explicitly loaded shared library, and re-run the program, gdb promptly
> segfaults. This patch fixes that, and adds a testcase for that behaviour.
> 
> This patch should be applied on top of my previous breakpoint_re_set_on 
> watchpoint cleanup patch.

I've noticed that update_watchpoint fail to exit early in case the
breakpoint's disposition is disp_del_at_next_stop. That disposition is
used for breakpoints that we need to delete when they are out of scope --
that's kind of hack, as trying to call delete_breakpoint directly will
lead to crashes as later code touches this breakpoint. 

Without this check, nothing breaks, but we sometimes get a message about
a deleted watchpoint twice. To fix it, the below one-liner should
be applied on top of this patch.

- Volodya
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 4f6f161..7a07678 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -855,6 +855,9 @@ update_watchpoint (struct breakpoint *b, int reparse)
 
   value_free (b->val);
   b->val = NULL;
+
+  if (b->disposition == disp_del_at_next_stop)
+    return;
  
   /* Save the current frame's ID so we can restore it after
      evaluating the watchpoint expression on its own frame.  */

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