From: cerr on
Hi There,

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
- executed gdb from the source directory
- set dir to "./"

Why am I still not seeing the source code? :o

Thanks for a little help here!
--
Ron
From: Ben Bacarisse on
cerr <ron.eggler(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.

> Thanks for a little help here!

Posting some/all of the output might give a vital clue.

--
Ben.
From: cerr on
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)
Thanks!
--
Ron
From: Andrew Poelstra on
On 2010-03-18, cerr <ron.eggler(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.
(This assumes you don't crash before line 1.)

--
Andrew Poelstra
http://www.wpsoftware.net/andrew
From: Ben Bacarisse on
cerr <ron.eggler(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.

>> > - 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.

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.

Have you tried other tools like valgrind?

--
Ben.