Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Hui Zhu <teawater@gmail.com>
To: gdb-patches ml <gdb-patches@sourceware.org>
Subject: [PATCH] Add command resetbpnum for reset $bpnum
Date: Mon, 19 Sep 2011 03:50:00 -0000	[thread overview]
Message-ID: <CANFwon0CgAn4UHi6d=CHSB69mRqYCFx0Xbfay7ZHD7ML1ur8iQ@mail.gmail.com> (raw)

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);


             reply	other threads:[~2011-09-18 16:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-19  3:50 Hui Zhu [this message]
2011-09-19 17:26 ` Stan Shebs
2011-09-19 19:02   ` Sergio Durigan Junior
2011-09-21  6:11     ` Hui Zhu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANFwon0CgAn4UHi6d=CHSB69mRqYCFx0Xbfay7ZHD7ML1ur8iQ@mail.gmail.com' \
    --to=teawater@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox