This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Patch: breakpoint ranges
- To: gdb-patches@sourceware.cygnus.com
- Subject: Patch: breakpoint ranges
- From: Tom Tromey <tromey@cygnus.com>
- Date: 30 Aug 1999 22:52:08 -0600
- Reply-To: tromey@cygnus.com
I consistently expect some breakpoint commands (disable and enable,
primarily) to take a range of breakpoints. I can't count the number
fo times I've written "disable 1-5" only to have gdb tell me that is
(still) in error.
Recently I became annoyed enough to implement this. Patch appended.
I'll check this in once I get approval.
1999-08-30 Tom Tromey <tromey@cygnus.com>
* breakpoint.c (get_number_trailer): Renamed from get_number.
(get_number): New function.
(map_breakpoint_numbers): Allow breakpoint ranges.
1999-08-30 Tom Tromey <tromey@cygnus.com>
* gdb.texinfo (Disabling): Mention breakpoint ranges.
Tom
Index: NEWS
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/NEWS,v
retrieving revision 2.70
diff -u -r2.70 NEWS
--- NEWS 1999/08/28 00:42:18 2.70
+++ NEWS 1999/08/31 04:37:34
@@ -48,6 +48,10 @@
``set remote X-packet''. Other commands in ``set remote'' family
include ``set remote P-packet''.
+* Some breakpoint commands can now accept ranges of breakpoints in the
+form ``FROM-TO''. The commands which understand this syntax are
+`delete', `disable', and `enable'.
+
*** Changes in GDB-4.18:
* New native configurations
Index: breakpoint.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/breakpoint.c,v
retrieving revision 1.239
diff -u -r1.239 breakpoint.c
--- breakpoint.c 1999/08/29 00:06:42 1.239
+++ breakpoint.c 1999/08/31 04:38:25
@@ -140,6 +140,9 @@
condition_command PARAMS ((char *, int));
static int
+get_number_trailer PARAMS ((char **, int));
+
+static int
get_number PARAMS ((char **));
void
@@ -408,10 +411,14 @@
Currently the string can either be a number or "$" followed by the name
of a convenience variable. Making it an expression wouldn't work well
- for map_breakpoint_numbers (e.g. "4 + 5 + 6"). */
+ for map_breakpoint_numbers (e.g. "4 + 5 + 6").
+
+ TRAILER is a character which can be found after the number; most
+ commonly this is `-'. If you don't want a trailer, use \0. */
static int
-get_number (pp)
+get_number_trailer (pp, trailer)
char **pp;
+ int trailer;
{
int retval;
char *p = *pp;
@@ -450,13 +457,21 @@
error_no_arg ("breakpoint number");
retval = atoi (*pp);
}
- if (!(isspace (*p) || *p == '\0'))
+ if (!(isspace (*p) || *p == '\0' || *p == trailer))
error ("breakpoint number expected");
while (isspace (*p))
p++;
*pp = p;
return retval;
}
+
+/* Like get_number_trailer, but don't allow a trailer. */
+static int
+get_number (pp)
+ char **pp;
+{
+ return get_number_trailer (pp, '\0');
+}
/* condition N EXP -- set break condition of breakpoint N to EXP. */
@@ -6740,7 +6755,7 @@
{
register char *p = args;
char *p1;
- register int num;
+ register int num, end;
register struct breakpoint *b;
if (p == 0)
@@ -6750,19 +6765,32 @@
{
p1 = p;
- num = get_number (&p1);
+ num = get_number_trailer (&p1, '-');
- ALL_BREAKPOINTS (b)
- if (b->number == num)
+ if (*p1 == '-')
{
- struct breakpoint *related_breakpoint = b->related_breakpoint;
- function (b);
- if (related_breakpoint)
- function (related_breakpoint);
- goto win;
+ ++p1;
+ end = get_number (&p1);
}
- printf_unfiltered ("No breakpoint number %d.\n", num);
- win:
+ else
+ end = num;
+
+ while (num <= end)
+ {
+ ALL_BREAKPOINTS (b)
+ if (b->number == num)
+ {
+ struct breakpoint *related_breakpoint = b->related_breakpoint;
+ function (b);
+ if (related_breakpoint)
+ function (related_breakpoint);
+ goto win;
+ }
+ printf_unfiltered ("No breakpoint number %d.\n", num);
+ win:
+ ++num;
+ }
+
p = p1;
}
}
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/doc/gdb.texinfo,v
retrieving revision 2.223
diff -u -r2.223 gdb.texinfo
--- gdb.texinfo 1999/08/20 20:43:36 2.223
+++ gdb.texinfo 1999/08/31 04:40:22
@@ -2639,9 +2639,11 @@
@kindex d
@item delete @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]}
Delete the breakpoints, watchpoints, or catchpoints of the numbers
-specified as arguments. If no argument is specified, delete all
-breakpoints (@value{GDBN} asks confirmation, unless you have @code{set
-confirm off}). You can abbreviate this command as @code{d}.
+specified as arguments. A range of breakpoint numbers can be specified
+by writing the endpoints of the range separated by a dash, for example
+@samp{2-5}. If no argument is specified, delete all breakpoints
+(@value{GDBN} asks confirmation, unless you have @code{set confirm
+off}). You can abbreviate this command as @code{d}.
@end table
@node Disabling
@@ -2656,9 +2658,10 @@
You disable and enable breakpoints, watchpoints, and catchpoints with
the @code{enable} and @code{disable} commands, optionally specifying one
-or more breakpoint numbers as arguments. Use @code{info break} or
-@code{info watch} to print a list of breakpoints, watchpoints, and
-catchpoints if you do not know which numbers to use.
+or more breakpoint numbers as arguments (a range is also accepted here).
+Use @code{info break} or @code{info watch} to print a list of
+breakpoints, watchpoints, and catchpoints if you do not know which
+numbers to use.
A breakpoint, watchpoint, or catchpoint can have any of four different
states of enablement: