gdb and remote debugging with threads

Srikanth Krishnamohan
2006-06-07T14:17:11Z

Hello All,
Does gdb 6.4 support remote debugging of a muti-threaded program. The
host is i686-linux and target is arm-xscale-linux.
The program exits when a break point is set and some cases gdb does not
stop at the breakpoints.

The problem also exists with remote debugging, when both the host and
target are i686-linux.

There seems to be lot of mails on this topic but no clear answer to the
current status.
An update would be greatly welcome.

Regards,
Srikanth

-----------------------Source code and gdb session
output-------------------------

//source code - multi-threaded program
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

void *thread_func(void *arg) {

int iThid = *(int *)arg;
printf("thread_func ID %d\n",iThid);
}

int main(int argc, char **argv)
{
if (argc < 1) {
printf("Usage: %s numthreads\n",argv[0]);
exit(1);
}
int retVal = 0,index=0;
int numThreads = atoi(argv[1]);
pthread_t thid[numThreads];

//create all the threads
for(index = 0;index <numThreads; index ++) {
printf("Creating thread num %d\n",index);
retVal = pthread_create(&thid[index],NULL,thread_func,(void
*)&index);
if (retVal < 0) {
printf("Error in creating thread id %d\n",thid[index]);
}
sleep(1);
}

for(index = 0;index <numThreads; index ++) {
pthread_join(thid[index],NULL);
}

}//end of source

---------------------------gdb session
output-------------------------------------------

//host(i686-linux) side session

$gdb thread_tst_xscale
GNU gdb 6.4
Copyright 2005 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 "--host=i686-pc-linux-gnu
--target=arm-xscale-linux-gnu"...
(gdb) target remote 192.168.190.135:5000
Remote debugging using 192.168.190.135:5000
0x40000e50 in ?? ()
(gdb) b 9
Breakpoint 1 at 0x853c: file thread_tst.c, line 9.
(gdb) c
Continuing.

Program received signal SIG32, Real-time event 32.
0x400a75f4 in ?? ()
(gdb) c
Continuing.

Program terminated with signal SIGKILL, Killed.
The program no longer exists.
(gdb)

//target(arm-xscale-linux) side session

[root@Linux /opt]#gdbserver :5000 ./thread_tst_xscale 5
Process ./thread_tst_xscale created; pid = 927