[Dwarf-Discuss] Lexical block address ranges when nesting
ron.brender at charter.net
Sat Nov 8 11:27:42 PST 2008
The computer science concept of a lexical block is inherently inclusive
of any blocks nested within (so-called inner blocks). As a consequence,
it never occurred to this complier implementor and the debugger
implementors he has worked with over the years to exclude the inner
blocks when generating the debug info for a block.
In a non-optimized compilation, it will normally be the case the every
lexical block (including every function body) can be described by as a
single contiguous range of instructions (using DW_AT_low_PC and
_high_PC) if blocks are considered inclusive of inner blocks. If inner
blocks are excluded, then any block containing a inner block becomes
discontiguous (usually) and would require the more complicated
DW_AT_range attribute to describe.
I don't recall anywhere else in the document where the concept of block
is explicitly defined. But I also find it hard to read Section 3.4 in a
way that allows either inclusive or exclusive interpretations.
I see no advantage for DWARF as a specification to be ambivalent about
whether blocks are inclusive or exclusive. But if that were the intent,
the I would argue that DWARF really needs another attribute that
specifies which interpretation is being used by a particular version of
a particular producer on a particular architecture (this week).
Otherwise, debugger implementations become less portable and must build
in additional knowledge about "known producers". (Yes, there is some of
this already but I see no value in it in this connection.)
Martin Day wrote:
> Section 3.4 of the dwarf3 spec says :
> "The lexical block entry may have either a DW_AT_low_pc and DW_AT_high_pc
> pair of attributes or a DW_AT_ranges attribute whose values encode the
> contiguous or non-contiguous address ranges, respectively, of the machine
> instructions generated for the lexical block (see Section 2.17)."
> We're compiling C/C++ using DW_AT_ranges. Should the ranges specified for a
> lexical block include the ranges of all nested (child) lexical blocks or
> should it only be the address ranges of instructions generated for that
> lexical block as the quote above seems to imply or is it undefined and
> implementation dependant?
> Compiler writers say it's easier for them to just list the ranges for
> instructions in the block excluding those in nested blocks. Debugger writers
> would prefer the ranges of a parent block to include all the ranges of child
> blocks so that a tree search is easier.
> Is this explicitly defined somewhere in the standard or should the debugger
> be able to cope with either method?
More information about the Dwarf-Discuss