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

Fengwei Zhang fz2135@columbia.edu
Fri Jun 19 04:15:20 GMT 2009


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?

I am working on a hosted environment and running an application, and  
I cannot change the source code.
Actually, my project is about fixing race condition for multi- 
threading program. The back-end is done. What I am working is to  
write the front-end, which is let the user to specify where to fix.

I do appreciate your help!

Regards,
Fengwei Zhang

On Jun 18, 2009, at 2:19 PM, Michael Eager wrote:

> Fengwei Zhang wrote:
>> Dear all,
>> I am working on a project which needs to get the variable location  
>> from executable application. I could use readelf and dwarfdump to  
>> output the text debugging information, including the variable  
>> locations. However, the debugging information is very complex. For  
>> example, variable location will be "DW_OP_fbreg: -32". It means  
>> some offset from stack base frame. In other words, I need to  
>> compute where the variable is based on the debugging information.
>> I am wondering: Is there any other tool which help me get the  
>> memory address of variables? Like "print variable_name" command in  
>> gdb, then I could get 0xff73d305.
>
> It's not clear what you are trying to do.
>
> What is your environment?  Is it a hosted environment like Linux
> or an embedded environment without memory protection?
>
> What do you want to do once you have the address of the variable?
>
> Do you want to find the variable address in an executable file or
> while you are executing the application?
>
> Assuming you are working in a hosted environment and running an
> application, if you want to look at the variable from a different
> process, you need more than just the address of the variable, you
> need a way to access the memory space for the application using  
> ptrace.
> That amounts to implementing a debugger like gdb.  This is somewhat
> easier to do in an embedded environment.
>
> Are you looking for a specific variable rather than wanting to look
> at an arbitrary variable?  Can you modify the program?
>
> If so, the simplest way may be to just use printf to print the address
> of the variable
>
>
> -- 
> Michael Eager	 eager at eagercon.com
> 1960 Park Blvd., Palo Alto, CA 94306  650-325-8077
>





More information about the Dwarf-discuss mailing list