bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can't debug multi-threaded programs; Program received signal SIG32


From: William Brower
Subject: Can't debug multi-threaded programs; Program received signal SIG32
Date: Thu, 29 Nov 2001 23:02:29 +1200

I can't debug this 18 line program with the latest (5.1),
or earlier versions of GDB. Curiously, when I build the
program with 'gcc --static ...' option, it works. Any ideas?

---------begin test_threads.c----------
#include <stdio.h>
#include <pthread.h>

void* dummy(void* vp)
{ 
  printf("Inside dummy\n");
}

int main(void)
{ 
  int n;
  for (n = 0; n < 10; n++) {
    pthread_t d;
    const int status = pthread_create(&d, NULL, dummy, NULL);
    printf("status: %d\n", status);
  }
  return 0;
}
----------end test_threads.c--------------

Compile first with:

% gcc -g -o test_threads test_threads.c -lpthread

Debug with:
address@hidden wb]$ gdb ./test_threads
GNU gdb 5.1
Copyright 2001 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 "i686-pc-linux-gnu"...
(gdb) b dummy
Breakpoint 1 at 0x80484d6: file test_threads.c, line 6.
(gdb) r
Starting program: /home/wb/./test_threads 

Program received signal SIG32, Real-time event 32.
0x4006f965 in sigsuspend () from /lib/libc.so.6
(gdb) info threads
(gdb) 

I get that pesky SIG32 signal and I'm dead in the water.

Now, compile with:

address@hidden wb]$ gcc --static -g -o test_threads test_threads.c
-lpthread
address@hidden wb]$ gdb ./test_threads
GNU gdb 5.1
Copyright 2001 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 "i686-pc-linux-gnu"...
(gdb) b dummy
Breakpoint 1 at 0x80481e6: file test_threads.c, line 6.
(gdb) r
Starting program: /home/wb/./test_threads 
[New Thread 1024 (LWP 4160)]
[New Thread 2049 (LWP 4161)]
[New Thread 1026 (LWP 4162)]
[Switching to Thread 1026 (LWP 4162)]

Breakpoint 1, dummy (vp=0x0) at test_threads.c:6
6         printf("Inside dummy\n");
(gdb) info threads
* 3 Thread 1026 (LWP 4162)  dummy (vp=0x0) at test_threads.c:6
  2 Thread 2049 (LWP 4161)  0x080537d8 in __poll (fds=0x80b076c, nfds=1, 
    timeout=2000) at ../sysdeps/unix/sysv/linux/poll.c:63
  1 Thread 1024 (LWP 4160)  0x08053a9d in __mmap ()
(gdb) 


And all is well. What gives?

Some more system details:
address@hidden wb]$  rpm -qa | grep glibc
glibc-common-2.2.2-10
glibc-devel-2.2.2-10
glibc-2.2.2-10
compat-glibc-6.2-2.1.3.2

address@hidden wb]$  rpm -qa | grep gcc  
gcc-objc-2.96-81
gcc-2.96-81
gcc-g77-2.96-81
gcc-c++-2.96-81

address@hidden wb]$  rpm -qa |grep gdb
gdbm-devel-1.8.0-5
gdbm-1.8.0-5
gdb-5.0.92-1

Thanks,
Bill Brower
MIT Lincoln Laboratory
Kwajalein, Marshall Islands



reply via email to

[Prev in Thread] Current Thread [Next in Thread]