[Dwarf-Discuss] Array Information

ashim saikia ar.saikia@yahoo.com
Wed Mar 12 12:31:42 GMT 2008


No, actually It is showing the array name as a variable and all the array information in another DW_AT (attribute). So going through the information how can I conclude that array "a" information is the information specified in the DW_TAG_array_type DIE. Actually how can I correlate this info....

Suppose in a large program I have 10 nos of array... the array var is shown differently and its information differently

thats what my question is

----- Original Message ----
From: Daniel Berlin <dberlin@dberlin.org>
To: ashim saikia <ar.saikia at yahoo.com>
Cc: dwarf-discuss at lists.dwarfstd.org
Sent: Wednesday, March 12, 2008 5:48:37 PM
Subject: Re: [Dwarf-Discuss] Array Information

On Wed, Mar 12, 2008 at 6:53 AM, ashim saikia <ar.saikia at yahoo.com> wrote:
>
> 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
>  <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)
>  <1><15c>: Abbrev Number: 6 (DW_TAG_array_type)
>   <15d>     DW_AT_sibling     : <16c>
>   <161>     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.
????


1.  You are getting the name, because the variable has the name, not the type.
2. The type of the array is clearly marked.
3. The number of elements is clearly marked by the subrange type child
of the array type, as allowed by the standard ("Subrange
type entries may also be used to represent the bounds of array dimensions.")

I'm not sure what you think you are missing.
You seem to be confused about the difference between the name of a
type and a name of the variable.






      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dwarfstd.org/private.cgi/dwarf-discuss-dwarfstd.org/attachments/20080312/31747e40/attachment.htm>



More information about the Dwarf-discuss mailing list