Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] Dont skip DW_TAG_member in load_partial_dies()
@ 2005-02-16  0:17 Manoj Iyer
  2005-02-16  1:09 ` Daniel Jacobowitz
  0 siblings, 1 reply; 11+ messages in thread
From: Manoj Iyer @ 2005-02-16  0:17 UTC (permalink / raw)
  To: gdb-patches


GDB prints internal error with C++ application produced by XLC.


=============== Test Case ========================
/* This testcase written by Lu Yang <luyang@ca.ibm.com> */

template<class T> class X;
template <class T>
class Y {
      friend class X<T>;
public:
      T f();
};

template <class T>
class X {
public:
      friend inline T Y<T>::f();
      static T a;
};

template <class T> inline T Y<T>::f() {return X<T>::a;}

template<> int X<int>::a =5;

int main() {

     Y<int> obj;
     if (obj.f() == 5)
         return 55;
     else
         return 66;
}

====================== End Test Case =====================

When the above testcase is compiled -m64 by XLC, GDB generates an internal
error:

"internal-error: could not find partial DIE in cache"

GCC creates a DWARF TAG for "a" as DW_TAG_variable and XLC creates
DW_TAG_member. GDB throws away TAGS that it find as uninteresting. In this
case DW_TAG_member. (this is in dwarf2read.c function:
load_partial_dies(). )

GCC created DWARF information
-------------------------------
 <2><102>: Abbrev Number: 13 (DW_TAG_variable)
     DW_AT_name        : a
     DW_AT_decl_file   : 1
     DW_AT_decl_line   : 13
     DW_AT_MIPS_linkage_name: _ZN1XIiE1aE
     DW_AT_type        : <d5>
     DW_AT_external    : 1
     DW_AT_declaration : 1

XLC created DWARF information
------------------------------
 <2><96>: Abbrev Number: 5 (DW_TAG_member)
     DW_AT_name        : a
     DW_AT_accessibility: 1     (public)
     DW_AT_declaration : 1
     DW_AT_type        : <78>


GCC in this case is producing wrong information. According to DWARF
spec:

" If the variable entry represents the defining declaration for a C++
static data member of a structure, class or union, the entry has a
DW_AT_specification attribute, whose value is a reference to the debugging
information entry representing the declaration of this data member. The
referenced entry has the tag DW_TAG_member and will be a child of some
class, structure or union type entry. "

So I think GDB needs to handle the DW_TAG_member and not skip it, when
dealing with  C++.

Here is a patch to GDB that will fix this problem

================ Patch to gdb ==================
2005-02-15  Manoj Iyer  <manjo@austin.ibm.com>

        * dwarf2read.c (load_partial_dies): Save DIE with tag
        DW_TAG_member, generated by XLC when compiling C++ application.

diff -Naur ./old/src/gdb/dwarf2read.c ./new/src/gdb/dwarf2read.c
--- ./old/src/gdb/dwarf2read.c  2005-02-15 11:13:05.000000000 -0600
+++ ./new/src/gdb/dwarf2read.c  2005-02-22 10:24:08.000000000 -0600
@@ -5167,7 +5167,8 @@
          && abbrev->tag != DW_TAG_enumerator
          && abbrev->tag != DW_TAG_subprogram
          && abbrev->tag != DW_TAG_variable
-         && abbrev->tag != DW_TAG_namespace)
+         && abbrev->tag != DW_TAG_namespace
+         && abbrev->tag != DW_TAG_member)
        {
          /* Otherwise we skip to the next sibling, if any.  */
          info_ptr = skip_one_die (info_ptr + bytes_read, abbrev, cu);

========================= END PATCH ======================


ok to commit?

Thanks
-----
manjo
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Cogito ergo sum                                                          +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


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

* Re: [RFC] Dont skip DW_TAG_member in load_partial_dies()
  2005-02-16  0:17 [RFC] Dont skip DW_TAG_member in load_partial_dies() Manoj Iyer
@ 2005-02-16  1:09 ` Daniel Jacobowitz
  2005-02-16  2:18   ` Joel Brobecker
                     ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Daniel Jacobowitz @ 2005-02-16  1:09 UTC (permalink / raw)
  To: Manoj Iyer; +Cc: gdb-patches, Elena Zannoni

On Tue, Feb 15, 2005 at 03:06:57PM -0600, Manoj Iyer wrote:
> 
> GDB prints internal error with C++ application produced by XLC.

Many of the tests in the GDB testsuite already will probably produce
this error, if you want to try running the testsuite with xlC.  It
probably won't be easy, though.

I'm copying this to Elena, since she is the maintainer of the DWARF-2
reader.  Your patch looks right to me.  In fact, I've been working on
running the GDB testsuite using ARM's compiler today, and I have a
patch that looks exactly like this in my working directory :-)

> When the above testcase is compiled -m64 by XLC, GDB generates an internal
> error:
> 
> "internal-error: could not find partial DIE in cache"
> 
> GCC creates a DWARF TAG for "a" as DW_TAG_variable and XLC creates
> DW_TAG_member. GDB throws away TAGS that it find as uninteresting. In this
> case DW_TAG_member. (this is in dwarf2read.c function:
> load_partial_dies(). )
> 
> GCC created DWARF information
> -------------------------------
>  <2><102>: Abbrev Number: 13 (DW_TAG_variable)
>      DW_AT_name        : a
>      DW_AT_decl_file   : 1
>      DW_AT_decl_line   : 13
>      DW_AT_MIPS_linkage_name: _ZN1XIiE1aE
>      DW_AT_type        : <d5>
>      DW_AT_external    : 1
>      DW_AT_declaration : 1
> 
> XLC created DWARF information
> ------------------------------
>  <2><96>: Abbrev Number: 5 (DW_TAG_member)
>      DW_AT_name        : a
>      DW_AT_accessibility: 1     (public)
>      DW_AT_declaration : 1
>      DW_AT_type        : <78>
> 
> 
> GCC in this case is producing wrong information. According to DWARF
> spec:
> 
> " If the variable entry represents the defining declaration for a C++
> static data member of a structure, class or union, the entry has a
> DW_AT_specification attribute, whose value is a reference to the debugging
> information entry representing the declaration of this data member. The
> referenced entry has the tag DW_TAG_member and will be a child of some
> class, structure or union type entry. "
> 
> So I think GDB needs to handle the DW_TAG_member and not skip it, when
> dealing with  C++.
> 
> Here is a patch to GDB that will fix this problem
> 
> ================ Patch to gdb ==================
> 2005-02-15  Manoj Iyer  <manjo@austin.ibm.com>
> 
>         * dwarf2read.c (load_partial_dies): Save DIE with tag
>         DW_TAG_member, generated by XLC when compiling C++ application.
> 
> diff -Naur ./old/src/gdb/dwarf2read.c ./new/src/gdb/dwarf2read.c
> --- ./old/src/gdb/dwarf2read.c  2005-02-15 11:13:05.000000000 -0600
> +++ ./new/src/gdb/dwarf2read.c  2005-02-22 10:24:08.000000000 -0600
> @@ -5167,7 +5167,8 @@
>           && abbrev->tag != DW_TAG_enumerator
>           && abbrev->tag != DW_TAG_subprogram
>           && abbrev->tag != DW_TAG_variable
> -         && abbrev->tag != DW_TAG_namespace)
> +         && abbrev->tag != DW_TAG_namespace
> +         && abbrev->tag != DW_TAG_member)
>         {
>           /* Otherwise we skip to the next sibling, if any.  */
>           info_ptr = skip_one_die (info_ptr + bytes_read, abbrev, cu);
> 
> ========================= END PATCH ======================
> 
> 
> ok to commit?
> 
> Thanks
> -----
> manjo
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> + Cogito ergo sum                                                          +
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 

-- 
Daniel Jacobowitz
CodeSourcery, LLC


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

* Re: [RFC] Dont skip DW_TAG_member in load_partial_dies()
  2005-02-16  1:09 ` Daniel Jacobowitz
