[Dwarf-discuss] DW_AT_ranges info generated by gcc

Todd Allen todd.allen
Thu Apr 21 15:32:56 GMT 2005


> In the machine code, the two functions in your example
> are merged, and represent one machine-level ABI "function".
> Even though they represent two distinct source-level "functions".
> 
> The answer to this question for inlines might be different than the
> way we want to deal with "nested functions" that are truly
> nested in the source code, or nested block scopes in a C or C++
> program.
> 
> We could also make a simplifying decision:
> 
> When a segment of machine code represents an underlying ABI
> function, then the range of address for that function
> should span the entire function.  Inlined function bodies,
> and nested scopes may also be described with address ranges
> spanning various subsets of these instructions.
> 

Almost certainly nested functions' addresses are going to be disjoint from
the functions in which they are nested.  At least, that's the way most Ada
compilers handle it.  The nesting is taken care of with a static link or
display or something else similar.  And so it wouldn't make sense to require
the outer function to include the PC's for the nested function.  That would
just add bloat to them.  NOTE: I don't really think you were suggesting this,
Chris.  I just want to get it out of the way.

For nested lexical blocks and inlines, my best argument for having the ABI
function's low_pc/high_pc/ranges cover the entire address range of the ABI
function is that it saves space.  If you required the ABI function to
"tiptoe" around any interior inline expansions or lexical blocks, it would
force it to use DW_AT_ranges, and they would end up having more address pairs
than if you just let it cover the interior inlines or blocks.  In fact, if
you allow the ABI function to cover everything inside it, it will end up with
DW_AT_low/DW_AT_high_pc practically all of the time.  In our implemenation,
we only need to use DW_AT_ranges for inline expansions and lexical blocks,
and never need it for ABI functions.

-- 
Todd Allen
Concurrent Computer Corporation




More information about the Dwarf-discuss mailing list