From: "Kaul, Martin" <martin.kaul@leuze.de>
To: <gcc-help@gcc.gnu.org>
Subject: DWARF-2 debuginformation and ELF
Date: Thu, 07 Jul 2005 15:06:00 -0000 [thread overview]
Message-ID: <AB648B716159384883FDB00709F1884D1D6A27@leoex1> (raw)
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
reply other threads:[~2005-07-07 15:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AB648B716159384883FDB00709F1884D1D6A27@leoex1 \
--to=martin.kaul@leuze.de \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).