Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* how to source level debug if I cannot see source embedded in elf file
@ 2009-11-23  0:04 loody
  2009-11-23 12:43 ` Simon Richter
  0 siblings, 1 reply; 4+ messages in thread
From: loody @ 2009-11-23  0:04 UTC (permalink / raw)
  To: gdb

Dear all:
If my tool chain cannot generate elf file without source embedded even
I compile them with "-g", can I do the source level debugging?

one of my toolchain cannot generate elf file with source embedded in,
I cannot see source code with "objdump -S testprogram.elf|less", but I
can see the function name in the file as the end of letter.

If I can do the source level debug, is there any setting or file I
have to generate?
appreciate your help,
miloody

/* source codes not embedded in the elf*/
80000298 <main>:
80000298:	27bdffd8 	addiu	sp,sp,-40
8000029c:	afbf0024 	sw	ra,36(sp)
800002a0:	afbe0020 	sw	s8,32(sp)
800002a4:	03a0f021 	move	s8,sp
800002a8:	24020017 	li	v0,23
800002ac:	afc20018 	sw	v0,24(s8)
800002b0:	24020020 	li	v0,32
800002b4:	afc20014 	sw	v0,20(s8)
800002b8:	2402002c 	li	v0,44
800002bc:	afc20010 	sw	v0,16(s8)
800002c0:	8fc30018 	lw	v1,24(s8)
800002c4:	8fc20014 	lw	v0,20(s8)
800002c8:	00621821 	addu	v1,v1,v0
800002cc:	8fc20010 	lw	v0,16(s8)
800002d0:	00621021 	addu	v0,v1,v0
800002d4:	afc20018 	sw	v0,24(s8)
800002d8:	24040100 	li	a0,256
800002dc:	0c0000d8 	jal	80000360 <malloc>
800002e0:	00000000 	nop
800002e4:	afc2001c 	sw	v0,28(s8)
800002e8:	0c00009e 	jal	80000278 <newline>
800002ec:	00000000 	nop
800002f0:	03c0e821 	move	sp,s8
800002f4:	8fbf0024 	lw	ra,36(sp)
800002f8:	8fbe0020 	lw	s8,32(sp)
800002fc:	27bd0028 	addiu	sp,sp,40


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: how to source level debug if I cannot see source embedded in  elf file
  2009-11-23  0:04 how to source level debug if I cannot see source embedded in elf file loody
@ 2009-11-23 12:43 ` Simon Richter
  2009-11-23 14:31   ` loody
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Richter @ 2009-11-23 12:43 UTC (permalink / raw)
  To: loody; +Cc: gdb

Hi,

On Mon, Nov 23, 2009 at 01:03:36AM +0800, loody wrote:

> If my tool chain cannot generate elf file without source embedded even
> I compile them with "-g", can I do the source level debugging?

That assembler dump appears to be from a fully linked file, so I'd
suspect the debug info is stripped at link time. Have you passed the -g
option to the link step as well?

   Simon


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: how to source level debug if I cannot see source embedded in elf   file
  2009-11-23 12:43 ` Simon Richter
@ 2009-11-23 14:31   ` loody
  2009-11-24 19:10     ` Dave Korn
  0 siblings, 1 reply; 4+ messages in thread
From: loody @ 2009-11-23 14:31 UTC (permalink / raw)
  To: Simon Richter; +Cc: gdb

Hi:
thanks for your reply :)
2009/11/23 Simon Richter <Simon.Richter@hogyros.de>:
> Hi,
>
> On Mon, Nov 23, 2009 at 01:03:36AM +0800, loody wrote:
>
>> If my tool chain cannot generate elf file without source embedded even
>> I compile them with "-g", can I do the source level debugging?
>
> That assembler dump appears to be from a fully linked file, so I'd
> suspect the debug info is stripped at link time. Have you passed the -g
> option to the link step as well?
first of all, I have to apologize that I have not described my
environment more detail.

I separate the compile process as first build the obj files, then link
them together. Since my program separates at different directories and
I need to build them each and finally link them together.

I am not quite understand the "passed the -g option to the link step as well".
I find the option described in ld document about "-g" below:
-g
    Ignored. Provided for compatibility with other tools.

Should I link them with "-g" as  well?
appreciate your help,
miloody

PS:
below is my compile and link commands:
/*my commands that I can see source */
mipsel-unknown-elf-gcc  -g -G 0 -mips32r2 -fno-omit-frame-pointer
-fno-optimize-sibling-calls -I./include -I./device/display
-I./device/fatfs -I./device/misc -I./device/ntstrg -I./device/ntuart
-I./device/ntxsub -I./device/vpu
-I/media/sdb1/newlib-1.17.0/build/mipsel/include -D_ASSEMBLER_  -c
init.S
mipsel-unknown-elf-gcc  -g -G 0 -mips32r2 -fno-omit-frame-pointer
-fno-optimize-sibling-calls -I./include -I./device/display
-I./device/fatfs -I./device/misc -I./device/ntstrg -I./device/ntuart
-I./device/ntxsub -I./device/vpu
-I/media/sdb1/newlib-1.17.0/build/mipsel/include -D_ASSEMBLER_  -c
reset.S
mipsel-unknown-elf-gcc  -g -G 0 -mips32r2 -fno-omit-frame-pointer
-fno-optimize-sibling-calls -I./include -I./device/display
-I./device/fatfs -I./device/misc -I./device/ntstrg -I./device/ntuart
-I./device/ntxsub -I./device/vpu
-I/media/sdb1/newlib-1.17.0/build/mipsel/include -c atexit.c
mipsel-unknown-elf-gcc  -g -G 0 -mips32r2 -fno-omit-frame-pointer
-fno-optimize-sibling-calls -I./include -I./device/display
-I./device/fatfs -I./device/misc -I./device/ntstrg -I./device/ntuart
-I./device/ntxsub -I./device/vpu
-I/media/sdb1/newlib-1.17.0/build/mipsel/include -c main.c
mipsel-unknown-elf-ld -T ./link.xn -o TestCode.elf -Map TestCode.map
--oformat elf32-littlemips  init.o reset.o atexit.o main.o -static
-nostdlib -L/media/sdb1/newlib-1.17.0/build/mipsel/lib
-L/root/bare_metal/x-tools/mipsel-unknown-elf/lib/gcc/mipsel-unknown-elf/4.2.4
 -lc -lnullmon -lgcc
rm -f TestCode.dla
rm -f TestCode.dnm


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: how to source level debug if I cannot see source embedded in  elf   file
  2009-11-23 14:31   ` loody
@ 2009-11-24 19:10     ` Dave Korn
  0 siblings, 0 replies; 4+ messages in thread
From: Dave Korn @ 2009-11-24 19:10 UTC (permalink / raw)
  To: loody; +Cc: Simon Richter, gdb

loody wrote:

> mipsel-unknown-elf-ld -T ./link.xn -o TestCode.elf -Map TestCode.map
> --oformat elf32-littlemips  init.o reset.o atexit.o main.o -static
> -nostdlib -L/media/sdb1/newlib-1.17.0/build/mipsel/lib
> -L/root/bare_metal/x-tools/mipsel-unknown-elf/lib/gcc/mipsel-unknown-elf/4.2.4
>  -lc -lnullmon -lgcc

  Is your linker script discarding the debug info sections?  Look at "objdump
-h" of TestCode.elf and of one of the .o files for comparison; if the .o files
have debug info sections but not the .elf, the problem is probably there.

    cheers,
      DaveK


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-23 14:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-23  0:04 how to source level debug if I cannot see source embedded in elf file loody
2009-11-23 12:43 ` Simon Richter
2009-11-23 14:31   ` loody
2009-11-24 19:10     ` Dave Korn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox