This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
gdb and remote debugging with threads
- From: "Srikanth Krishnamohan" <Srikanth dot Krishnamohan at navigon dot com>
- To: <gdb at sourceware dot org>
- Cc: <gdb at sources dot redhat dot com>
- Date: Wed, 7 Jun 2006 16:17:09 +0200
- Subject: gdb and remote debugging with threads
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
Listening on port 5000
Remote debugging from host 192.168.190.117
Creating thread num 0
Child terminated with signal = 9
Child terminated with signal = 0x9
GDBserver exiting
[root@Linux /opt]#