@ 2005-02-16  2:18   ` Joel Brobecker
  2005-02-16  3:24     ` Daniel Jacobowitz
  2005-02-16 13:46   ` Manoj Iyer
  2005-03-02 18:32   ` Manoj Iyer
  2 siblings, 1 reply; 11+ messages in thread
From: Joel Brobecker @ 2005-02-16  2:18 UTC (permalink / raw)
  To: Manoj Iyer, gdb-patches, Elena Zannoni

> I'm copying this to Elena, since she is the maintainer of the DWARF-2
> reader.  Your patch looks right to me.  In fact, I've been working on
> running the GDB testsuite using ARM's compiler today, and I have a
> patch that looks exactly like this in my working directory :-)

We also found the same sort of problem for Ada, and ended up doing
the same thing. We haven't had time to submit this change yet, as
there were a few things we wanted to thing about before doing so.

Just FYI: Here is the change we've made so far in gdb-6.3.

       if (abbrev->tag == DW_TAG_subprogram
          || abbrev->tag == DW_TAG_variable
          || abbrev->tag == DW_TAG_namespace
+          || abbrev->tag == DW_TAG_enumeration_type
+          || abbrev->tag == DW_TAG_structure_type

-- 
Joel


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

* Re: [RFC] Dont skip DW_TAG_member in load_partial_dies()
  2005-02-16  2:18   ` Joel Brobecker
@ 2005-02-16  3:24     ` Daniel Jacobowitz
  2005-02-16 22:50       ` Joel Brobecker
  2005-02-17  0:38       ` Manoj Iyer
  0 siblings, 2 replies; 11+ messages in thread
From: Daniel Jacobowitz @ 2005-02-16  3:24 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Manoj Iyer, gdb-patches, Elena Zannoni

On Tue, Feb 15, 2005 at 03:35:03PM -0800, Joel Brobecker wrote:
> > I'm copying this to Elena, since she is the maintainer of the DWARF-2
> > reader.  Your patch looks right to me.  In fact, I've been working on
> > running the GDB testsuite using ARM's compiler today, and I have a
> > patch that looks exactly like this in my working directory :-)
> 
> We also found the same sort of problem for Ada, and ended up doing
> the same thing. We haven't had time to submit this change yet, as
> there were a few things we wanted to thing about before doing so.
> 
> Just FYI: Here is the change we've made so far in gdb-6.3.
> 
>        if (abbrev->tag == DW_TAG_subprogram
>           || abbrev->tag == DW_TAG_variable
>           || abbrev->tag == DW_TAG_namespace
> +          || abbrev->tag == DW_TAG_enumeration_type
> +          || abbrev->tag == DW_TAG_structure_type

That's a very different problem - you're at the other interesting if in
this function.  Please show me an example of debug information which
requires this - and see the comment above which talks about why most of
these checks are only for buggy compilers...

-- 
Daniel Jacobowitz
CodeSourcery, LLC


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

* Re: [RFC] Dont skip DW_TAG_member in load_partial_dies()
  2005-02-16  1:09 ` Daniel Jacobowitz
  2005-02-16  2:18   ` Joel Brobecker
@ 2005-02-16 13:46   ` Manoj Iyer
  2005-03-02 18:32   ` Manoj Iyer
  2 siblings, 0 replies; 11+ messages in thread
From: Manoj Iyer @ 2005-02-16 13:46 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches, Elena Zannoni


Elena,

If you agree with the change I can commit after your approval. Thanks
Daniel for your comments.

Thanks
-----
manjo
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Cogito ergo sum                                                          +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

On Tue, 15 Feb 2005, Daniel Jacobowitz wrote:

> On Tue, Feb 15, 2005 at 03:06:57PM -0600, Manoj Iyer wrote:
> >
> > GDB prints internal error with C++ application produced by XLC.
>
> Many of the tests in the GDB testsuite already will probably produce
> this error, if you want to try running the testsuite with xlC.  It
> probably won't be easy, though.
>
> I'm copying this to Elena, since she is the maintainer of the DWARF-2
> reader.  Your patch looks right to me.  In fact, I've been working on
> running the GDB testsuite using ARM's compiler today, and I have a
> patch that looks exactly like this in my working directory :-)
>
> > When the above testcase is compiled -m64 by XLC, GDB generates an internal
> > error:
> >
> > "internal-error: could not find partial DIE in cache"
> >
> > GCC creates a DWARF TAG for "a" as DW_TAG_variable and XLC creates
> > DW_TAG_member. GDB throws away TAGS that it find as uninteresting. In this
> > case DW_TAG_member. (this is in dwarf2read.c function:
> > load_partial_dies(). )
> >
> > GCC created DWARF information
> > -------------------------------
> >  <2><102>: Abbrev Number: 13 (DW_TAG_variable)
> >      DW_AT_name        : a
> >      DW_AT_decl_file   : 1
> >      DW_AT_decl_line   : 13
> >      DW_AT_MIPS_linkage_name: _ZN1XIiE1aE
> >      DW_AT_type        : <d5>
> >      DW_AT_external    : 1
> >      DW_AT_declaration : 1
> >
> > XLC created DWARF information
> > ------------------------------
> >  <2><96>: Abbrev Number: 5 (DW_TAG_member)
> >      DW_AT_name        : a
> >      DW_AT_accessibility: 1     (public)
> >      DW_AT_declaration : 1
> >      DW_AT_type        : <78>
> >
> >
> > GCC in this case is producing wrong information. According to DWARF
> > spec:
> >
> > " If the variable entry represents the defining declaration for a C++
> > static data member of a structure, class or union, the entry has a
> > DW_AT_specification attribute, whose value is a reference to the debugging
> > information entry representing the declaration of this data member. The
> > referenced entry has the tag DW_TAG_member and will be a child of some
> > class, structure or union type entry. "
> >
> > So I think GDB needs to handle the DW_TAG_member and not skip it, when
> > dealing with  C++.
> >
> > Here is a patch to GDB that will fix this problem
> >
> > ================ Patch to gdb ==================
> > 2005-02-15  Manoj Iyer  <manjo@austin.ibm.com>
> >
> >         * dwarf2read.c (load_partial_dies): Save DIE with tag
> >         DW_TAG_member, generated by XLC when compiling C++ application.
> >
> > diff -Naur ./old/src/gdb/dwarf2read.c ./new/src/gdb/dwarf2read.c
> > --- ./old/src/gdb/dwarf2read.c  2005-02-15 11:13:05.000000000 -0600
> > +++ ./new/src/gdb/dwarf2read.c  2005-02-22 10:24:08.000000000 -0600
> > @@ -5167,7 +5167,8 @@
> >           && abbrev->tag != DW_TAG_enumerator
> >           && abbrev->tag != DW_TAG_subprogram
> >           && abbrev->tag != DW_TAG_variable
> > -         && abbrev->tag != DW_TAG_namespace)
> > +         && abbrev->tag != DW_TAG_namespace
> > +         && abbrev->tag != DW_TAG_member)
> >         {
> >           /* Otherwise we skip to the next sibling, if any.  */
> >           info_ptr = skip_one_die (info_ptr + bytes_read, abbrev, cu);
> >
> > ========================= END PATCH ======================
> >
> >
> > ok to commit?
> >
> > Thanks
> > -----
> > manjo
> > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > + Cogito ergo sum                                                          +
> > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
>
> --
> Daniel Jacobowitz
> CodeSourcery, LLC
>


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

* Re: [RFC] Dont skip DW_TAG_member in load_partial_dies()
  2005-02-16  3:24     ` Daniel Jacobowitz
@ 2005-02-16 22:50       ` Joel Brobecker
  2005-02-17 14:30         ` Daniel Jacobowitz
  2005-02-17  0:38       ` Manoj Iyer
  1 sibling, 1 reply; 11+ messages in thread
From: Joel Brobecker @ 2005-02-16 22:50 UTC (permalink / raw)
  To: Manoj Iyer, gdb-patches, Elena Zannoni

Hello Daniel,

> > Just FYI: Here is the change we've made so far in gdb-6.3.
> > 
> >        if (abbrev->tag == DW_TAG_subprogram
> >           || abbrev->tag == DW_TAG_variable
> >           || abbrev->tag == DW_TAG_namespace
> > +          || abbrev->tag == DW_TAG_enumeration_type
> > +          || abbrev->tag == DW_TAG_structure_type
> 
> That's a very different problem - you're at the other interesting if in
> this function.  Please show me an example of debug information which
> requires this - and see the comment above which talks about why most of
> these checks are only for buggy compilers...

It's a long story :).

In Ada, we allow nested functions. In order to be able to break inside
a nested function, using "break nested_function", we need to scan the
DIEs inside subprogram DIEs and build partial symbols for them. That's
the first local change we did. Something like: if ada and then
subprogram, then do not skip to sibling.

And next, we face something a bit out of the ordinary: We had a function
that was inlined. That caused GCC to create a nameless subprogram DIE,
with an AT_specification attribute pointing to the original procedure.
The tricky part was that there was inside that procedure a nameless
enumeration DIE that also had an AT_specification. We failed on that
second AT_specification during the lookup in the hash-table.

I hope this makes sense. I'm trying to be short as I'm busier than
I have ever been right now. Don't hesitate to let me know if I'm not,
though.  It may take a bit of time for me to answer, but I will answer.

-- 
Joel


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

* Re: [RFC] Dont skip DW_TAG_member in load_partial_dies()
  2005-02-16  3:24     ` Daniel Jacobowitz
  2005-02-16 22:50       ` Joel Brobecker
@ 2005-02-17  0:38       ` Manoj Iyer
  2005-02-17 14:06         ` Daniel Jacobowitz
  1 sibling, 1 reply; 11+ messages in thread
From: Manoj Iyer @ 2005-02-17  0:38 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

> > > I'm copying this to Elena, since she is the maintainer of the DWARF-2
> > > reader.  Your patch looks right to me.  In fact, I've been working on
> > > running the GDB testsuite using ARM's compiler today, and I have a
> > > patch that looks exactly like this in my working directory :-)

What is the clean way of using a different compiler? I tried the
CC_FOR_TARGET CC variabels etc but dint work. Also, nothing documented.
Really appreciate your input.

--
Manjo


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

* Re: [RFC] Dont skip DW_TAG_member in load_partial_dies()
  2005-02-17  0:38       ` Manoj Iyer
@ 2005-02-17 14:06         ` Daniel Jacobowitz
  0 siblings, 0 replies; 11+ messages in thread
From: Daniel Jacobowitz @ 2005-02-17 14:06 UTC (permalink / raw)
  To: Manoj Iyer; +Cc: gdb-patches

On Wed, Feb 16, 2005 at 04:40:19PM -0600, Manoj Iyer wrote:
> > > > I'm copying this to Elena, since she is the maintainer of the DWARF-2
> > > > reader.  Your patch looks right to me.  In fact, I've been working on
> > > > running the GDB testsuite using ARM's compiler today, and I have a
> > > > patch that looks exactly like this in my working directory :-)
> 
> What is the clean way of using a different compiler? I tried the
> CC_FOR_TARGET CC variabels etc but dint work. Also, nothing documented.
> Really appreciate your input.

