From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4420 invoked by alias); 18 Feb 2011 16:50:02 -0000 Received: (qmail 4363 invoked by uid 22791); 18 Feb 2011 16:49:59 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 18 Feb 2011 16:49:54 +0000 Received: (qmail 18164 invoked from network); 18 Feb 2011 16:49:52 -0000 Received: from unknown (HELO scottsdale.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 18 Feb 2011 16:49:52 -0000 From: Pedro Alves To: Tom Tromey Subject: Re: [patch] delete a range of display numbers Date: Fri, 18 Feb 2011 16:57:00 -0000 User-Agent: KMail/1.13.5 (Linux/2.6.35-25-generic; KDE/4.6.0; x86_64; ; ) Cc: gdb-patches@sourceware.org, Guillaume Leconte , Eli Zaretskii References: <201102181555.13149.pedro@codesourcery.com> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201102181649.47097.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-02/txt/msg00475.txt.bz2 On Friday 18 February 2011 16:15:26, Tom Tromey wrote: > Pedro> Yeah, sorry I should have said I also looked and couldn't find > Pedro> where's that being used. It look like a dead path at this point. > Pedro> I'll do a testrun with a gdb_assert in place to be a bit more sure. > > I think the last user was probably "commands" without an argument, and > then my commands-for-rbreak change modified this code path. Okay, thanks, the gdb_assert never triggered, so I just removed the support for NULL pp completely. Here's what I tested&applied. Thanks for the initial patch Guillaume. -- Pedro Alves 2011-02-18 Pedro Alves gdb/ * 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. --- gdb/breakpoint.c | 9 +------ gdb/breakpoint.h | 2 + gdb/printcmd.c | 62 ++++++++++++++++++++++++++++--------------------------- 3 files changed, 36 insertions(+), 37 deletions(-) Index: src/gdb/breakpoint.c =================================================================== --- src.orig/gdb/breakpoint.c 2011-02-18 16:27:51.000000000 +0000 +++ src/gdb/breakpoint.c 2011-02-18 16:30:02.627376997 +0000 @@ -561,8 +561,6 @@ struct program_space *default_breakpoint 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 trail 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; Index: src/gdb/breakpoint.h =================================================================== --- src.orig/gdb/breakpoint.h 2011-02-18 16:29:47.000000000 +0000 +++ src/gdb/breakpoint.h 2011-02-18 16:30:02.627376997 +0000 @@ -1191,4 +1191,6 @@ extern struct breakpoint *iterate_over_b extern int user_breakpoint_p (struct breakpoint *); +extern int get_number_or_range (char **pp); + #endif /* !defined (BREAKPOINT_H) */ Index: src/gdb/printcmd.c =================================================================== --- src.orig/gdb/printcmd.c 2011-02-18 16:29:47.000000000 +0000 +++ src/gdb/printcmd.c 2011-02-18 16:30:02.677376997 +0000 @@ -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_ 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 (); }