This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Add command resetbpnum for reset $bpnum
- From: Hui Zhu <teawater at gmail dot com>
- To: gdb-patches ml <gdb-patches at sourceware dot org>
- Date: Mon, 19 Sep 2011 00:16:00 +0800
- Subject: [PATCH] Add command resetbpnum for reset $bpnum
Hi,
I found we never set the breakpoint number back in GDB. And sometime,
I fount that user need reset $bpnum to the current last number.
So I make a patch add command resetbpnum for reset $bpnum to the last
number of the current breakpoints.
Then we can got:
(gdb) b *0
Breakpoint 1 at 0x0
(gdb) b *0
Note: breakpoint 1 also set at pc 0x0.
Breakpoint 2 at 0x0
(gdb) b *0
Note: breakpoints 1 and 2 also set at pc 0x0.
Breakpoint 3 at 0x0
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x00000000
2 breakpoint keep y 0x00000000
3 breakpoint keep y 0x00000000
(gdb) d 3
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x00000000
2 breakpoint keep y 0x00000000
(gdb) resetbpnum
(gdb) b *0
Note: breakpoints 1 and 2 also set at pc 0x0.
Breakpoint 3 at 0x0
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x00000000
2 breakpoint keep y 0x00000000
3 breakpoint keep y 0x00000000
Please help me review it.
Best,
Hui
2011-09-19 Hui Zhu <teawater@gmail.com>
* breakpoint.c (resetbpnum_command): New function.
(_initialize_breakpoint): Register resetbpnum_command.
---
breakpoint.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
--- a/breakpoint.c
+++ b/breakpoint.c
@@ -13272,6 +13272,20 @@ iterate_over_breakpoints (int (*callback
return NULL;
}
+static void
+resetbpnum_command (char *args, int from_tty)
+{
+ struct breakpoint *b;
+ int num = 0;
+
+ ALL_BREAKPOINTS (b)
+ {
+ if (b->number > num)
+ num = b->number;
+ }
+ set_breakpoint_count (num);
+}
+
void
initialize_breakpoint_ops (void)
{
@@ -13955,6 +13969,9 @@ The breakpoint will stop execution of th
an instruction at any address within the [START-LOCATION, END-LOCATION]\n\
range (including START-LOCATION and END-LOCATION)."));
+ add_com ("resetbpnum", class_breakpoint, resetbpnum_command, _("\
+Reset $bpnum to the last number of the current breakpoints."));
+
automatic_hardware_breakpoints = 1;
observer_attach_about_to_proceed (breakpoint_about_to_proceed);