[cfe-dev] Fwd: clang may generate incorrect dwarf info?

Eric Christopher echristo at gmail.com
Wed Apr 3 08:17:49 PDT 2013


What's the actual definition look like?

ghostwheel:~/tmp> cat foo.c
void _sx_xunlock(struct sx *sx, const char *file, int line) {}

0x00000026:     TAG_subprogram [2] *
                 AT_name( "_sx_xunlock" )
                 AT_decl_file( "/Users/echristo/tmp/foo.c" )
                 AT_decl_line( 1 )
                 AT_prototyped( 0x01 )
                 AT_external( 0x01 )
                 AT_low_pc( 0x0000000000000000 )
                 AT_high_pc( 0x0000000000000011 )
                 AT_frame_base( rbp )

0x00000041:         TAG_formal_parameter [3]
                     AT_name( "sx" )
                     AT_decl_file( "/Users/echristo/tmp/foo.c" )
                     AT_decl_line( 1 )
                     AT_type( {0x00000072} ( sx* ) )
                     AT_location( fbreg -8 )

0x0000004f:         TAG_formal_parameter [3]
                     AT_name( "file" )
                     AT_decl_file( "/Users/echristo/tmp/foo.c" )
                     AT_decl_line( 1 )
                     AT_type( {0x00000083} ( const char* ) )
                     AT_location( fbreg -16 )

0x0000005d:         TAG_formal_parameter [3]
                     AT_name( "line" )
                     AT_decl_file( "/Users/echristo/tmp/foo.c" )
                     AT_decl_line( 1 )
                     AT_type( {0x00000088} ( int ) )
                     AT_location( fbreg -20 )

0x0000006b:         NULL

with current clang.

-eric

On Wed, Apr 3, 2013 at 6:49 AM, Andriy Gapon <avg at freebsd.org> wrote:
>
> -------- Original Message --------
>
>
> Function signature in FreeBSD source code:
> void _sx_xunlock(struct sx *sx, const char *file, int line);
>
> DWARF (reported by objdump -x -w -W) when compiled with gcc:
>  <1><8337>: Abbrev Number: 63 (DW_TAG_subprogram)
>   <8338>     DW_AT_external    : 1
>   <8339>     DW_AT_name        : (indirect string, offset: 0x48c9): _sx_xunlock
>   <833d>     DW_AT_decl_file   : 1
>   <833e>     DW_AT_decl_line   : 373
>   <8340>     DW_AT_prototyped  : 1
>   <8341>     DW_AT_low_pc      : 0x13a7
>   <8349>     DW_AT_high_pc     : 0x143e
>   <8351>     DW_AT_frame_base  : 0x3cd3 (location list)
>   <8355>     DW_AT_sibling     : <84a4>
>  <2><8359>: Abbrev Number: 59 (DW_TAG_formal_parameter)
>   <835a>     DW_AT_name        : sx
>   <835d>     DW_AT_decl_file   : 1
>   <835e>     DW_AT_decl_line   : 372
>   <8360>     DW_AT_type        : <2cac>
>   <8364>     DW_AT_location    : 0x3d1f (location list)
>  <2><8368>: Abbrev Number: 60 (DW_TAG_formal_parameter)
>   <8369>     DW_AT_name        : (indirect string, offset: 0x9016): file
>   <836d>     DW_AT_decl_file   : 1
>   <836e>     DW_AT_decl_line   : 372
>   <8370>     DW_AT_type        : <1ea>
>   <8374>     DW_AT_location    : 0x3d8e (location list)
>  <2><8378>: Abbrev Number: 60 (DW_TAG_formal_parameter)
>   <8379>     DW_AT_name        : (indirect string, offset: 0x12a): line
>   <837d>     DW_AT_decl_file   : 1
>   <837e>     DW_AT_decl_line   : 372
>   <8380>     DW_AT_type        : <5f>
>   <8384>     DW_AT_location    : 0x3dd7 (location list)
>
> Ditto when compiled with clang:
>  <1><2c70>: Abbrev Number: 55 (DW_TAG_subprogram)
>   <2c71>     DW_AT_name        : (indirect string, offset: 0x1817): _sx_xunlock
>   <2c75>     DW_AT_decl_file   : 1
>   <2c76>     DW_AT_decl_line   : 373
>   <2c78>     DW_AT_prototyped  : 1
>   <2c78>     DW_AT_external    : 1
>   <2c78>     DW_AT_inline      : 1      (inlined)
>  <2><2c79>: Abbrev Number: 51 (DW_TAG_formal_parameter)
>   <2c7a>     DW_AT_name        : (indirect string, offset: 0xd061): line
>   <2c7e>     DW_AT_decl_file   : 1
>   <2c7f>     DW_AT_decl_line   : 373
>   <2c81>     DW_AT_type        : <a2>
>  <2><2c85>: Abbrev Number: 51 (DW_TAG_formal_parameter)
>   <2c86>     DW_AT_name        : (indirect string, offset: 0xd056): sx
>   <2c8a>     DW_AT_decl_file   : 1
>   <2c8b>     DW_AT_decl_line   : 373
>   <2c8d>     DW_AT_type        : <782c>
>  <2><2c91>: Abbrev Number: 51 (DW_TAG_formal_parameter)
>   <2c92>     DW_AT_name        : (indirect string, offset: 0xc67): file
>   <2c96>     DW_AT_decl_file   : 1
>   <2c97>     DW_AT_decl_line   : 373
>   <2c99>     DW_AT_type        : <32>
>
> First, looks like the parameters come in a wrong order.
>
> [snip]
>
> --
> Andriy Gapon
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list