This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: dwarf2 - multiple DW_TAG_variable for global variable


This dwarf code started appearing since this patch:

------------------------------------------------------------------------
r145293 | jakub | 2009-03-30 14:35:03 +0000 (Mon, 30 Mar 2009) | 11 lines

        PR debug/39563
        * c-decl.c (struct c_binding): Add locus field.
        (bind): Add locus argument, set locus field from it.
        (pop_scope): For b->nested VAR_DECL or FUNCTION_DECL,
        add a DECL_EXTERNAL copy of b->decl to current BLOCK_VARS.
        (push_file_scope, pushtag, pushdecl, pushdecl_top_level,
        implicitly_declare, undeclared_variable, lookup_label,
        declare_label, c_make_fname_decl, c_builtin_function,
        c_builtin_function_ext_scope, store_parm_decls_newstyle): Adjust
        bind callers.

Jan, can you confirm that this is indeed the correct DWARF that is being generated.

Thank you,
Nenad



On 1/4/10 11:34 PM, Nenad Vukicevic wrote:
I installed gcc-4.5-20091224 snapshot and noticed that for simple variable declaration
I get two DW_TAG_variable dies in the object file. For example, the following
code


int xxxxx;
main()
{xxxxx=1;}

generates (with -g -gdwarf2 -O0 switches):

<1><54>: Abbrev Number: 4 (DW_TAG_variable)
<55> DW_AT_name : (indirect string, offset: 0x36): xxxxx
<59> DW_AT_decl_file : 1
<5a> DW_AT_decl_line : 1
<5b> DW_AT_type : <0x4d>
<5f> DW_AT_external : 1
<60> DW_AT_declaration : 1
<1><61>: Abbrev Number: 5 (DW_TAG_variable)
<62> DW_AT_name : (indirect string, offset: 0x36): xxxxx
<66> DW_AT_decl_file : 1
<67> DW_AT_decl_line : 1
<68> DW_AT_type : <0x4d>
<6c> DW_AT_external : 1
<6d> DW_AT_location : 9 byte block: 3 0 0 0 0 0 0 0 0 (DW_OP_addr: 0)


Is the above normal? 4.3.2 compiler generates only one die, the second one with
DW_AT_location attribute, which is correct.


I also noticed that this example (were variable is not used):

int xxxxx;
main()
{}

generates only one DW_TAG_variable, the one with DW_AT_location, which again
should be correct.


I ran into this problem by porting some GDB code that uses DWARF2 and got surprised
to see this change from the previous version of gcc (4.3).


Thanks,
Nenad



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]