Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

why my cross-compiler gcc doesn't produce any .debug*** section?

9 views
Skip to first unread message

Peter

unread,
Feb 26, 2012, 3:54:12 AM2/26/12
to mche...@hotmail.com
Hi all
why my cross-compiler gcc doesn't produce any .debug*** section?
thanks
from Peter (cmk...@hotmail.com)


/Users/peter>i586-peter-elf-gcc -c -g a.c
/Users/peter>i586-peter-elf-objdump a.o -h

a.o: file format elf32-i386

Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000028 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 0000005c 2**2
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 0000005c 2**2
ALLOC
3 .stab 000001a4 00000000 00000000 0000005c 2**2
CONTENTS, RELOC, READONLY, DEBUGGING
4 .stabstr 000002b5 00000000 00000000 00000200 2**0
CONTENTS, READONLY, DEBUGGING
5 .comment 00000012 00000000 00000000 000004b5 2**0
CONTENTS, READONLY
6 .eh_frame 00000038 00000000 00000000 000004c8 2**2
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
/Users/peter>

Peter Cheung

unread,
Feb 26, 2012, 4:01:51 AM2/26/12
to
although it doesn't have .debug_loc, but i can dump the source form
the output file, so where does the debug line info store?

/Users/peter>i586-peter-elf-objdump -S a.o

a.o: file format elf32-i386


Disassembly of section .text:

00000000 <main>:
int main(){
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 ec 10 sub $0x10,%esp
int x=0;
6: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
for (x=0;x<10;x++){
d: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
14: eb 07 jmp 1d <main+0x1d>
x+=2;
16: 83 45 fc 02 addl $0x2,-0x4(%ebp)
int main(){
int x=0;
for (x=0;x<10;x++){
1a: ff 45 fc incl -0x4(%ebp)
1d: 83 7d fc 09 cmpl $0x9,-0x4(%ebp)
21: 7e f3 jle 16 <main+0x16>
x+=2;
}
return x;
23: 8b 45 fc mov -0x4(%ebp),%eax
}
26: c9 leave
27: c3 ret
/Users/peter>

Marven Lee

unread,
Feb 26, 2012, 4:49:36 AM2/26/12
to

Peter wrote:
> Hi all
> why my cross-compiler gcc doesn't produce any .debug*** section?
>
> /Users/peter>i586-peter-elf-gcc -c -g a.c
> /Users/peter>i586-peter-elf-objdump a.o -h

I've never used the GDB debugger or used the debug sections in
an executable but maybe your i386-elf cross compiler isn't creating
them in the right format?

Looking through the patch I made for my i386-kielder-elf there is
the following lines in the config header:

+++ gcc-4.1.1_new/gcc/config/i386/kielder.h

+/* Use stabs instead of DWARF debug format. */
+#undef PREFERRED_DEBUGGING_TYPE
+#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG

I don't know the difference between stabs and DWARF. Perhaps
stabs doesn't create the .debug_*** sections.

Perhaps you can either alter the preferred debugging type in your
version of the header or maybe GCC has a command line option
to produce DWARF debugging output.


--
Marv


Doug McIntyre

unread,
Feb 26, 2012, 9:46:57 AM2/26/12
to
Peter <mche...@gmail.com> writes:
> why my cross-compiler gcc doesn't produce any .debug*** section?
>thanks
>from Peter (cmk...@hotmail.com)

>/Users/peter>i586-peter-elf-gcc -c -g a.c
>/Users/peter>i586-peter-elf-objdump a.o -h

This platform uses .stab for debugging info.

> 3 .stab 000001a4 00000000 00000000 0000005c 2**2
> CONTENTS, RELOC, READONLY, DEBUGGING
> 4 .stabstr 000002b5 00000000 00000000 00000200 2**0
> CONTENTS, READONLY, DEBUGGING

So, there's your .debug sections..

Andrew Haley

unread,
Feb 26, 2012, 12:07:54 PM2/26/12
to
In gnu.gcc.help Peter <mche...@gmail.com> wrote:

> why my cross-compiler gcc doesn't produce any .debug*** section?

Debug info in the STABS format is in the .stab section.

Andrew.

Peter Cheung

unread,
Feb 26, 2012, 1:02:28 PM2/26/12
to
thanks
how to force gcc to generate dwarf rather then stab?

Peter Cheung

unread,
Feb 26, 2012, 1:11:58 PM2/26/12
to
On Feb 27, 2:02 am, Peter Cheung <mcheun...@gmail.com> wrote:
> thanks
> how to force gcc to generate dwarf rather then stab?

-ggdb can produce dwarf2, but why gcc default is stab? how to
configure it to use dwarf2 format as default?

Andrew Haley

unread,
Feb 27, 2012, 4:12:00 AM2/27/12
to
In gnu.gcc.help Peter Cheung <mche...@gmail.com> wrote:
That depends on how you configured GCC. GCC usually defaults to
whatever is standard on the target you're configuring for. We don't
know what that is.

Andrew.
0 new messages