This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Fix auto-delete breakpoint with custom print function
- From: Vladimir Prus <vladimir at codesourcery dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 16 Nov 2007 16:58:11 +0300
- Subject: Fix auto-delete breakpoint with custom print function
Current GDB allows a breakpoint to be automatically
deleted when hit, and it also allows a breakpoint to
have custom function to be called when breakpoint is hit.
However, trying both those mechanism together does not work --
breakpoint is deleted before we try to print it. This
patch fixes it. OK?
- Volodya
Auto-delete breakpoints after printing stop status,
so that auto-delete with custom print function are printed
correctly.
* infrun.c (normal_stop): Move call to
breakpoint_auto_delete until after breakpoints are
printed.
* breakpoint.c (print_bp_stop_message): Don't
print anything for breakpoint without custom
printing function if it's about to be removed.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 89440b3..fbe40b8 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2448,6 +2448,12 @@ print_bp_stop_message (bpstat bs)
/* FIXME: how breakpoint can ever be NULL here? */
if (b != NULL && b->ops != NULL && b->ops->print_it != NULL)
return b->ops->print_it (b);
+ else if (b && (b->disposition == disp_del
+ || b->disposition == disp_del_at_next_stop))
+ /* For breakpoints that will be deleted at this stop,
+ and don't have a custom print routine, don't print
+ anything. */
+ return PRINT_UNKNOWN;
else
return print_it_typical (bs);
}
diff --git a/gdb/infrun.c b/gdb/infrun.c
index cf7aa02..25be12f 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3159,11 +3159,6 @@ Further execution is probably impossible.\n"));
}
breakpoints_inserted = 0;
- /* Delete the breakpoint we stopped at, if it wants to be deleted.
- Delete any breakpoint that is to be deleted at the next stop. */
-
- breakpoint_auto_delete (stop_bpstat);
-
/* If an auto-display called a function and that got a signal,
delete that auto-display to avoid an infinite recursion. */
@@ -3300,6 +3295,15 @@ Further execution is probably impossible.\n"));
}
done:
+
+ /* Delete the breakpoint we stopped at, if it wants to be deleted.
+ Delete any breakpoint that is to be deleted at the next stop.
+ Do this after printing the location we've stopped at, so that
+ if a breakpoint has special print routine, it's invoked, befor
+ we delete the breakpoint. */
+
+ breakpoint_auto_delete (stop_bpstat);
+
annotate_stopped ();
observer_notify_normal_stop (stop_bpstat);
}