gdb stack trace shows only those frames after the signal
srikrish
srikrish@in.ibm.com
Tue Dec 23 15:03:00 GMT 2003
Hi - I'm sorry for the formatting problems in my previous post.
After handling a signal the previous stack trace is lost. Is this a known problem? Any fixes?
Hardware Environment: Intel x86
Software Environment:
RHEL 3; gdb-5.3.90-0.20030710.40rh; glibc 2.3.2-95.6; gcc 3.2.3 20030502
Steps to Reproduce:
1. compile the testcase (under Additinal Info below) with "gcc -o t mytrap.c"
2. run "t"
3. attach gdb to the "t"'s PID and type "where"
Actual Results:
[root@localhost root]# gdb
GNU gdb Red Hat Linux (5.3.90-0.20030710.40rh)
This GDB was configured as "i386-redhat-linux-gnu".
(gdb) attach 2032
Attaching to process 2032
Reading symbols from /home/krishna/t...done.
Using host libthread_db library "/lib/libthread_db.so.1".
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
0xb755d8cb in pause () from /lib/libc.so.6
(gdb) where
#0 0xb755d8cb in pause () from /lib/libc.so.6
#1 0x0804840f in function2 () at mytrap.c:8
#2 0x0804842c in function1 () at mytrap.c:15
#3 0x08048449 in SIGSEGVhandler (sig=11, info=0xbfffa5a0, ucontext=0xbfffa620)
at mytrap.c:22
#4 <signal handler called>
(gdb) frame 5
#0 0x00000000 in ?? ()
(gdb)
Expected Results:
the stack traceback should display functionb, functiona, and main for this
testcase
mytrap.c:
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
void function2( void )
{
printf( "Now in function2.. pausing.. pid = %d\n", getpid() );
pause();
}
void function1( void )
{
printf( "Now in function1\n" );
function2();
}
void SIGSEGVhandler( int sig, siginfo_t *info, void *ucontext )
{
printf( "Now in SIGSEGVhandler\n" );
function1();
}
void functionb( void )
{
char *p = NULL;
printf( "Now in functionb... causing sig11...\n" );
*p = 'x'; /* forcing SEGFAULT */
}
void functiona( void )
{
printf( "Now in functiona\n" );
functionb();
}
int main( void )
{
struct sigaction newact;
struct sigaction oldact;
newact.sa_sigaction = SIGSEGVhandler;
newact.sa_flags = SA_SIGINFO;
sigaction( SIGSEGV, &newact, &oldact );
printf( "About to call functiona\n" );
functiona();
return 0;
}
Srikrishnan
More information about the Gdb
mailing list