Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] New dwarf2_attribute_true_p function in dwarf2read.c
@ 2004-04-15 20:23 Joel Brobecker
  2004-04-16  4:15 ` Jim Blandy
  2004-04-16 14:20 ` Daniel Jacobowitz
  0 siblings, 2 replies; 6+ messages in thread
From: Joel Brobecker @ 2004-04-15 20:23 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

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  <brobecker@gnat.com>

        * 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

[-- Attachment #2: dwarf2read.c.diff --]
[-- Type: text/plain, Size: 1894 bytes --]

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA] New dwarf2_attribute_true_p function in dwarf2read.c
  2004-04-15 20:23 [RFA] New dwarf2_attribute_true_p function in dwarf2read.c Joel Brobecker
@ 2004-04-16  4:15 ` Jim Blandy
  2004-04-16  4:32   ` Joel Brobecker
  2004-04-16 14:20 ` Daniel Jacobowitz
  1 sibling, 1 reply; 6+ messages in thread
From: Jim Blandy @ 2004-04-16  4:15 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

Joel Brobecker <brobecker@gnat.com> writes:

> 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  <brobecker@gnat.com>
> 
>         * dwarf2read.c (dwarf2_attribute_true_p): New function.
>         (die_is_declaration): Use the function above.
> 
> Tested on x86-linux, no regression.
> 
> OK to apply?

Yep.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA] New dwarf2_attribute_true_p function in dwarf2read.c
  2004-04-16  4:15 ` Jim Blandy
@ 2004-04-16  4:32   ` Joel Brobecker
  0 siblings, 0 replies; 6+ messages in thread
From: Joel Brobecker @ 2004-04-16  4:32 UTC (permalink / raw)
  To: Jim Blandy; +Cc: gdb-patches

> > 2004-04-15  Joel Brobecker  <brobecker@gnat.com>
> > 
> >         * dwarf2read.c (dwarf2_attribute_true_p): New function.
> >         (die_is_declaration): Use the function above.
> > 
> > Tested on x86-linux, no regression.
> > 
> > OK to apply?
> 
> Yep.

Thanks a lot. Checked in.

I'll also see if we can reuse that new function a bit more...

-- 
Joel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA] New dwarf2_attribute_true_p function in dwarf2read.c
  2004-04-15 20:23 [RFA] New dwarf2_attribute_true_p function in dwarf2read.c Joel Brobecker
  2004-04-16  4:15 ` Jim Blandy
@ 2004-04-16 14:20 ` Daniel Jacobowitz
  2004-04-16 16:18   ` Joel Brobecker
  2004-04-16 21:37   ` Jim Blandy
  1 sibling, 2 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2004-04-16 14:20 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On Thu, Apr 15, 2004 at 01:23:18PM -0700, Joel Brobecker wrote:
> 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  <brobecker@gnat.com>
> 
>         * dwarf2read.c (dwarf2_attribute_true_p): New function.
>         (die_is_declaration): Use the function above.
> 
> Tested on x86-linux, no regression.
> 
> OK to apply?

Sorry, this patch is incorrect.

> -  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

First of all, there's no dwarf2_attribute_p, you mean dwarf2_attr and
dwarf2_attr_true_p.

Secondly, the predicate function should be used for flag attributes
like DW_AT_declaration, but checking DW_UNSND for DW_AT_specification
is incorrect - it's a DIE reference.  dwarf2_attr != NULL is the right
check.  Some day I hope to add checking macros to verify we're using
the right member of each union...

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA] New dwarf2_attribute_true_p function in dwarf2read.c
  2004-04-16 14:20 ` Daniel Jacobowitz
@ 2004-04-16 16:18   ` Joel Brobecker
  2004-04-16 21:37   ` Jim Blandy
  1 sibling, 0 replies; 6+ messages in thread
From: Joel Brobecker @ 2004-04-16 16:18 UTC (permalink / raw)
  To: gdb-patches

> > 2004-04-15  Joel Brobecker  <brobecker@gnat.com>
> > 
> >         * dwarf2read.c (dwarf2_attribute_true_p): New function.
> >         (die_is_declaration): Use the function above.
> > 
> > Tested on x86-linux, no regression.
> > 
> > OK to apply?
> 
> Sorry, this patch is incorrect.

Ah, sorry, you're right, I wasn't paying enough attention.
I have backed the change out for the time being, pending rework.

> > -  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
> 
> First of all, there's no dwarf2_attribute_p, you mean dwarf2_attr and
> dwarf2_attr_true_p.
> 
> Secondly, the predicate function should be used for flag attributes
> like DW_AT_declaration, but checking DW_UNSND for DW_AT_specification
> is incorrect - it's a DIE reference.  dwarf2_attr != NULL is the right
> check.  Some day I hope to add checking macros to verify we're using
> the right member of each union...

I will send a new patch right away.

Thanks Daniel.
-- 
Joel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RFA] New dwarf2_attribute_true_p function in dwarf2read.c
  2004-04-16 14:20 ` Daniel Jacobowitz
  2004-04-16 16:18   ` Joel Brobecker
@ 2004-04-16 21:37   ` Jim Blandy
  1 sibling, 0 replies; 6+ messages in thread
From: Jim Blandy @ 2004-04-16 21:37 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Joel Brobecker, gdb-patches


Daniel Jacobowitz <drow@false.org> writes:
> On Thu, Apr 15, 2004 at 01:23:18PM -0700, Joel Brobecker wrote:
> > 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  <brobecker@gnat.com>
> > 
> >         * dwarf2read.c (dwarf2_attribute_true_p): New function.
> >         (die_is_declaration): Use the function above.
> > 
> > Tested on x86-linux, no regression.
> > 
> > OK to apply?
> 
> Sorry, this patch is incorrect.

Oops.  Thanks, Daniel.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-04-16 21:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-15 20:23 [RFA] New dwarf2_attribute_true_p function in dwarf2read.c Joel Brobecker
2004-04-16  4:15 ` Jim Blandy
2004-04-16  4:32   ` Joel Brobecker
2004-04-16 14:20 ` Daniel Jacobowitz
2004-04-16 16:18   ` Joel Brobecker
2004-04-16 21:37   ` Jim Blandy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox