[Dwarf-Discuss] DW_AT_specification chains

Michael Eager eager@eagercon.com
Wed Apr 23 19:27:02 GMT 2008

Marcel Mettes wrote:
> Hello,
> I was wondering what the semantics are of a series of DW_AT_specifications
> that are supposed to form some kind of chain?
> For example
>     X1 TAG_variable
>     X2     DW_AT_name = "x"
>     Y1 TAG_variable
>     Y2     DW_AT_specification = X1
>     Y3     DW_AT_external = 1
>     Y4     DW_AT_type = ...
>     Z1 TAG_variable
>     Z2     DW_AT_specification = Y1
>     Z3     DW_AT_location = ...
> Would this be valid or should the DW_AT_specification at offset Z2
> point directly to X1?

Here's what the DWARF Spec says:

    2.13.2 Declarations Completing Non-Defining Declarations

    Debugging information entries that represent a declaration that completes
    another (earlier) non-defining declaration, may have a DW_AT_specification
    attribute whose value is a reference to the debugging information entry
    representing the non-defining declaration. Debugging information entries
    with a DW_AT_specification attribute do not need to duplicate information
    provided by the debugging information entry referenced by that specification

I take this to mean that you can have the following in your program:

    struct foo;

    struct foo { int x; };

Where the second (defining) declaration has an AT_specification which
points back to the first (non-defining) declaration.

There are other more complex examples for languages like C++.

Given the very limited detail in your example, the answer to your
question about whether this is valid is "it depends".  It would help
to have the source code which this is supposed to describe, as well
as other information which would put it in context, say, whether
this was a single compilation, or where the source appears in
the program (e.g., within or outside of a function).

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

More information about the Dwarf-discuss mailing list