For native testing it's a bit tricky; I recommend using wrapper
scripts, earlier in your path, called gcc and g++.  For target testing
you can set 'compiler' and 'c++compiler' in the board file.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


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

* Re: [RFC] Dont skip DW_TAG_member in load_partial_dies()
  2005-02-16 22:50       ` Joel Brobecker
@ 2005-02-17 14:30         ` Daniel Jacobowitz
  2005-02-17 17:43           ` Joel Brobecker
  0 siblings, 1 reply; 11+ messages in thread
From: Daniel Jacobowitz @ 2005-02-17 14:30 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Manoj Iyer, gdb-patches, Elena Zannoni

On Wed, Feb 16, 2005 at 11:08:24AM -0800, Joel Brobecker wrote:
> Hello Daniel,
> 
> > > Just FYI: Here is the change we've made so far in gdb-6.3.

[BTW: A bug report would have been nice... this'll do :-)]

> > > 
> > >        if (abbrev->tag == DW_TAG_subprogram
> > >           || abbrev->tag == DW_TAG_variable
> > >           || abbrev->tag == DW_TAG_namespace
> > > +          || abbrev->tag == DW_TAG_enumeration_type
> > > +          || abbrev->tag == DW_TAG_structure_type
> > 
> > That's a very different problem - you're at the other interesting if in
> > this function.  Please show me an example of debug information which
> > requires this - and see the comment above which talks about why most of
> > these checks are only for buggy compilers...
> 
> It's a long story :).
> 
> In Ada, we allow nested functions. In order to be able to break inside
> a nested function, using "break nested_function", we need to scan the
> DIEs inside subprogram DIEs and build partial symbols for them. That's
> the first local change we did. Something like: if ada and then
> subprogram, then do not skip to sibling.
> 
> And next, we face something a bit out of the ordinary: We had a function
> that was inlined. That caused GCC to create a nameless subprogram DIE,
> with an AT_specification attribute pointing to the original procedure.
> The tricky part was that there was inside that procedure a nameless
> enumeration DIE that also had an AT_specification. We failed on that
> second AT_specification during the lookup in the hash-table.
> 
> I hope this makes sense. I'm trying to be short as I'm busier than
> I have ever been right now. Don't hesitate to let me know if I'm not,
> though.  It may take a bit of time for me to answer, but I will answer.

This sounds like a case that's too complicated for the heuristics to
handle.  I have a patch under test which implements a more thorough
fallback when lookup in the hash table fails.  That allows the
heuristics to be relatively quick, and work for the common case, but
still support more complex cases like this one.

The example I developed it for (this morning) was a C++ function-local
class, like gdb.cp/local.exp, which had an out-of-line definition of
the member function.  That also would have required recursing into
subprograms, and therefore also recursing into lexical blocks, which
defeats the point of the heuristics entirely.

I'm not done testing these patches, but if I don't post it soon, nag me
about it!

-- 
Daniel Jacobowitz
CodeSourcery, LLC


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

* Re: [RFC] Dont skip DW_TAG_member in load_partial_dies()
  2005-02-17 14:30         ` Daniel Jacobowitz
