From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 965 invoked by alias); 15 Apr 2004 20:23:21 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 941 invoked from network); 15 Apr 2004 20:23:19 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (209.53.16.45) by sources.redhat.com with SMTP; 15 Apr 2004 20:23:19 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id B416247D63; Thu, 15 Apr 2004 13:23:18 -0700 (PDT) Date: Thu, 15 Apr 2004 20:23:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: [RFA] New dwarf2_attribute_true_p function in dwarf2read.c Message-ID: <20040415202318.GD1564@gnat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="SUOF0GtieIMvvwua" Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2004-04/txt/msg00325.txt.bz2 --SUOF0GtieIMvvwua Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 380 Hello, Following a suggestion made by JimB in: http://sources.redhat.com/ml/gdb-patches/2004-04/msg00297.html I made the following change: 2004-04-15 Joel Brobecker * dwarf2read.c (dwarf2_attribute_true_p): New function. (die_is_declaration): Use the function above. Tested on x86-linux, no regression. OK to apply? Thanks, -- Joel --SUOF0GtieIMvvwua Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="dwarf2read.c.diff" Content-length: 1894 Index: dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.142 diff -u -p -r1.142 dwarf2read.c --- dwarf2read.c 2 Apr 2004 04:35:46 -0000 1.142 +++ dwarf2read.c 15 Apr 2004 20:20:15 -0000 @@ -677,6 +677,9 @@ static void set_cu_language (unsigned in static struct attribute *dwarf2_attr (struct die_info *, unsigned int, struct dwarf2_cu *); +static int dwarf2_attribute_true_p (struct die_info *die, unsigned name, + struct dwarf2_cu *cu); + static int die_is_declaration (struct die_info *, struct dwarf2_cu *cu); static struct die_info *die_specification (struct die_info *die, @@ -5141,11 +5144,28 @@ dwarf2_attr (struct die_info *die, unsig return NULL; } +/* Return non-zero iff the attribute NAME is defined for the given DIE, + and holds a non-zero value. */ + +static int +dwarf2_attribute_true_p (struct die_info *die, unsigned name, + struct dwarf2_cu *cu) +{ + struct attribute *attr = dwarf2_attr (die, name, cu); + + return (attr && DW_UNSND (attr)); +} + static int die_is_declaration (struct die_info *die, struct dwarf2_cu *cu) { - return (dwarf2_attr (die, DW_AT_declaration, cu) - && ! dwarf2_attr (die, DW_AT_specification, cu)); + /* A DIE is a declaration if it has a DW_AT_declaration attribute + which value is non-zero. However, we have to be careful of DIEs + with a DW_AT_specification attribute, because dwarf2_attribute_p() + follows this attribute, and therefore might cause us to find a + DW_AT_declaration attribute, but that belongs to a different DIE. */ + return (dwarf2_attribute_true_p (die, DW_AT_declaration, cu) + && ! dwarf2_attribute_true_p (die, DW_AT_specification, cu)); } /* Return the die giving the specification for DIE, if there is --SUOF0GtieIMvvwua--