This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Tue, Oct 24, 2006 at 02:34:04PM -0400, Daniel Jacobowitz wrote: > On Tue, Oct 24, 2006 at 08:29:33PM +0200, Benedikt Spranger wrote: > > Attaching gdb to gdbserver, set the above breakpoints and issue "cont", > > then the program stops at breakpoint BP1. BP2 is never reached, although > > the thread is visible via "ps" on the target system. The thread is stuck > > in sys_futex and not as expected in the ptrace breakpoint trap. Also gdb > > does not show that the thread was created. > > > > This can be reproduced with glibc 2.3.6 -> 2.5, kernel 2.6.14 -> > > 2.6.19-rc2, gcc 3.4 -> 4.1.1 and binutils up to cvs-latest. > > Well, it works just fine for me, so you may want to investigate your > setup. Have you set solib-absolute-prefix, the most frequent problem? > Check if "info shared" and "info threads" show sensible output. Here are some more details about the problem. It turned out that it works if you link against libpthread dynamically and doesn't with -static. The test program and log reports of the static and dynamic case are attached. Robert -- Dipl.-Ing. Robert Schwebel | http://www.pengutronix.de Pengutronix - Linux Solutions for Science and Industry Handelsregister: Amtsgericht Hildesheim, HRA 2686 Hannoversche Str. 2, 31134 Hildesheim, Germany Phone: +49-5121-206917-0 | Fax: +49-5121-206917-9
#define _XOPEN_SOURCE 600 #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <semaphore.h> #include <time.h> #include <assert.h> #include <errno.h> #include <signal.h> #include <pthread.h> #include <signal.h> #define die(msg) {perror (msg); exit (EXIT_FAILURE); } sem_t sem; int stop; void sig_handler (int sig) { stop = sig; } void *thread1 (void *data) { int t = (int) data; while (!stop) { while (sem_wait (&sem) == -1 && errno == EINTR) continue; printf ("My name is %d. thread %d\n", t, t); fflush (stdout); sem_post (&sem); sleep (1); } return NULL; } void *thread2 (void *data) { int t = (int) data; while (!stop) { while (sem_wait (&sem) == -1 && errno == EINTR) continue; printf ("My name is %d. thread %d\n", t, t); fflush (stdout); sem_post (&sem); sleep (1); } return NULL; } void *thread3 (void *data) { int t = (int) data; while (!stop) { while (sem_wait (&sem) == -1 && errno == EINTR) continue; printf ("My name is %d. thread %d\n", t, t); fflush (stdout); sem_post (&sem); sleep (1); } return NULL; } void *thread4 (void *data) { int t = (int) data; while (!stop) { while (sem_wait (&sem) == -1 && errno == EINTR) continue; printf ("My name is %d. thread %d\n", t, t); fflush (stdout); sem_post (&sem); sleep (1); } return NULL; } int main (void) { pthread_t p1, p2, p3, p4; signal (SIGINT, sig_handler); stop = 0; if (sem_init (&sem, 0, 0) == -1) die ("sem_init"); pthread_create (&p1, NULL, thread1, (void *) 1); pthread_create (&p2, NULL, thread2, (void *) 2); pthread_create (&p3, NULL, thread3, (void *) 3); pthread_create (&p4, NULL, thread4, (void *) 4); while (!stop) { printf ("main\n"); fflush (stdout); sem_post (&sem); sleep (2); } sem_post (&sem); pthread_join (p1, NULL); pthread_join (p2, NULL); pthread_join (p3, NULL); pthread_join (p4, NULL); return 0; }
Attachment:
static_bin.gdb.log
Description: Text document
Attachment:
shared_bin.gdb.log
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |