This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch] Fix C `extern' shadowing in a local block
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 2 Apr 2009 11:54:13 -0700
- Subject: Re: [patch] Fix C `extern' shadowing in a local block
- References: <20090326212128.GA32657@host0.dyn.jankratochvil.net>
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