[Dwarf-discuss] Question about variable location in Dwarf
Sebastian Krawczuk
syk
Wed Oct 4 20:37:39 GMT 2006
Jun,
You can almost blindly assume that this has to be (but not necessarily)
a frame pointer register. Unfortunately mapping between DWARF register
IDs and H/W registers is compiler-centric. For gcc (and some other
compilers too) Reg #5 happens to be EBP ;)
Good luck!
Sebastian.
Jun Koi wrote:
> Hello,
>
> I am having some problem interpreting Dwarf format. I am trying to get
> the address of a local variable in my C program by analyzing the Dwarf
> format. Here is my simple code:
>
> .....
> int main()
> {
> static char buffer[512];
> struct old_utsname old;
> ....
> }
>
> I use dwarfdump on the debugged binary of my code, and get the below data:
>
> ....
> <1>< 578> DW_TAG_subprogram
> DW_AT_sibling <655>
> DW_AT_external yes(1)
> DW_AT_name main
> DW_AT_decl_file 1 /home/jun/projects/olduname.c
> DW_AT_decl_line 24
> DW_AT_type <208>
> DW_AT_low_pc 0x8048433
> DW_AT_high_pc 0x804854e
> DW_AT_frame_base DW_OP_reg5
> <2>< 605> DW_TAG_variable
> DW_AT_name buffer
> DW_AT_decl_file 1 /home/bun/projects/olduname.c
> DW_AT_decl_line 25
> DW_AT_type <655>
> DW_AT_location DW_OP_addr 0x80497c0
> <2>< 625> DW_TAG_variable
> DW_AT_name old
> DW_AT_decl_file 1 /home/bun/projects/olduname.c
> DW_AT_decl_line 26
> DW_AT_type <291>
> DW_AT_location DW_OP_breg5-329
>
> ......
>
> So I understand that the (run-time) virtual address of the variable
> "buffer" is at 0x80497c0. But how can I get the virtual address of the
> variable "old"? It seems that I must get it by computing "DW_OP_breg5
> - 329"? But how can I get the value of DW_OP_breg5 in this case?
>
> I understand that DW_OP_breg5 is the value of a register, right? But
> what is that register? (ebp? I am on Intel x86)
>
> Thank you a lot,
> Jun
>
> _______________________________________________
> Dwarf-discuss mailing list
> Dwarf-discuss at lists.freestandards.org
> http://lists.freestandards.org/mailman/listinfo/dwarf-discuss
>
--
Sebastian Krawczuk
OC Systems, Inc.
Office: 703-279-2770
Cell: 703-855-2323
Email: syk at ocsystems.com
# make sense
make: 1254-002 Cannot find a rule to create target sense from dependencies.
Stop.
More information about the Dwarf-discuss
mailing list