From: Pedro Alves Date: Fri, 18 Feb 2011 16:43:53 +0000 (+0000) Subject: * breakpoint.c (get_number_trailer): No longer accept a NULL PP. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3c3fe74c6fe58e9035ff5a045d9497321d3a0d31;p=binutils-gdb.git * breakpoint.c (get_number_trailer): No longer accept a NULL PP. * breakpoint.h (get_number_or_range): Declare. * printcmd.c (ALL_DISPLAYS): Declare. (delete_display): Reimplement taking a display pointer. (undisplay_command): Accept a range of displays to delete, using get_number_or_range. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c55cc8f3460..bd987d61e7d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2011-02-18 Pedro Alves + + * breakpoint.c (get_number_trailer): No longer accept a NULL PP. + * breakpoint.h (get_number_or_range): Declare. + * printcmd.c (ALL_DISPLAYS): Declare. + (delete_display): Reimplement taking a display pointer. + (undisplay_command): Accept a range of displays to delete, using + get_number_or_range. + 2011-02-18 Pierre Muller * c-valprint.c (c_val_print): Add embedded_offset to address diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index ca56c435943..c9e149b656b 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -561,8 +561,6 @@ struct program_space *default_breakpoint_pspace; name of a convenience variable. Making it an expression wouldn't work well for map_breakpoint_numbers (e.g. "4 + 5 + 6"). - If the string is a NULL pointer, that denotes the last breakpoint. - TRAILER is a character which can be found after the number; most commonly this is `-'. If you don't want a trailer, use \0. */ @@ -572,10 +570,7 @@ get_number_trailer (char **pp, int trailer) int retval = 0; /* default */ char *p = *pp; - if (p == NULL) - /* Empty line means refer to the last breakpoint. */ - return breakpoint_count; - else if (*p == '$') + if (*p == '$') { /* Make a copy of the name, so we can null-terminate it to pass to lookup_internalvar(). */ @@ -651,7 +646,7 @@ get_number (char **pp) is completed. The call that completes the range will advance pointer PP past . */ -int +int get_number_or_range (char **pp) { static int last_retval, end_value; diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 86fae669fc3..a3927cfbc18 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1191,4 +1191,6 @@ extern struct breakpoint *iterate_over_breakpoints (int (*) (struct breakpoint * extern int user_breakpoint_p (struct breakpoint *); +extern int get_number_or_range (char **pp); + #endif /* !defined (BREAKPOINT_H) */ diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 29ffbf5253f..6576dce3021 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -167,6 +167,11 @@ static struct display *display_chain; static int display_number; +/* Walk the following statement or block through all displays. */ + +#define ALL_DISPLAYS(B) \ + for (B = display_chain; B; B = B->next) + /* Prototypes for exported functions. */ void output_command (char *, int); @@ -1555,35 +1560,26 @@ clear_displays (void) } } -/* Delete the auto-display number NUM. */ +/* Delete the auto-display DISPLAY. */ static void -delete_display (int num) +delete_display (struct display *display) { - struct display *d1, *d; + struct display *d; - if (!display_chain) - error (_("No display number %d."), num); + gdb_assert (display != NULL); - if (display_chain->number == num) - { - d1 = display_chain; - display_chain = d1->next; - free_display (d1); - } - else - for (d = display_chain;; d = d->next) + if (display_chain == display) + display_chain = display->next; + + ALL_DISPLAYS (d) + if (d->next == display) { - if (d->next == 0) - error (_("No display number %d."), num); - if (d->next->number == num) - { - d1 = d->next; - d->next = d1->next; - free_display (d1); - break; - } + d->next = display->next; + break; } + + free_display (display); } /* Delete some values from the auto-display chain. @@ -1607,18 +1603,24 @@ undisplay_command (char *args, int from_tty) while (*p) { p1 = p; - while (*p1 >= '0' && *p1 <= '9') - p1++; - if (*p1 && *p1 != ' ' && *p1 != '\t') - error (_("Arguments must be display numbers.")); - num = atoi (p); + num = get_number_or_range (&p1); + if (num == 0) + warning (_("bad display number at or near '%s'"), p); + else + { + struct display *d; - delete_display (num); + ALL_DISPLAYS (d) + if (d->number == num) + break; + if (d == NULL) + printf_unfiltered (_("No display number %d.\n"), num); + else + delete_display (d); + } p = p1; - while (*p == ' ' || *p == '\t') - p++; } dont_repeat (); }