Subject: Re: gdb backtrace
To: Christian Groessler <cpg@aladdin.de>
From: Kamal Prasad <kamalpr@yahoo.com>
List: tech-toolchain
Date: 07/03/2002 16:50:21
I am seeing the same problem. further, the address
returned by the bt is not a valid address.
at the very least, it should be possible to do an nm
and locare the function name where we got a signal.
thanks
-kamal

--- Christian Groessler <cpg@aladdin.de> wrote:
> Hi,
> 
> the gdb backtrace doesn't work if linked w/ shared
> libs.
> 
> Assume the following program:
> 
> ----------------
> #include <stdio.h>
> 
> void runtz(void)
> {
>         sleep(1);
>         printf("runtz\n");
> }
> 
> int main(void)
> {
> 
>         int i;
> 
>         for (i=0; i<100; i++) runtz();
> 
>         return(0);
> }
> ----------------
> 
> After "cc -g loopy.c -o loopy", try
> 
> ----------------
> [power:~/tmp]$ gdb loopy
> GNU gdb 5.0nb1
> Copyright 2000 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General
> Public License, and you are
> welcome to change it and/or distribute copies of it
> under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show
> warranty" for details.
> This GDB was configured as "powerpc--netbsd"...
> (gdb) r
> Starting program: /home/chris/tmp/loopy 
> runtz
> ^C
> Program received signal SIGINT, Interrupt.
> 0x418865f4 in ?? () from /usr/lib/libc.so.12
> (gdb) bt
> #0  0x418865f4 in ?? () from /usr/lib/libc.so.12
> (gdb)
> ----------------
> 
> It does not work.
> Trying the same statically linked "cc -g -static
> loopy.c -o loopy", it
> works:
> 
> ----------------
> [power:~/tmp]$ gdb loopy
> GNU gdb 5.0nb1
> Copyright 2000 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General
> Public License, and you are
> welcome to change it and/or distribute copies of it
> under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show
> warranty" for details.
> This GDB was configured as "powerpc--netbsd"...
> (gdb) r
> Starting program: /home/chris/tmp/loopy 
> runtz
> ^C
> Program received signal SIGINT, Interrupt.
> 0x18007a4 in nanosleep ()
> (gdb) bt
> #0  0x18007a4 in nanosleep ()
> #1  0x1800788 in sleep ()
> #2  0x1800638 in runtz () at loopy.c:6
> #3  0x1800694 in main () at loopy.c:15
> #4  0x180030c in _start ()
> (gdb) 
> ----------------
> 
> On i386, even with "cc -g loopy.c -o loopy" (using
> shared libs) it
> works:
> 
> ----------------
> [tann:~/tmp]$ gdb loopy
> GNU gdb 5.0nb1
> Copyright 2000 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General
> Public License, and you are
> welcome to change it and/or distribute copies of it
> under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show
> warranty" for details.
> This GDB was configured as "i386--netbsdelf"...
> (gdb) r
> Starting program: /home/chris/tmp/loopy 
> runtz
> ^C
> Program received signal SIGINT, Interrupt.
> 0x480a87c7 in nanosleep () from /usr/lib/libc.so.12
> (gdb) bt
> #0  0x480a87c7 in nanosleep () from
> /usr/lib/libc.so.12
> #1  0x480a87a0 in sleep () from /usr/lib/libc.so.12
> #2  0x8048944 in runtz () at loopy.c:6
> #3  0x8048979 in main () at loopy.c:15
> #4  0x8048740 in ___start ()
> (gdb) 
> ----------------
> 
> 
> Should I send-pr this?
> 
> regards,
> chris
> 


__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com