From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11971 invoked by alias); 19 Apr 2004 18:13:49 -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 11963 invoked from network); 19 Apr 2004 18:13:49 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (142.179.108.108) by sources.redhat.com with SMTP; 19 Apr 2004 18:13:49 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id 6999B47D63; Mon, 19 Apr 2004 11:13:49 -0700 (PDT) Date: Mon, 19 Apr 2004 18:13:00 -0000 From: Joel Brobecker To: Jim Blandy Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] New dwarf2_attribute_true_p function in dwarf2read.c (take 2) Message-ID: <20040419181349.GB22414@gnat.com> References: <20040416212108.GJ22414@gnat.com> <20040419170932.GW22414@gnat.com> <20040419171821.GA16454@nevyn.them.org> <20040419172546.GX22414@gnat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="kH8JNVvasRCCW1Oz" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i X-SW-Source: 2004-04/txt/msg00439.txt.bz2 --kH8JNVvasRCCW1Oz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 306 > Perfect. Cool. Attached is what I ended up checkin in: function name revised, and comment also added. 2004-04-19 Joel Brobecker * dwarf2read.c (dwarf2_flag_true_p): New function. (die_is_declaration): Use the function above. Add some comments. Cheers, -- Joel --kH8JNVvasRCCW1Oz Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="true_p.diff" Content-length: 2041 Index: dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.146 diff -u -p -r1.146 dwarf2read.c --- dwarf2read.c 16 Apr 2004 16:12:52 -0000 1.146 +++ dwarf2read.c 19 Apr 2004 18:07:56 -0000 @@ -732,6 +732,9 @@ static void set_cu_language (unsigned in static struct attribute *dwarf2_attr (struct die_info *, unsigned int, struct dwarf2_cu *); +static int dwarf2_flag_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, @@ -5549,11 +5552,30 @@ 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. This function should only be used for + DW_FORM_flag attributes. */ + +static int +dwarf2_flag_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 with + DIEs having a DW_AT_specification attribute, because dwarf2_attr() + (via dwarf2_flag_true_p) follows this attribute. So we may + end up accidently finding a declaration attribute that belongs + to a different DIE referenced by the specification attribute, + even though the given DIE does not have a declaration attribute. */ + return (dwarf2_flag_true_p (die, DW_AT_declaration, cu) + && dwarf2_attr (die, DW_AT_specification, cu) == NULL); } /* Return the die giving the specification for DIE, if there is --kH8JNVvasRCCW1Oz--