From: Scott Lurndal on
cerr <ron.eggler(a)gmail.com> writes:
>On Mar 18, 11:10=A0am, Ben Bacarisse <ben.use...(a)bsb.me.uk> wrote:
>> cerr <ron.egg...(a)gmail.com> writes:
>> > I have a question. I'm running into a segfault but on bt i do not get
>> > source code but only useless addresses.
>> > I've done the following:
>> > - loaded my binary with symbol-file
>> > - compiled binary with following flags: -g3 -O0 -g
>>
>> The mixture of -g3 and -g seems odd. =A0At best I'd imagine that the
>> latter -g is the one that governs the compile and -g is -g2 by
>> default.
>>
>> > - executed gdb from the source directory
>> > - set dir to "./"
>>
>> > Why am I still not seeing the source code? :o
>>
>> Is the fault in a part of the code for which there are no symbols?
>> E.g. in a library that you did not compile with -g.
>
>I would not think so...
>>
>> > Thanks for a little help here!
>>
>> Posting some/all of the output might give a vital clue.
>
>The output looks like this:
>Program received signal SIGSEGV, Segmentation fault.
>0xb7f009b3 in ?? ()
>(gdb) bt
>#0 0xb7f009b3 in ?? ()
>#1 0xbf9c43e4 in ?? ()
>#2 0xbf9c4384 in ?? ()
>#3 0xbf9c4328 in ?? ()
>#4 0xb7f1bff4 in ?? ()
>#5 0x4ba2695f in ?? ()
>#6 0xb7f1bff4 in ?? ()
>#7 0xbf9c43e4 in ?? ()
>#8 0x00000000 in ?? ()
>(gdb)

You neglected to specify which operating system and which version
of the gnu toolchain you are using.

However, this appears as if the executable was stripped. Verify
by using objdump -h on the executable and look for the .debug*
sections. If the sections are not present, examine your Makefile
for any lines that invoke the 'strip' utility on the executable.

e.g.

$ objdump -h /tmp/b974 | tail

28 .comment 00000046 0000000000000000 0000000000000000 000091f8 2**0
CONTENTS, READONLY
29 .debug_aranges 00000250 0000000000000000 0000000000000000 00009240 2**4
CONTENTS, READONLY, DEBUGGING
30 .debug_pubnames 00000733 0000000000000000 0000000000000000 00009490 2**0
CONTENTS, READONLY, DEBUGGING
31 .debug_info 00007b5c 0000000000000000 0000000000000000 00009bc3 2**0
CONTENTS, READONLY, DEBUGGING
32 .debug_abbrev 00000f67 0000000000000000 0000000000000000 0001171f 2**0
CONTENTS, READONLY, DEBUGGING
33 .debug_line 00001408 0000000000000000 0000000000000000 00012686 2**0
CONTENTS, READONLY, DEBUGGING
34 .debug_str 00003219 0000000000000000 0000000000000000 00013a8e 2**0
CONTENTS, READONLY, DEBUGGING
35 .debug_loc 00003c15 0000000000000000 0000000000000000 00016ca7 2**0
CONTENTS, READONLY, DEBUGGING
36 .debug_ranges 00001b50 0000000000000000 0000000000000000 0001a8bc 2**0
CONTENTS, READONLY, DEBUGGING
$
From: cerr on
On Mar 18, 1:24 pm, sc...(a)slp53.sl.home (Scott Lurndal) wrote:
> cerr <ron.egg...(a)gmail.com> writes:
> >On Mar 18, 11:10=A0am, Ben Bacarisse <ben.use...(a)bsb.me.uk> wrote:
> >> cerr <ron.egg...(a)gmail.com> writes:
> >> > I have a question. I'm running into a segfault but on bt i do not get
> >> > source code but only useless addresses.
> >> > I've done the following:
> >> > - loaded my binary with symbol-file
> >> > - compiled binary with following flags: -g3 -O0 -g
>
> >> The mixture of -g3 and -g seems odd. =A0At best I'd imagine that the
> >> latter -g is the one that governs the compile and -g is -g2 by
> >> default.
>
> >> > - executed gdb from the source directory
> >> > - set dir to "./"
>
> >> > Why am I still not seeing the source code? :o
>
> >> Is the fault in a part of the code for which there are no symbols?
> >> E.g. in a library that you did not compile with -g.
>
> >I would not think so...
>
> >> > Thanks for a little help here!
>
> >> Posting some/all of the output might give a vital clue.
>
> >The output looks like this:
> >Program received signal SIGSEGV, Segmentation fault.
> >0xb7f009b3 in ?? ()
> >(gdb) bt
> >#0  0xb7f009b3 in ?? ()
> >#1  0xbf9c43e4 in ?? ()
> >#2  0xbf9c4384 in ?? ()
> >#3  0xbf9c4328 in ?? ()
> >#4  0xb7f1bff4 in ?? ()
> >#5  0x4ba2695f in ?? ()
> >#6  0xb7f1bff4 in ?? ()
> >#7  0xbf9c43e4 in ?? ()
> >#8  0x00000000 in ?? ()
> >(gdb)
>
> You neglected to specify which operating system and which version
> of the gnu toolchain you are using.

