From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30654 invoked by alias); 18 Feb 2011 13:25:58 -0000 Received: (qmail 30643 invoked by uid 22791); 18 Feb 2011 13:25:56 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-qy0-f169.google.com (HELO mail-qy0-f169.google.com) (209.85.216.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 18 Feb 2011 13:25:49 +0000 Received: by qyk2 with SMTP id 2so213783qyk.0 for ; Fri, 18 Feb 2011 05:25:48 -0800 (PST) MIME-Version: 1.0 Received: by 10.224.80.210 with SMTP id u18mr563186qak.389.1298035547847; Fri, 18 Feb 2011 05:25:47 -0800 (PST) Received: by 10.229.31.198 with HTTP; Fri, 18 Feb 2011 05:25:47 -0800 (PST) In-Reply-To: <201102181159.00201.pedro@codesourcery.com> References: <83vd0hvdls.fsf@gnu.org> <201102181159.00201.pedro@codesourcery.com> Date: Fri, 18 Feb 2011 14:41:00 -0000 Message-ID: Subject: Re: [patch] delete a range of display numbers From: Guillaume Leconte To: Pedro Alves Cc: gdb-patches@sourceware.org, Eli Zaretskii Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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/msg00458.txt.bz2 Alright the code works well, with the expected behavious. I think it's obviously the best solution, since it reuses existing code. Thanks. On Fri, Feb 18, 2011 at 12:58 PM, Pedro Alves wrot= e: > The "delete" breakpoint command accepts ranges as > well, and even has code that handles convenience > variables mixed with the numbers. =A0I think we should > reuse that instead of re-adding code that parses ranges. > Might as well make the "delete display" command > implementation look more like the "delete" command > implementation. =A0Here's a quick cut at it. > > -- > Pedro Alves > > --- > =A0gdb/breakpoint.c | =A0 =A05 +--- > =A0gdb/breakpoint.h | =A0 =A02 + > =A0gdb/printcmd.c =A0 | =A0 62 ++++++++++++++++++++++++++++--------------= ------------- > =A03 files changed, 36 insertions(+), 33 deletions(-) > > Index: src/gdb/breakpoint.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- src.orig/gdb/breakpoint.c =A0 2011-02-18 10:13:06.000000000 +0000 > +++ src/gdb/breakpoint.c =A0 =A0 =A0 =A02011-02-18 10:36:37.487376996 +00= 00 > @@ -573,8 +573,7 @@ get_number_trailer (char **pp, int trail > =A0 char *p =3D *pp; > > =A0 if (p =3D=3D NULL) > - =A0 =A0/* Empty line means refer to the last breakpoint. =A0*/ > - =A0 =A0return breakpoint_count; > + =A0 =A0return 0; > =A0 else if (*p =3D=3D '$') > =A0 =A0 { > =A0 =A0 =A0 /* Make a copy of the name, so we can null-terminate it > @@ -651,7 +650,7 @@ get_number (char **pp) > =A0 =A0is completed. =A0The call that completes the range will advance > =A0 =A0pointer PP past . =A0*/ > > -int > +int > =A0get_number_or_range (char **pp) > =A0{ > =A0 static int last_retval, end_value; > Index: src/gdb/breakpoint.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- src.orig/gdb/breakpoint.h =A0 2011-02-08 09:31:08.000000000 +0000 > +++ src/gdb/breakpoint.h =A0 =A0 =A0 =A02011-02-18 10:55:56.367376999 +00= 00 > @@ -1191,4 +1191,6 @@ extern struct breakpoint *iterate_over_b > > =A0extern int user_breakpoint_p (struct breakpoint *); > > +extern int get_number_or_range (char **pp); > + > =A0#endif /* !defined (BREAKPOINT_H) */ > Index: src/gdb/printcmd.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- src.orig/gdb/printcmd.c =A0 =A0 2011-02-01 15:27:37.000000000 +0000 > +++ src/gdb/printcmd.c =A02011-02-18 11:12:56.587376996 +0000 > @@ -167,6 +167,11 @@ static struct display *display_chain; > > =A0static int display_number; > > +/* Walk the following statement or block through all displays. =A0*/ > + > +#define ALL_DISPLAYS(B) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0\ > + =A0for (B =3D display_chain; B; B =3D B->next) > + > =A0/* Prototypes for exported functions. =A0*/ > > =A0void output_command (char *, int); > @@ -1555,35 +1560,26 @@ clear_displays (void) > =A0 =A0 } > =A0} > > -/* Delete the auto-display number NUM. =A0*/ > +/* Delete the auto-display DISPLAY. =A0*/ > > =A0static void > -delete_display (int num) > +delete_display (struct display *display) > =A0{ > - =A0struct display *d1, *d; > + =A0struct display *d; > > - =A0if (!display_chain) > - =A0 =A0error (_("No display number %d."), num); > + =A0gdb_assert (display !=3D NULL); > > - =A0if (display_chain->number =3D=3D num) > - =A0 =A0{ > - =A0 =A0 =A0d1 =3D display_chain; > - =A0 =A0 =A0display_chain =3D d1->next; > - =A0 =A0 =A0free_display (d1); > - =A0 =A0} > - =A0else > - =A0 =A0for (d =3D display_chain;; d =3D d->next) > + =A0if (display_chain =3D=3D display) > + =A0 =A0display_chain =3D display->next; > + > + =A0ALL_DISPLAYS (d) > + =A0 =A0if (d->next =3D=3D display) > =A0 =A0 =A0 { > - =A0 =A0 =A0 if (d->next =3D=3D 0) > - =A0 =A0 =A0 =A0 error (_("No display number %d."), num); > - =A0 =A0 =A0 if (d->next->number =3D=3D num) > - =A0 =A0 =A0 =A0 { > - =A0 =A0 =A0 =A0 =A0 d1 =3D d->next; > - =A0 =A0 =A0 =A0 =A0 d->next =3D d1->next; > - =A0 =A0 =A0 =A0 =A0 free_display (d1); > - =A0 =A0 =A0 =A0 =A0 break; > - =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 d->next =3D display->next; > + =A0 =A0 =A0 break; > =A0 =A0 =A0 } > + > + =A0free_display (display); > =A0} > > =A0/* Delete some values from the auto-display chain. > @@ -1607,18 +1603,24 @@ undisplay_command (char *args, int from_ > =A0 while (*p) > =A0 =A0 { > =A0 =A0 =A0 p1 =3D p; > - =A0 =A0 =A0while (*p1 >=3D '0' && *p1 <=3D '9') > - =A0 =A0 =A0 p1++; > - =A0 =A0 =A0if (*p1 && *p1 !=3D ' ' && *p1 !=3D '\t') > - =A0 =A0 =A0 error (_("Arguments must be display numbers.")); > > - =A0 =A0 =A0num =3D atoi (p); > + =A0 =A0 =A0num =3D get_number_or_range (&p1); > + =A0 =A0 =A0if (num =3D=3D 0) > + =A0 =A0 =A0 warning (_("bad display number at or near '%s'"), p); > + =A0 =A0 =A0else > + =A0 =A0 =A0 { > + =A0 =A0 =A0 =A0 struct display *d; > > - =A0 =A0 =A0delete_display (num); > + =A0 =A0 =A0 =A0 ALL_DISPLAYS (d) > + =A0 =A0 =A0 =A0 =A0 if (d->number =3D=3D num) > + =A0 =A0 =A0 =A0 =A0 =A0 break; > + =A0 =A0 =A0 =A0 if (d =3D=3D NULL) > + =A0 =A0 =A0 =A0 =A0 printf_unfiltered (_("No display number %d.\n"), nu= m); > + =A0 =A0 =A0 =A0 else > + =A0 =A0 =A0 =A0 =A0 delete_display (d); > + =A0 =A0 =A0 } > > =A0 =A0 =A0 p =3D p1; > - =A0 =A0 =A0while (*p =3D=3D ' ' || *p =3D=3D '\t') > - =A0 =A0 =A0 p++; > =A0 =A0 } > =A0 dont_repeat (); > =A0} > --=20 "A fellow of infinite jest, of most excellent fancy."