From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1191 invoked by alias); 6 May 2013 17:49:51 -0000 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 Received: (qmail 1181 invoked by uid 89); 6 May 2013 17:49:50 -0000 X-Spam-SWARE-Status: No, score=-8.3 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS,TW_XS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 06 May 2013 17:49:50 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r46Hnnjn019516 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 6 May 2013 13:49:49 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r46HnkLd008536; Mon, 6 May 2013 13:49:47 -0400 Message-ID: <5187ED3A.8000108@redhat.com> Date: Mon, 06 May 2013 17:49:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 MIME-Version: 1.0 To: Sergio Durigan Junior CC: GDB Patches , "Dr. David Alan Gilbert" Subject: Re: [PATCH] Fix for PR 15413 (segfault when completing "condition" for pending bp) References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-05/txt/msg00128.txt.bz2 On 05/06/2013 03:58 AM, Sergio Durigan Junior wrote: > gdb/ > 2013-05-05 Sergio Durigan Junior > > PR breakpoints/15413: > * breakpoint.c (condition_completer): Rewrite parts of the code to > handle completion of the "condition" command for pending > breakpoints. > > gdb/testsuite/ > 2013-05-05 Sergio Durigan Junior > > PR breakpoints/15413: > * gdb.base/pending.exp: Add test for completion of the "condition" > command for pending breakpoints. > > diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c > index 35ada7a..81bf5ed 100644 > --- a/gdb/breakpoint.c > +++ b/gdb/breakpoint.c > @@ -1013,25 +1013,36 @@ condition_completer (struct cmd_list_element *cmd, > > ALL_BREAKPOINTS (b) > { > - int single = b->loc->next == NULL; > - struct bp_location *loc; > + struct bp_location *loc = NULL; > int count = 1; > > - for (loc = b->loc; loc; loc = loc->next) > + do > { > char location[50]; > > - if (single) > - xsnprintf (location, sizeof (location), "%d", b->number); > + if (b->loc == NULL) > + { > + /* We're probably dealing with a pending breakpoint. Just > + inform its number. */ s/probably// s/inform/complete/ ? > + xsnprintf (location, sizeof (location), "%d", b->number); > + } > else > - xsnprintf (location, sizeof (location), "%d.%d", b->number, > - count); > + { > + if (b->loc->next == NULL) > + xsnprintf (location, sizeof (location), "%d", b->number); > + else > + xsnprintf (location, sizeof (location), "%d.%d", b->number, > + count); > + > + loc = b->loc->next; This is always picking the same loc over and over? I guess this means the test should be extended. :-) > + } > > if (strncmp (location, text, len) == 0) > VEC_safe_push (char_ptr, result, xstrdup (location)); > > ++count; > } > + while (loc != NULL); > } > I notice the condition completer is more broken than this, btw: $ ./gdb ./testsuite/gdb.cp/mb-ctor GNU gdb (GDB) 7.6.50.20130430-cvs (gdb) b Derived::Derived Breakpoint 1 at 0x400811: Derived::Derived. (2 locations) (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 1.1 y 0x0000000000400811 in Derived::Derived(int) at ../../../src/gdb/testsuite/gdb.cp/mb-ctor.cc:34 1.2 y 0x0000000000400867 in Derived::Derived(int) at ../../../src/gdb/testsuite/gdb.cp/mb-ctor.cc:34 (gdb) complete condition condition 1.1 condition 1.2 (gdb) complete condition 1 condition 1.1 condition 1.2 (gdb) complete condition 1. condition 1.1.1 condition 1.1.2 (gdb) complete condition 1.1 condition 1.1.1 (gdb) complete condition 1.1 condition 1.1.1 (gdb) complete condition 1.1.1 (gdb) Or: (gdb) condition (gdb) condition 1.1. (gdb) condition 1. (gdb) condition 1. (gdb) condition 1.1. (gdb) condition 1.1. Bad breakpoint argument: '1.1.' BTW2, I'm thinking it'd make sense to always include the breakpoint-number-only ("%d", b->number) completion option, even if there are multiple locations? That is, with breakpoint 1 having two locations, this would happen: (gdb) condition 1 1 1.1 1.2 instead of: (gdb) condition 1 (gdb) condition 1. (gdb) condition 1. 1.1 1.2 Oh, wait, wait, wait... The condition is a breakpoint property, not a location property, so what's with the completer suggesting location numbers at all? (gdb) info breakpoints Num Type Disp Enb Address What 1 breakpoint keep y 1.1 y 0x0000000000400811 in Derived::Derived(int) at ../../../src/gdb/testsuite/gdb.cp/mb-ctor.cc:34 1.2 y 0x0000000000400867 in Derived::Derived(int) at ../../../src/gdb/testsuite/gdb.cp/mb-ctor.cc:34 (gdb) condition 1 0 (gdb) (gdb) condition 1.2 0 Bad breakpoint argument: '1.2 0' -- Pedro Alves