I'm using Linux and GNU gdb 6.8

> However, this appears as if the executable was stripped.  Verify
> by using objdump -h on the executable and look for the .debug*
> sections.  If the sections are not present, examine your Makefile
> for any lines that invoke the 'strip' utility on the executable.
[snip]
a tail-ed objdump looks like:
objdump -h prg | tail
28 .debug_abbrev 0000e7db 00000000 00000000 001fc34a 2**0
CONTENTS, READONLY, DEBUGGING
29 .debug_line 0001fc6c 00000000 00000000 0020ab25 2**0
CONTENTS, READONLY, DEBUGGING
30 .debug_frame 0000fa3c 00000000 00000000 0022a794 2**2
CONTENTS, READONLY, DEBUGGING
31 .debug_str 0000c79d 00000000 00000000 0023a1d0 2**0
CONTENTS, READONLY, DEBUGGING
32 .debug_macinfo 0026b6c1 00000000 00000000 0024696d 2**0
CONTENTS, READONLY, DEBUGGING

That doesn't look too shabby, does it?

From: cerr on
On Mar 18, 11:44 am, Ben Bacarisse <ben.use...(a)bsb.me.uk> wrote:
> cerr <ron.egg...(a)gmail.com> writes:
> > On Mar 18, 11:10 am, Ben Bacarisse <ben.use...(a)bsb.me.uk> wrote:
> >> cerr <ron.egg...(a)gmail.com> writes:
> >> > I have a question. I'm running into a segfault but on bt i do not get
> >> > source code but only useless addresses.
> >> > I've done the following:
> >> > - loaded my binary with symbol-file
>
> On re-reading this is curious.  There is less possibility for a
> mistake if gdb find the symbols from the file it is running.
Right but the binary i loaded the symbols from is the same as the one
that's running.
And i thought i may need to load it cause i'm actually debugging on a
remote target and not locally.
>
>
>
>
>
> >> > - compiled binary with following flags: -g3 -O0 -g
>
> >> The mixture of -g3 and -g seems odd.  At best I'd imagine that the
> >> latter -g is the one that governs the compile and -g is -g2 by
> >> default.
>
> >> > - executed gdb from the source directory
> >> > - set dir to "./"
>
> >> > Why am I still not seeing the source code? :o
>
> >> Is the fault in a part of the code for which there are no symbols?
> >> E.g. in a library that you did not compile with -g.
>
> > I would not think so...
>
> >> > Thanks for a little help here!
>
> >> Posting some/all of the output might give a vital clue.
>
> > The output looks like this:
> > Program received signal SIGSEGV, Segmentation fault.
> > 0xb7f009b3 in ?? ()
> > (gdb) bt
> > #0  0xb7f009b3 in ?? ()
> > #1  0xbf9c43e4 in ?? ()
> > #2  0xbf9c4384 in ?? ()
> > #3  0xbf9c4328 in ?? ()
> > #4  0xb7f1bff4 in ?? ()
> > #5  0x4ba2695f in ?? ()
> > #6  0xb7f1bff4 in ?? ()
> > #7  0xbf9c43e4 in ?? ()
> > #8  0x00000000 in ?? ()
> > (gdb)
> > Thanks!
>
> It's possible that gdb can't give you a stack trace because the stack
> has been messed up.
How would that happen?
>
> Step through the program skipping over everything but the top-level
> functions to find where the fault it.  Keep going deeper as you get
> closer to fault.
Uhm, that's difficult as there's various threads.
>
> Have you tried other tools like valgrind?
Nope I unfortunately can't get valgring compiled for my target
platform... :(

From: cerr on
On Mar 18, 11:31 am, Andrew Poelstra <apoels...(a)localhost.localdomain>
wrote:
> On 2010-03-18, cerr <ron.egg...(a)gmail.com> wrote:
>
>
>
>
>
> > On Mar 18, 11:10 am, Ben Bacarisse <ben.use...(a)bsb.me.uk> wrote:
> >> cerr <ron.egg...(a)gmail.com> writes:
> >> > I have a question. I'm running into a segfault but on bt i do not get
> >> > source code but only useless addresses.
> >> > I've done the following:
> >> > - loaded my binary with symbol-file
> >> > - compiled binary with following flags: -g3 -O0 -g
>
> >> The mixture of -g3 and -g seems odd.  At best I'd imagine that the
> >> latter -g is the one that governs the compile and -g is -g2 by
> >> default.
>
> >> > - executed gdb from the source directory
> >> > - set dir to "./"
>
> >> > Why am I still not seeing the source code? :o
>
> >> Is the fault in a part of the code for which there are no symbols?
> >> E.g. in a library that you did not compile with -g.
>
> > I would not think so...
>
> >> > Thanks for a little help here!
>
> >> Posting some/all of the output might give a vital clue.
>
> > The output looks like this:
> > Program received signal SIGSEGV, Segmentation fault.
> > 0xb7f009b3 in ?? ()
> > (gdb) bt
> > #0  0xb7f009b3 in ?? ()
> > #1  0xbf9c43e4 in ?? ()
> > #2  0xbf9c4384 in ?? ()
> > #3  0xbf9c4328 in ?? ()
> > #4  0xb7f1bff4 in ?? ()
> > #5  0x4ba2695f in ?? ()
> > #6  0xb7f1bff4 in ?? ()
> > #7  0xbf9c43e4 in ?? ()
> > #8  0x00000000 in ?? ()
> > (gdb)
>
> If you've got debug symbols in there, try:
>
> (gdb) break 1
> (gdb) run
> (gdb) x 0xb7f009b3
>
> And examine each of those hex addresses while the program is running.
How would I examine each of the addresses? That's gonna be quite a
number....

> (This assumes you don't crash before line 1.)
>
> --
> Andrew Poelstrahttp://www.wpsoftware.net/andrew

From: Andrew Poelstra on
On 2010-03-19, cerr <ron.eggler(a)gmail.com> wrote:
> On Mar 18, 11:31�am, Andrew Poelstra <apoels...(a)localhost.localdomain>
> wrote:
>> On 2010-03-18, cerr <ron.egg...(a)gmail.com> wrote:
>> > The output looks like this:
>> > Program received signal SIGSEGV, Segmentation fault.
>> > 0xb7f009b3 in ?? ()
>> > (gdb) bt
>> > #0 �0xb7f009b3 in ?? ()
>> > #1 �0xbf9c43e4 in ?? ()
>> > #2 �0xbf9c4384 in ?? ()
>> > #3 �0xbf9c4328 in ?? ()
>> > #4 �0xb7f1bff4 in ?? ()
>> > #5 �0x4ba2695f in ?? ()
>> > #6 �0xb7f1bff4 in ?? ()
>> > #7 �0xbf9c43e4 in ?? ()
>> > #8 �0x00000000 in ?? ()
>> > (gdb)
>>
>> If you've got debug symbols in there, try:
>>
>> (gdb) break 1
>> (gdb) run
>> (gdb) x 0xb7f009b3
>>
>> And examine each of those hex addresses while the program is running.
> How would I examine each of the addresses? That's gonna be quite a
> number....
>

You posted 9: There are nine numbers to check. Just copy and
paste them individually from the output of 'bt' to the input
of 'x'.

If you break at line 1 (before anything horrible has happened),
it'll tell you what function is located at that memory address
and hopefully you can determine the problem from there.

--
Andrew Poelstra
http://www.wpsoftware.net/andrew