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]

GDBserver - debugging a MULTI-THREADED application.


Hello,


Debugging a MULTITHREADED application with GDBserver hangs when running
into the GDB-(server) debugger.

I've been DIGGING the web and the newsgroups for several days now and...
Still not able to find anything that can help me a little further.


Platform ARM-at91sam9g20 (=ARM)
Using GDB-6.8 / GDBserver-6.8 
Eclipse-3.4.2. (as UI)


The problem is that as soon as a SECOND thread is started, the
application seems to freeze if ran in the DEBUGGER, when the application
is run without GDB all seems to behave 'normally'.


Anyone that can point me in the GOOD direction?



Kind regards 
Noel Vellemans


Note: I've written a SMALL sample that can show the 'strange' behavior.


// Source Code 


/* Some Sample test*/

#include <pthread.h>
#include <stdio.h>
#define NUM_THREADS	5

void *PrintHello(void *threadid)
{
  int n;
  for (n=0;n<20;n++)
  {
   printf("\r\n%d: Hello World! %d \r\n", threadid,n);
   sleep(5);
  }
   pthread_exit(NULL);
}

int main()
{
   pthread_t threads[NUM_THREADS];
   int rc, t;
   for(t=0;t<NUM_THREADS;t++){
      printf("Creating thread %d\r\n", t);
      rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
      if (rc){
         printf("ERROR; return code from pthread_create() is %d\r\n",
rc);
         exit(-1);
      }
   }

   printf("Sleeping/printing in main ..... \r\n");
   {
	   int n;
	   for(n=0;n<30;n++)
	   {
		   sleep(1);
		   printf("printing in main %d \r\n",n);
		   sleep(4);
	   }
   }
   printf("Sleeping in main ..... DONE .. \r\n");
   pthread_exit(NULL);
}




///
when looking at the console output I get this BEHAVOIR when running GDB.
The application seens to HANG when the 2nd thread is started.

////////////////////////////////////////
// GDB-Server - Console - LOG
// HANGS !!!!! 
////////////////////////////////////////
gdbserver *:9000 ./threading 
Process ./threading created; pid = 1006
Listening on port 9000
Remote debugging from host xxx.xxx.xxx.xxx
Creating thread 0
01006 : __pthread_initialize_manager: manager stack: size=8160,
bos=0x11150, tos=0x13130
01006 : __pthread_initialize_manager: send REQ_DEBUG to manager thread
01007 : __pthread_manager: before poll
01006 : pthread_create: write REQ_CREATE to manager thread
01007 : __pthread_manager: after poll
01007 : __pthread_manager: before __libc_read
01007 : __pthread_manager: after __libc_read, n=148
01007 : __pthread_manager: got REQ_CREATE
01007 : pthread_handle_create: cloning new_thread = 0xbe5ffe20
01006 : pthread_create: before suspend(self)
01008 : pthread_start_thread: 

0: Hello World! 0 
01007 : pthread_handle_create: new thread pid = 1008
01007 : __pthread_manager: restarting 1073938496
01007 : __pthread_manager: before poll
01006 : pthread_create: after suspend(self)
Creating thread 1
01006 : pthread_create: write REQ_CREATE to manager thread
01006 : pthread_create: before suspend(self)
01007 : __pthread_manager: after poll
01007 : __pthread_manager: before __libc_read
01007 : __pthread_manager: after __libc_read, n=148
01007 : __pthread_manager: got REQ_CREATE
01007 : pthread_handle_create: cloning new_thread = 0xbe3ffe20

0: Hello World! 1 
01007 : pthread_handle_create: new thread pid = 1009
01007 : __pthread_manager: restarting 1073938496
01007 : __pthread_manager: before poll


==> This is the LAST output line on the CONSOLE ... 
==> and the DEBUGGER seems to freeze/hang !!
==> have to reboot TARGET !! 




////////////////////////////////////////
// native-Console - LOG (no GDB-server)
// RUNS FINE !!!!
////////////////////////////////////////
Creating thread 0
00996 : __pthread_initialize_manager: manager stack: size=8160,
bos=0x11150, tos=0x13130
00996 : __pthread_initialize_manager: send REQ_DEBUG to manager thread
00997 : __pthread_manager: before poll
00996 : pthread_create: write REQ_CREATE to manager thread
00997 : __pthread_manager: after poll
00997 : __pthread_manager: before __libc_read
00997 : __pthread_manager: after __libc_read, n=148
00997 : __pthread_manager: got REQ_CREATE
00997 : pthread_handle_create: cloning new_thread = 0xbe7ffe20
00998 : pthread_start_thread: 

