[Dwarf-discuss] "null entry"

Cary Coutant cary
Mon May 23 16:44:26 PDT 2005


> I'll agree with the poster who said it was a pain to
> have zero not work as a null sibling pointer.  But there's
> a work-around:
>
> Since the value of SW_AT_sibling is a reference, and a
> reference is an offset from a .debug_info section (this one
> or a remote one), zero would normally mean "the first DIE".
> So producers could issue a null DIE as the very first DIE,
> and then zero works!  (or have I misunderstood something?)

It has to point to exactly the right null entry (i.e., the one that 
actually follows the last sibling and all of its children). Since not 
every DIE necessarily has a sibling attribute, the DWARF reader could 
follow the sibling attribute of one DIE to skip over its children, then 
find itself at the end of the chain. The reader will then go up a level 
and continue reading siblings at that level from that point. If you've 
pointed to a null at the wrong place, the reader may continue reading 
from the wrong place.

> Won't a DIE offset of zero give you the compilation unit header?

Yes. The first DIE is typically at offset 11, 12, 13, or so. Setting 
sibling = 0 results in gdb reading the compilation unit header as a DIE 
(with predictably ugly results).

-cary




More information about the Dwarf-Discuss mailing list