Subject: Re: gcc default debugging symobls
To: Jan Schaumann <jschauma@netmeister.org>
From: Nathan J. Williams <nathanw@wasabisystems.com>
List: current-users
Date: 04/05/2004 15:07:31
Jan Schaumann <jschauma@netmeister.org> writes:
> Under i386, it appears that gcc if passed '-g' generates the wrong
> debugging symbols per default:
[...]
> When compiled with '-g', running it through gdb it will correctly print
> 0.184000, but if you break and inspect x, it will give:
>
> (gdb) p x
> $1 = {c = 97 'a', d = 5.2867121265460283e-315}
> (gdb)
>
> Now using '-gstabs' or '-gstabs+' or '-gstabs3', it will behave
> correctly. So... what am I doing wrong, or why is gcc not creating the
> correct debugging symbols per default?
I can confirm that the debugging information is wrong; it describes
the 'd' field as being 8 bytes from the start of the structure, when
the generated code puts it 4 bytes from the start of the structure
(and which is correct according to the ABI).
From "readelf --debug-dump":
<1><3a8>: Abbrev Number: 10 (DW_TAG_structure_type)
DW_AT_sibling : <3cd>
DW_AT_name : (indirect string, offset: 0x153): astruct
DW_AT_byte_size : 12
DW_AT_decl_file : 1
DW_AT_decl_line : 3
<2><3b4>: Abbrev Number: 12 (DW_TAG_member)
DW_AT_name : c
DW_AT_decl_file : 1
DW_AT_decl_line : 4
DW_AT_type : <42>
DW_AT_data_member_location: 2 byte block: 23 0 (DW_OP_plus_uconst: 0)
<2><3c0>: Abbrev Number: 12 (DW_TAG_member)
DW_AT_name : d
DW_AT_decl_file : 1
DW_AT_decl_line : 5
DW_AT_type : <3cd>
DW_AT_data_member_location: 2 byte block: 23 8 (DW_OP_plus_uconst: 8)
I couldn't say *why* it's doing this, though.
- Nathan