[Dwarf-Discuss] How do we get the value of type attribute from dwarf info programatically

ashim saikia ar.saikia@yahoo.com
Tue Apr 8 12:38:04 GMT 2008


Hi,
I want to print all the information for all the local variables defined in my program from the dwarf. Ofcourse, local variables will be of type int, char ,pointers, arrays, structures, union,ennumerated and so on...

Now suppose I have dwarf information for array as follows:-

 <2><1a1>: Abbrev Number: 11 (DW_TAG_variable)
  <1a2>     DW_AT_name        : ary
  <1a6>     DW_AT_decl_file   : 1
  <1a7>     DW_AT_decl_line   : 18
  <1a8>     DW_AT_type        : <1e2>
  <1ac>     DW_AT_location    : 3 byte block: 91 98 7f  (DW_OP_fbreg: -104)

 <1><1e2>: Abbrev Number: 7 (DW_TAG_array_type)
  <1e3>     DW_AT_sibling     : <1f2>
  <1e7>     DW_AT_type        : <bb>

 <2><1eb>: Abbrev Number: 8 (DW_TAG_subrange_type)
  <1ec>     DW_AT_type        : <f9>
  <1f0>     DW_AT_upper_bound : 19.

Now I can conclude the following from the above given dwarf info:-
1. ary is a variable of type <1e2> and at location -104 off the frame base register.
2. Type <1e2> is an array with an element type of <bb>
3. Has one dimension with the implied lower bound of 0 and the declared upper bound of 19.

Now, I am trying to write a program that will give me these information into a file .Everything goes fine until I encounter the DW_AT_type attribute. DW_AT_type attribute gives me the value <1e2>, and I get the die <1e2>.
Again I have to read the die <1e2>. I do so,... again I get a DW_AT_type attribute again a die <bb>(... doing recursion). Now bb gives me the base type... (ok fine). Now what about the DW_TAG_subrange type, the DW_AT_upper_bound is of my interest. Because I m doing recursion, I end up with the die given by <bb>. Now If I check out this die, for "having a child die", obviously it doesnot have one. But the die <1e2> which defines array type has a child,... How do I keep track of that?
This becomes very tedious when I encounter structure or union types.....

I will be oblidged if anybody can help me out......

Thanks & Regards
Ashim







      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dwarfstd.org/private.cgi/dwarf-discuss-dwarfstd.org/attachments/20080408/88002cd6/attachment.htm>



More information about the Dwarf-discuss mailing list