0: Hello World! 0 
00997 : pthread_handle_create: new thread pid = 998
00997 : __pthread_manager: restarting 1073938496
00997 : __pthread_manager: before poll
00996 : pthread_create: before suspend(self)
00996 : pthread_create: after suspend(self)
Creating thread 1
00996 : pthread_create: write REQ_CREATE to manager thread
00996 : pthread_create: before suspend(self)
00997 : __pthread_manager: after poll
00997 : __pthread_manager: before __libc_read
00997 : __pthread_manager: after __libc_read, n=148
00997 : __pthread_manager: got REQ_CREATE
00997 : pthread_handle_create: cloning new_thread = 0xbe5ffe20
00999 : pthread_start_thread: 

1: Hello World! 0 
00997 : pthread_handle_create: new thread pid = 999
00997 : __pthread_manager: restarting 1073938496
00996 : pthread_create: after suspend(self)
Creating thread 2
00996 : pthread_create: write REQ_CREATE to manager thread
00996 : pthread_create: before suspend(self)
00997 : __pthread_manager: before poll
00997 : __pthread_manager: after poll
00997 : __pthread_manager: before __libc_read
00997 : __pthread_manager: after __libc_read, n=148
00997 : __pthread_manager: got REQ_CREATE
00997 : pthread_handle_create: cloning new_thread = 0xbe3ffe20
01000 : pthread_start_thread: 

2: Hello World! 0 
00997 : pthread_handle_create: new thread pid = 1000
00997 : __pthread_manager: restarting 1073938496
00996 : pthread_create: after suspend(self)
Creating thread 3
00996 : pthread_create: write REQ_CREATE to manager thread
00996 : pthread_create: before suspend(self)
00997 : __pthread_manager: before poll
00997 : __pthread_manager: after poll
00997 : __pthread_manager: before __libc_read
00997 : __pthread_manager: after __libc_read, n=148
00997 : __pthread_manager: got REQ_CREATE
00997 : pthread_handle_create: cloning new_thread = 0xbe1ffe20
01001 : pthread_start_thread: 

3: Hello World! 0 
00997 : pthread_handle_create: new thread pid = 1001
00997 : __pthread_manager: restarting 1073938496
00996 : pthread_create: after suspend(self)
Creating thread 4
00996 : pthread_create: write REQ_CREATE to manager thread
00996 : pthread_create: before suspend(self)
00997 : __pthread_manager: before poll
00997 : __pthread_manager: after poll
00997 : __pthread_manager: before __libc_read
00997 : __pthread_manager: after __libc_read, n=148
00997 : __pthread_manager: got REQ_CREATE
00997 : pthread_handle_create: cloning new_thread = 0xbdfffe20
01002 : pthread_start_thread: 

4: Hello World! 0 
00997 : pthread_handle_create: new thread pid = 1002
00997 : __pthread_manager: restarting 1073938496
00996 : pthread_create: after suspend(self)
Sleeping/printing in main ..... 
00997 : __pthread_manager: before poll
printing in main 0 
00997 : __pthread_manager: after poll
00997 : __pthread_manager: before poll
00997 : __pthread_manager: after poll
00997 : __pthread_manager: before poll

0: Hello World! 1 

1: Hello World! 1 

2: Hello World! 1 

3: Hello World! 1 

4: Hello World! 1 
printing in main 1 
00997 : __pthread_manager: after poll
00997 : __pthread_manager: before poll
00997 : __pthread_manager: after poll
00997 : __pthread_manager: before poll

0: Hello World! 2 

1: Hello World! 2 

2: Hello World! 2 

3: Hello World! 2 

4: Hello World! 2 
00997 : __pthread_manager: after poll
00997 : __pthread_manager: before poll
printing in main 2 
00997 : __pthread_manager: after poll
00997 : __pthread_manager: before poll
00997 : __pthread_manager: after poll
00997 : __pthread_manager: before poll

......... removed some lines here .........
......... removed some lines here .........
......... removed some lines here .........
......... removed some lines here .........
......... removed some lines here .........


0: Hello World! 19 

1: Hello World! 19 

2: Hello World! 19 

3: Hello World! 19 

4: Hello World! 19 
printing in main 19 
00997 : __pthread_manager: after poll
00997 : __pthread_manager: before poll
00997 : __pthread_manager: after poll
00997 : __pthread_manager: before poll
00998 : __pthread_do_exit: self=0xbe7ffe20, pid=998


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]