[Dwarf-Discuss] find local variable information from the dwarf

David Anderson davea42@earthlink.net
Mon Jan 21 19:20:56 GMT 2008


Neeraj kushwaha wrote:
> Hi All,
>
> I am trying to find the location and value of local variable in a stack
> frame from the core dump.
> As GDB can fetch the value and location of local variable using the
> information from the dwarf debugging format.
>
> I am trying to manually find the location and value of the local variable
> from the core.
>
> This is what i did; from the a.out, I extracted the dwarf information using
> "dwarfdump -a a.out"
>
> and using the GDB i am trying to print the dump from the core "x/88b main1"
>
> But I am not able to find the location information of the local variable
>
> for example:
>
>         DW_AT_name                  c
>         DW_AT_decl_file             1 /home/neeraj/4.c
>         DW_AT_decl_line             15
>         DW_AT_type                  <177>
>         DW_AT_location              DW_OP_fbreg -20
>
>
> local variable is at location DW_OP_fbreg - 20. But how to find the
> DW_OP_fbreg?
>
>   

Look back a few lines.  The fbreg is defined in the subprogram
DIE (DW_AT_frame_base):

> <1><  315>    DW_TAG_subprogram
>         DW_AT_external              yes(1)
>         DW_AT_name                  main
>         DW_AT_decl_file             1 /home/neeraj/4.c
>         DW_AT_decl_line             14
>         DW_AT_type                  <177>
>         DW_AT_low_pc                0x8048398
>         DW_AT_high_pc               0x80483ca
>         DW_AT_frame_base            [
> 0]<lowpc=0x24><highpc=0x28>DW_OP_breg4+4
>                     [ 1]<lowpc=0x28><highpc=0x2e>DW_OP_reg1
>                     [ 2]<lowpc=0x2e><highpc=0x2f>DW_OP_breg4+4
>                     [ 3]<lowpc=0x2f><highpc=0x31>DW_OP_breg4+8
>                     [ 4]<lowpc=0x31><highpc=0x56>DW_OP_breg5+8
>   

Hope that helps.
David Anderson.




More information about the Dwarf-discuss mailing list