* DWARF-2 debuginformation and ELF
@ 2005-07-07 15:06 Kaul, Martin
0 siblings, 0 replies; only message in thread
From: Kaul, Martin @ 2005-07-07 15:06 UTC (permalink / raw)
To: gcc-help
Hi
Im currently creating software using the arm-elf-gcc and sh-elf-gcc. For the debuggers I need debugging information in DWARF version 2 format.
Assuming the following content of main.cpp
----------------------------------------
class A
{
int local_counter_;
public:
A();
virtual ~A();
void incCounter( int value );
};
int main( void )
{
A obja;
obja.incCounter( 10 );
return 0;
}
-----------------------------------------
When I compile the Sourcemodul main.cpp via
arm-elf-g++ -mthumb-interwork -mcpu=arm7tdmi -mapcs-frame -gdwarf-2 -O0 -c main.cpp -o main.o
or for Renesas SH microcontroller via
sh-elf-g++ -gdwarf-2 -O0 -c main.cpp -o main.o
and make a dump of the debug information via "readelf --debug-dump main.o" the following output is produced:
-----------------------------------------
[...]
The section .debug_info contains:
Compilation Unit @ 0:
Length: 128
Version: 2
Abbrev Offset: 0
Pointer Size: 4
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
DW_AT_stmt_list : 0
DW_AT_high_pc : 0x100
DW_AT_low_pc : 0
DW_AT_producer : GNU C++ 4.0.0
DW_AT_language : 4 (C++)
DW_AT_name : main.cpp
DW_AT_comp_dir : /cygdrive/c/temp/gcc_problem
<1><4d>: Abbrev Number: 2 (DW_TAG_subprogram)
DW_AT_sibling : <78>
DW_AT_external : 1
DW_AT_name : main
DW_AT_decl_file : 1
DW_AT_decl_line : 12
DW_AT_type : <78>
DW_AT_low_pc : 0
DW_AT_high_pc : 0x100
DW_AT_frame_base : 1 byte block: 5b (DW_OP_reg11)
<2><68>: Abbrev Number: 3 (DW_TAG_variable)
DW_AT_name : obja <<<--- A obja; in main()
DW_AT_decl_file : 1
DW_AT_decl_line : 14
DW_AT_type : <7f> <<<--- Reference to class A
DW_AT_location : 2 byte block: 7b 50 (DW_OP_breg11: -48)
<1><78>: Abbrev Number: 4 (DW_TAG_base_type)
DW_AT_name : int
DW_AT_byte_size : 4
DW_AT_encoding : 5 (signed)
<1><7f>: Abbrev Number: 5 (DW_TAG_structure_type)
DW_AT_name : A <<<--- class A incomplete
DW_AT_declaration : 1
Dump of debug contents of section .debug_line:
Length: 56
DWARF Version: 2
[...]
-----------------------------------------
As shown above it seems that the debuginformation of class A is incomplete -> The debugger do not show any information about class A.
When I remove the virtual destruktur of class A then the debug information changes to:
-----------------------------------------
[...]
The section .debug_info contains:
Compilation Unit @ 0:
Length: 254
Version: 2
Abbrev Offset: 0
Pointer Size: 4
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
DW_AT_stmt_list : 0
DW_AT_high_pc : 0x100
DW_AT_low_pc : 0
DW_AT_producer : GNU C++ 4.0.0
DW_AT_language : 4 (C++)
DW_AT_name : main.cpp
DW_AT_comp_dir : /cygdrive/c/temp/gcc_problem
<1><4d>: Abbrev Number: 2 (DW_TAG_structure_type)
DW_AT_sibling : <cd>
DW_AT_name : A <<<---- complete class A
DW_AT_byte_size : 4
DW_AT_decl_file : 1
DW_AT_decl_line : 3
<2><57>: Abbrev Number: 3 (DW_TAG_member)
DW_AT_name : local_counter_
DW_AT_decl_file : 1
DW_AT_decl_line : 4
DW_AT_type : <cd>
DW_AT_data_member_location: 2 byte block: 23 0 (DW_OP_plus_uconst: 0)
DW_AT_accessibility: 3 (private)
<2><71>: Abbrev Number: 4 (DW_TAG_subprogram)
DW_AT_sibling : <83>
DW_AT_external : 1
DW_AT_name : A
DW_AT_decl_file : 1
DW_AT_decl_line : 6
DW_AT_declaration : 1
<3><7c>: Abbrev Number: 5 (DW_TAG_formal_parameter)
DW_AT_type : <d4>
DW_AT_artificial : 1
<2><83>: Abbrev Number: 4 (DW_TAG_subprogram)
DW_AT_sibling : <9c>
DW_AT_external : 1
DW_AT_name : ~A
DW_AT_decl_file : 1
DW_AT_decl_line : 7
DW_AT_declaration : 1
<3><8f>: Abbrev Number: 5 (DW_TAG_formal_parameter)
DW_AT_type : <d4>
DW_AT_artificial : 1
<3><95>: Abbrev Number: 5 (DW_TAG_formal_parameter)
DW_AT_type : <cd>
DW_AT_artificial : 1
<2><9c>: Abbrev Number: 6 (DW_TAG_subprogram)
DW_AT_external : 1
DW_AT_name : incCounter
DW_AT_decl_file : 1
DW_AT_decl_line : 9
DW_AT_MIPS_linkage_name: _ZN1A10incCounterEi
DW_AT_declaration : 1
<3><c0>: Abbrev Number: 5 (DW_TAG_formal_parameter)
DW_AT_type : <d4>
DW_AT_artificial : 1
<3><c6>: Abbrev Number: 7 (DW_TAG_formal_parameter)
DW_AT_type : <cd>
<1><cd>: Abbrev Number: 8 (DW_TAG_base_type)
DW_AT_name : int
DW_AT_byte_size : 4
DW_AT_encoding : 5 (signed)
<1><d4>: Abbrev Number: 9 (DW_TAG_pointer_type)
DW_AT_byte_size : 4
DW_AT_type : <4d>
<1><da>: Abbrev Number: 10 (DW_TAG_subprogram)
DW_AT_external : 1
DW_AT_name : main
DW_AT_decl_file : 1
DW_AT_decl_line : 12
DW_AT_type : <cd>
DW_AT_low_pc : 0
DW_AT_high_pc : 0x100
DW_AT_frame_base : 1 byte block: 5b (DW_OP_reg11)
<2><f1>: Abbrev Number: 11 (DW_TAG_variable)
DW_AT_name : obja <<<--- A obja; in main()
DW_AT_decl_file : 1
DW_AT_decl_line : 14
DW_AT_type : <4d> <<<--- Reference to class A
DW_AT_location : 2 byte block: 7b 54 (DW_OP_breg11: -44)
Dump of debug contents of section .debug_line:
Length: 56
DWARF Version: 2
[...]
-----------------------------------------
Then the debuginformation of class A is complete and the content of obja is displayed by the debugger.
It seems that when a methode of class A is virtual then gcc doesn't put the complete debug information of class A into the object-file.
In the above example class A is defined in an other sourcemodul. When I copy the constructor "A::A() {}" to the sourcemodul main.cpp then also with virtual methods of class A the complete debug information are put into the object-file.
Is this a known bug? Hmm, when not then I should wrote an bug report...
I tested this "effect" with the following versions of gcc:
- 3.3.2 (get it as an binary installation)
- 3.4.2 (compiled by myself)
- 4.0.0 (compiled by myself)
Thanks a lot for any comments and hints.
Best regards
Martin Kaul
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-07-07 15:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-07 15:06 DWARF-2 debuginformation and ELF Kaul, Martin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).