[Dwarf-Discuss] the list of 'local' variables

Mathieu Lacage mathieu.lacage@gmail.com
Sat Jul 17 09:23:40 GMT 2010


I am trying to figure out how I can, from a pc address, find the list
of local variables which the pc address is able to access from its
source language. I see that the 'Call Frame Information' appears to be
just what I need but I fail to see how:
  - I can get the list of local variables available _at this address_
  - I can get from a local variable name a location expression valid
_at this address_ which indicates either how to calculate the value of
the variable or how to calculate its address

The other option might be to parse the .debug_info section and
identify the DW_TAG_variable and DW_TAG_lexical_block entities under
the current function (which I guess I can find quickly from the
aranges section) but I am worried that the location information I get
from the lexical_block are not valid everywhere in the block depending
on various compiler optimizations because I see no way to make that
location information be pc-dependent.

The next step for me is digging in the gdb source tree to figure out
how it implements this but maybe someone who knows better can save me
a lot of time by giving me a rough outline of how this is expected to
be done.

Mathieu Lacage <mathieu.lacage at gmail.com>

More information about the Dwarf-discuss mailing list