@ 2005-02-17 17:43           ` Joel Brobecker
  0 siblings, 0 replies; 11+ messages in thread
From: Joel Brobecker @ 2005-02-17 17:43 UTC (permalink / raw)
  To: Manoj Iyer, gdb-patches, Elena Zannoni

> This sounds like a case that's too complicated for the heuristics to
> handle.  I have a patch under test which implements a more thorough
> fallback when lookup in the hash table fails.  That allows the
> heuristics to be relatively quick, and work for the common case, but
> still support more complex cases like this one.

Sounds like a great idea. The reason we didn't submit our changes
was that we were also convinced that our solution was not the best
approach (we were concerned that we would end up scanning all the
symbols, and hence more or less defeating the purpose of partial
symbols). Your solution addresses these concerns very nicely.

-- 
Joel


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

* Re: [RFC] Dont skip DW_TAG_member in load_partial_dies()
  2005-02-16  1:09 ` Daniel Jacobowitz
  2005-02-16  2:18   ` Joel Brobecker
  2005-02-16 13:46   ` Manoj Iyer
@ 2005-03-02 18:32   ` Manoj Iyer
  2 siblings, 0 replies; 11+ messages in thread
From: Manoj Iyer @ 2005-03-02 18:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Elena Zannoni


Elena,

Any comments on this patch of mine? ok to commit?


Thanks
-----
manjo
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Cogito ergo sum                                                          +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

On Tue, 15 Feb 2005, Daniel Jacobowitz wrote:

> On Tue, Feb 15, 2005 at 03:06:57PM -0600, Manoj Iyer wrote:
> >
> > GDB prints internal error with C++ application produced by XLC.
>
> Many of the tests in the GDB testsuite already will probably produce
> this error, if you want to try running the testsuite with xlC.  It
> probably won't be easy, though.
>
> I'm copying this to Elena, since she is the maintainer of the DWARF-2
> reader.  Your patch looks right to me.  In fact, I've been working on
> running the GDB testsuite using ARM's compiler today, and I have a
> patch that looks exactly like this in my working directory :-)
>
> > When the above testcase is compiled -m64 by XLC, GDB generates an internal
> > error:
> >
> > "internal-error: could not find partial DIE in cache"
> >
> > GCC creates a DWARF TAG for "a" as DW_TAG_variable and XLC creates
> > DW_TAG_member. GDB throws away TAGS that it find as uninteresting. In this
> > case DW_TAG_member. (this is in dwarf2read.c function:
> > load_partial_dies(). )
> >
> > GCC created DWARF information
> > -------------------------------
> >  <2><102>: Abbrev Number: 13 (DW_TAG_variable)
> >      DW_AT_name        : a
> >      DW_AT_decl_file   : 1
> >      DW_AT_decl_line   : 13
> >      DW_AT_MIPS_linkage_name: _ZN1XIiE1aE
> >      DW_AT_type        : <d5>
> >      DW_AT_external    : 1
> >      DW_AT_declaration : 1
> >
> > XLC created DWARF information
> > ------------------------------
> >  <2><96>: Abbrev Number: 5 (DW_TAG_member)
> >      DW_AT_name        : a
> >      DW_AT_accessibility: 1     (public)
> >      DW_AT_declaration : 1
> >      DW_AT_type        : <78>
> >
> >
> > GCC in this case is producing wrong information. According to DWARF
> > spec:
> >
> > " If the variable entry represents the defining declaration for a C++
> > static data member of a structure, class or union, the entry has a
> > DW_AT_specification attribute, whose value is a reference to the debugging
> > information entry representing the declaration of this data member. The
> > referenced entry has the tag DW_TAG_member and will be a child of some
> > class, structure or union type entry. "
> >
> > So I think GDB needs to handle the DW_TAG_member and not skip it, when
> > dealing with  C++.
> >
> > Here is a patch to GDB that will fix this problem
> >
> > ================ Patch to gdb ==================
> > 2005-02-15  Manoj Iyer  <manjo@austin.ibm.com>
> >
> >         * dwarf2read.c (load_partial_dies): Save DIE with tag
> >         DW_TAG_member, generated by XLC when compiling C++ application.
> >
> > diff -Naur ./old/src/gdb/dwarf2read.c ./new/src/gdb/dwarf2read.c
> > --- ./old/src/gdb/dwarf2read.c  2005-02-15 11:13:05.000000000 -0600
> > +++ ./new/src/gdb/dwarf2read.c  2005-02-22 10:24:08.000000000 -0600
> > @@ -5167,7 +5167,8 @@
> >           && abbrev->tag != DW_TAG_enumerator
> >           && abbrev->tag != DW_TAG_subprogram
> >           && abbrev->tag != DW_TAG_variable
> > -         && abbrev->tag != DW_TAG_namespace)
> > +         && abbrev->tag != DW_TAG_namespace
> > +         && abbrev->tag != DW_TAG_member)
> >         {
> >           /* Otherwise we skip to the next sibling, if any.  */
> >           info_ptr = skip_one_die (info_ptr + bytes_read, abbrev, cu);
> >
> > ========================= END PATCH ======================
> >
> >
> > ok to commit?
> >
> > Thanks
> > -----
> > manjo
> > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > + Cogito ergo sum                                                          +
> > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >
>
> --
> Daniel Jacobowitz
> CodeSourcery, LLC
>


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

end of thread, other threads:[~2005-03-02 18:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-16  0:17 [RFC] Dont skip DW_TAG_member in load_partial_dies() Manoj Iyer
2005-02-16  1:09 ` Daniel Jacobowitz
2005-02-16  2:18   ` Joel Brobecker
2005-02-16  3:24     ` Daniel Jacobowitz
2005-02-16 22:50       ` Joel Brobecker
2005-02-17 14:30         ` Daniel Jacobowitz
2005-02-17 17:43           ` Joel Brobecker
2005-02-17  0:38       ` Manoj Iyer
2005-02-17 14:06         ` Daniel Jacobowitz
2005-02-16 13:46   ` Manoj Iyer
2005-03-02 18:32   ` Manoj Iyer

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