[Dwarf-Discuss] Array Information

ashim saikia ar.saikia@yahoo.com
Wed Mar 12 11:53:26 GMT 2008


Hi,
I am unable to get the array info using dwarf2. Should I migrate to dwarf3. I have written a simple c program containing array.
#include <stdio.h>

main()
{
        int a[20];
        int b[30];
        int i=0;
        int *p=NULL;

        for(i=0;i<20;i++) {
          a[i]=2;
          b[i]=2;
        }

        *p=30;
        for(i=0;i<20;i++)
          printf("\n a[%d]=%d",i,a[i]);
}

The following steps I have followed to get the dwarf info:

$ gcc -g -c testarray.c
$ objdump -h testarray.o

$readelf -wi testarray.o
The result is:-

he section .debug_info contains:

  Compilation Unit @ offset 0x0:
   Length:        383
   Version:       2
   Abbrev Offset: 0
   Pointer Size:  4
 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
  < c>     DW_AT_stmt_list   : 0    
  <10>     DW_AT_high_pc     : 0x8048458    
  <14>     DW_AT_low_pc      : 0x80483c4    
  <18>     DW_AT_producer    : GNU C 4.1.2 20070925 (Red Hat 4.1.2-33)    
  <40>     DW_AT_language    : 1    (ANSI C)
  <41>     DW_AT_name        : testarray.c    
  <4d>     DW_AT_comp_dir    : /usr1/ashim/cprogs    
 <1><60>: Abbrev Number: 2 (DW_TAG_base_type)
  <61>     DW_AT_name        : (indirect string, offset: 0x0): unsigned int    
  <65>     DW_AT_byte_size   : 4    
  <66>     DW_AT_encoding    : 7    (unsigned)
 <1><67>: Abbrev Number: 3 (DW_TAG_base_type)
  <68>     DW_AT_name        : unsigned char    
  <76>     DW_AT_byte_size   : 1    
  <77>     DW_AT_encoding    : 8    (unsigned char)
 <1><78>: Abbrev Number: 3 (DW_TAG_base_type)
  <79>     DW_AT_name        : short unsigned int    
  <8c>     DW_AT_byte_size   : 2    
  <8d>     DW_AT_encoding    : 7    (unsigned)
 <1><8e>: Abbrev Number: 3 (DW_TAG_base_type)
  <8f>     DW_AT_name        : long unsigned int    
  <a1>     DW_AT_byte_size   : 4    
  <a2>     DW_AT_encoding    : 7    (unsigned)
 <1><a3>: Abbrev Number: 3 (DW_TAG_base_type)
  <a4>     DW_AT_name        : signed char    
  <b0>     DW_AT_byte_size   : 1    
  <b1>     DW_AT_encoding    : 6    (signed char)
 <1><b2>: Abbrev Number: 3 (DW_TAG_base_type)
  <b3>     DW_AT_name        : short int    
  <bd>     DW_AT_byte_size   : 2    
  <be>     DW_AT_encoding    : 5    (signed)
 <1><bf>: Abbrev Number: 3 (DW_TAG_base_type)
  <c0>     DW_AT_name        : int    
  <c4>     DW_AT_byte_size   : 4    
  <c5>     DW_AT_encoding    : 5    (signed)
 <1><c6>: Abbrev Number: 3 (DW_TAG_base_type)
  <c7>     DW_AT_name        : long long int    
  <d5>     DW_AT_byte_size   : 8    
  <d6>     DW_AT_encoding    : 5    (signed)
 <1><d7>: Abbrev Number: 3 (DW_TAG_base_type)
  <d8>     DW_AT_name        : long long unsigned int    
  <ef>     DW_AT_byte_size   : 8    
  <f0>     DW_AT_encoding    : 7    (unsigned)
 <1><f1>: Abbrev Number: 3 (DW_TAG_base_type)
  <f2>     DW_AT_name        : long int    
  <fb>     DW_AT_byte_size   : 4    
  <fc>     DW_AT_encoding    : 5    (signed)
 <1><fd>: Abbrev Number: 2 (DW_TAG_base_type)
  <fe>     DW_AT_name        : (indirect string, offset: 0x0): unsigned int    
  <102>     DW_AT_byte_size   : 4    
  <103>     DW_AT_encoding    : 7    (unsigned)
 <1><104>: Abbrev Number: 3 (DW_TAG_base_type)
  <105>     DW_AT_name        : char    
  <10a>     DW_AT_byte_size   : 1    
  <10b>     DW_AT_encoding    : 6    (signed char)
 <1><10c>: Abbrev Number: 4 (DW_TAG_subprogram)
  <10d>     DW_AT_sibling     : <15c>    
  <111>     DW_AT_external    : 1    
  <112>     DW_AT_name        : main    
  <117>     DW_AT_decl_file   : 1    
  <118>     DW_AT_decl_line   : 4    
  <119>     DW_AT_type        : <bf>    
  <11d>     DW_AT_low_pc      : 0x80483c4    
  <121>     DW_AT_high_pc     : 0x8048458    
  <125>     DW_AT_frame_base  : 0    (location list)
 <2><129>: Abbrev Number: 5 (DW_TAG_variable)
  <12a>     DW_AT_name        : a    
  <12c>     DW_AT_decl_file   : 1    
  <12d>     DW_AT_decl_line   : 5    
  <12e>     DW_AT_type        : <15c>    
  <132>     DW_AT_location    : 3 byte block: 91 9c 7f     (DW_OP_fbreg: -100)
 <2><136>: Abbrev Number: 5 (DW_TAG_variable)
  <137>     DW_AT_name        : b    
  <139>     DW_AT_decl_file   : 1    
  <13a>     DW_AT_decl_line   : 6    
  <13b>     DW_AT_type        : <16c>    
  <13f>     DW_AT_location    : 3 byte block: 91 a4 7e     (DW_OP_fbreg: -220)
 <2><143>: Abbrev Number: 5 (DW_TAG_variable)
  <144>     DW_AT_name        : i    
  <146>     DW_AT_decl_file   : 1    
  <147>     DW_AT_decl_line   : 7    
  <148>     DW_AT_type        : <bf>    
  <14c>     DW_AT_location    : 2 byte block: 91 6c     (DW_OP_fbreg: -20)
 <2><14f>: Abbrev Number: 5 (DW_TAG_variable)
  <150>     DW_AT_name        : p    
  <152>     DW_AT_decl_file   : 1    
  <153>     DW_AT_decl_line   : 8    
  <154>     DW_AT_type        : <17c>    
  <158>     DW_AT_location    : 2 byte block: 91 70     (DW_OP_fbreg: -16)
 <1><15c>: Abbrev Number: 6 (DW_TAG_array_type)
  <15d>     DW_AT_sibling     : <16c>    
  <161>     DW_AT_type        : <bf>    
 <2><165>: Abbrev Number: 7 (DW_TAG_subrange_type)
  <166>     DW_AT_type        : <fd>    
  <16a>     DW_AT_upper_bound : 19    
 <1><16c>: Abbrev Number: 6 (DW_TAG_array_type)
  <16d>     DW_AT_sibling     : <17c>    
  <171>     DW_AT_type        : <bf>    
 <2><175>: Abbrev Number: 7 (DW_TAG_subrange_type)
  <176>     DW_AT_type        : <fd>    
  <17a>     DW_AT_upper_bound : 29    
 <1><17c>: Abbrev Number: 8 (DW_TAG_pointer_type)
  <17d>     DW_AT_byte_size   : 4    
  <17e>     DW_AT_type        : <bf>    

Here at DW_TAG_array type I am not getting the DW_AT_name (i.e. the name of the array) without which I cannot establish the relation between the array, its type and the number of elements.

So will dwarf3 solves this problem. I am attaching the result of redelf as a text file also, as in case this above info is not that clear.

I will be blessed if anybody can help me out with any suggestion....


Regards
Ars






      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dwarfstd.org/private.cgi/dwarf-discuss-dwarfstd.org/attachments/20080312/dfd03051/attachment.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: readout.txt
URL: <http://lists.dwarfstd.org/private.cgi/dwarf-discuss-dwarfstd.org/attachments/20080312/dfd03051/attachment.txt>



More information about the Dwarf-discuss mailing list