[Dwarf-discuss] Re: Dwarf2 Beginner's Question: Pointer variable tracking with Optimization

David Anderson davea
Tue Jun 14 10:53:12 GMT 2005


Koji Noguchi wrote:
> To show how beginner I am, 
> I tried the following simple code but couldn't figure out the 
> register for pointer 'p_int' from the DWARF2 output.

Few folks would be determined enough to understand
the byte codes.  Instead, produce a .o file and use
readelf (gnu tool) or dwarfdump (from my web site)
to display the .debug_info section readably.

Unless you are diagnosing a compiler bug it's far more sesnsible
to read the formatted output from a dumper tool.

> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> #include <stdio.h>
> #include <stdlib.h>
> 
> int main()
> {
>   int aaa,bbb;
>   int * p_int;
> 
>   aaa = 11;
>   bbb = 22;
>   p_int = &bbb;
> 
>   printf( "aaa = %d bbb = %d p_int = %p *p_int = %d\n",
>           aaa, bbb, p_int, *p_int);
>   return 0;
> }
> 
> 
>   .long .LASF46 # DW_AT_name: "p_int"
>   .byte 0x1 # DW_AT_decl_file
>   .byte 0x8 # DW_AT_decl_line
>   .long 0x2f3 # DW_AT_type
>   .byte 0x0 # end of children of DIE 0x2b4
>   .uleb128 0x5  # (DIE (0x2f3) DW_TAG_pointer_type)
>   .byte 0x4 # DW_AT_byte_size
>   .long 0x4f  # DW_AT_type
>   .byte 0x0 # end of children of DIE 0xb


Regards,
David B. Anderson davea at sgi dot com http://reality.sgiweb.org/davea




More information about the Dwarf-discuss mailing list