This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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: [patch] Fix C `extern' shadowing in a local block


Hi Jan,

> 2009-03-26  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* dwarf2read.c
> 	(new_symbol <DW_TAG_variable> <!DW_AT_location> <DW_AT_external>):
> 	Create the symbol in local scope.

This part makes me uncomfortable. I am afraid that doing so would be
misinterpreting the meaning of DW_AT_external. Also, I would mean
that we are treating this attribute differently depending on whether
we have a location attribute or not. This may be the correct thing
to do, but I want to make sure that the debugging information generated
in this case is correct.

We have to consider for instance the following example:

    extern int toto;
    
    int
    main (void)
    {
      toto++;
      return 0;
    }

The debugging information generated for our extern looks like this:

        .uleb128 0x4    # (DIE (0x55) DW_TAG_variable)
        .long   .LASF4  # DW_AT_name: "toto"
        .byte   0x1     # DW_AT_decl_file (foo.c)
        .byte   0x1     # DW_AT_decl_line
        .long   0x4e    # DW_AT_type
        .byte   0x1     # DW_AT_external
        .byte   0x1     # DW_AT_declaration
        .byte   0x0     # end of children of DIE 0xb

The description for the global variable looks completely identical
to your example where the variable is bound to a local scope.

Now, in practice, I think that things would work in both cases.
In my example, with your patch, the variable would be inserted
at the file_symbols level instead of inside the local scope associated
to your block.

I would like to have Daniel's opinion on this. I'll see if he's on IRC.

-- 
Joel


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