From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19547 invoked by alias); 4 Aug 2015 00:02:47 -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 19535 invoked by uid 89); 4 Aug 2015 00:02:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 04 Aug 2015 00:02:45 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 8BE33225 for ; Tue, 4 Aug 2015 00:02:44 +0000 (UTC) Received: from pinnacle.lan (ovpn-113-146.phx2.redhat.com [10.3.113.146]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7402hXh005045 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO) for ; Mon, 3 Aug 2015 20:02:44 -0400 Date: Tue, 04 Aug 2015 00:02:00 -0000 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: Re: [PATCH] dwarf2read.c: Check type of linkage name attribute prior to decoding Message-ID: <20150803170242.40de4e22@pinnacle.lan> In-Reply-To: References: <20150803154721.29a6a4ec@pinnacle.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00056.txt.bz2 On Mon, 3 Aug 2015 16:31:08 -0700 Doug Evans wrote: > On Mon, Aug 3, 2015 at 3:47 PM, Kevin Buettner wrote: > > > > > * gdb.dwarf2/dw2-bad-mips-linkage-name.S: New file. > > * gdb.dwarf2/dw2-bad-mips-linkage-name.exp: New file. > > If I wanted to regenerate the .S how would I do it? > [generated .S files needs such instructions] You wouldn't, at least not easily. I used a circa 2010 mips-elf toolchain to create a .S file which I then modified by hand, both removing sections not relevant to the test as well as adding in a reference to the DW_AT_MIPS_linkage_name attribute that's not a string. > I wonder, though, if this is a good place for using the dwarf assembler. > Seems so. We just need a MIPS_linkage_name attribute > that isn't a string. The dwarf assembler test would be a lot > smaller. Thanks for the suggestion. I'll look into this. > > diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c > > index 24a4022..9eb7cbc 100644 > > --- a/gdb/dwarf2read.c > > +++ b/gdb/dwarf2read.c > > @@ -8722,7 +8722,10 @@ dwarf2_physname (const char *name, struct die_info *die, struct dwarf2_cu *cu) > > > > /* DW_AT_linkage_name is missing in some cases - depend on what GDB > > has computed. */ > > - if (attr && DW_STRING (attr)) > > + if (attr > > + && (attr->form == DW_FORM_strp || attr->form == DW_FORM_string > > + || attr->form == DW_FORM_GNU_strp_alt) > > + && DW_STRING (attr)) > > { > > char *demangled; > > One thought that comes to mind is that gdb should protect itself > from all such mistakes. > > What if there was a wrapper on dwarf2_attr, dwarf2_string_attr > or some such, and it returned either the attribute (if the attribute > is present *and* is a string) or NULL. > And if the attribute is present but not a string it logs a > complaint (standard bad debug info complaint) and returns NULL. Sounds reasonable. I'll take a look at this too. Kevin