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] Watchpoints + conditionals problem


Hi folks,

There is an unexpected behavior when we use software watchpoints (also
hardware in some cases) attached to conditional expressions, such as:
"watch x if x == <number>", considering "x" a simple "int" type
variable.

When that watchpoint goes out of scope, it's marked for disposal at the
next stop as obviously there's no way to evaluate the expression "x"
anymore. But GDB is still trying to evaluate the conditional part of the
watchpoint, even though "x" is out of scope already. Thus, GDB is
failing to find correct frame information and ends up in an internal
error.

I've tracked down this issue and it seems we need to check for the
disposition field of the watchpoint whenever we check for the return
value of a conditional expression.

Attached is a simple patch of what i have in mind to fix this issue. The
testcase can be a simple "Hello world"-like binary with a few variables
to watch.

Any other ideas?

Regards,
Luis
Index: gdb/breakpoint.c
===================================================================
--- gdb.orig/breakpoint.c	2007-11-28 09:47:26.000000000 -0800
+++ gdb/breakpoint.c	2007-11-28 09:49:47.000000000 -0800
@@ -2969,7 +2969,7 @@
 	if (b->type == bp_watchpoint_scope)
 	  b->related_breakpoint->watchpoint_triggered = watch_triggered_yes;
 
-	if (bl->cond)
+	if (bl->cond && bl->owner->disposition != disp_del_at_next_stop)
 	  {
 	    /* Need to select the frame, with all that implies
 	       so that the conditions will have the right context.  */

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