[Dwarf-discuss] reading DWARF

Michael Eager eager
Tue Feb 6 17:05:19 GMT 2007


gireesh subramaniam wrote:
> 
> Hello all,
>       i wanted to use the object code so as to create a source language 
> independent code browser.Can u help me with some useful links regarding 
> dwarf dump information on inheritance in source or if possible even some 
> programming examples:).The DWARF 3.0 pdf is not very helpful and is not 
> very specific about the tags and attributes for the inheritance in 
> source code.also i have been trying to write C/C++ code to read and 
> process the dwarf directly from the program file.it <http://file.it> 
> would be really helpful if someone can come up with either a sort of 
> algorithm or even some short programming examples for it.

Hi Gireesh --

I think developing a source browser using Dwarf is a great idea.
All of the information needed to implement one is present in the
debug information.

As Dave and Jim suggested, dwarfdump and readelf contain examples of
code to process Dwarf data.  Section 5.6.3 starting on page 73 in the
Dwarf 3.0 Specification describes how Dwarf specifies a derived class.
Like most specifications, the language is precise, but sometimes requires
a bit of close reading to understand

To understand how inheritance is described, you first need to understand
how Dwarf describes classes, which is described in Section 5.6 which
starts on page 70 of the Dwarf 3 Standards.  Since you haven't asked
about this, I'm assuming that this is reasonably clear.

A derived class description contains a DW_TAG_inheritance entry which
describes the class's inheritance.  This contains a DW_AT_type attribute
which points to the parent class from which this class was derived.  The
kind of inheritance (public, protected, or private) is described in a
DW_AT_accessibility attribute.  If a derived class is inherits from
several parent classes (multiple inheritance), there are multiple
DW_TAG_inheritance entries.

For a source browser, you probably need not be concerned with the
attributes which describe the location of data described by the class.

I would suggest that you try writing a few small pieces of C++ code
and take a look at the Dwarf which gcc generates for the classes.

Good luck.  If you have specific questions, please do send them
to the mailing list.

-- 
Michael Eager	 eager at eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077





More information about the Dwarf-discuss mailing list