[Dwarf-Discuss] question about variable locations from dwarf debugging information

Michael Eager eager at eagercon.com
Fri Jun 19 09:00:09 PDT 2009


Fengwei Zhang wrote:
> Dear all,
> 
> Thanks for Paul Pluzhnikov, Frank Ch. Eigler and Michael Eager's replies.
> What I am working on is to get the variable location from dwarf 
> debugging information. I am interested in locations of both global and 
> automatic variables.
> For globals, we could get their fixed addresses from the symbol table.
> Like Paul mentioned, we need both debug info and run-time info to 
> compute the automatic variables.
> 
> However, what I am trying to do is to get the memory pattern (ebp + 8 - 
> 30) from dwarf debugging info for automatic variables. In other words, I 
> don't want to run that application, but I could predict where the 
> variable will be (like ebp + 8 - 30 ).
> I guess my question is:  How can I get the "memory pattern" from dwarf 
> debugging info? How about heap allocation?

It is difficult to predict where an automatic variable might be allocated
during execution.  The location depends on where the stack is allocated
when the program is loaded and the exact call sequence.  If there are
multiple paths to the function declaring the automatic variable, there
will be many potential locations for the variable, each valid at a different
point in the program's lifetime.  In the case of a recursive function, there
may be a number of locations which contain the variable, all of which are
valid at the same instant.

In any case, the variable does not exist outside of an active invocation
of the function which creates the automatic variable.  Discussing where
a variable is located when it doesn't exist seems a philosophical issue.

DWARF provides information for locating automatic variables during a
program's execution when the variable has been instantiated.   DWARF can
also be used to locate an automatic variable from a dump image of a
program's execution, again, assuming that the variable was instantiated
at the time the image was created.

DWARF says nothing about heap allocation.


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



More information about the Dwarf-Discuss mailing list