|
From: | Hyung-Taek Lim |
Subject: | Does gdbserver support multithreaded program in linux? |
Date: | Mon, 23 Apr 2001 19:46:21 +0900 |
Hi,
I wonder whether gdbserver supports multithreaded program in
Linux or not.
I made a small multithreaded program with
pthread.
If I debug the program with the same host as gdb by entering
"gdb sample",
I could debug the program very well.
I could switch between threads and could get information about
register information of each thread.
However, I failed to debug the program remotely with
gdbserver.
gdb shows SIGPWR signal after my sample program has created a
new pthread.
Host and target were all Linux and I used gdb
5.0.
I list my small sample program and error message I encountered
when debugging remotely.
Thanks. ^^
----------------------------------------------------------------
#include <stdio.h>
#include <pthread.h> #include <sys/types.h> #include <signal.h> void* print_digit(void* arg); pthread_t thrid[10]; main() { int i=0; printf("\nmain thread:PID[%d],THR[%d]\n",getpid(),pthread_self()); sleep(3); pthread_create(&thrid[i],NULL,print_digit,(void *)i); i++; pthread_create(&thrid[i],NULL,print_digit,(void *)i); i++; pthread_create(&thrid[i],NULL,print_digit,(void *)i); i++; pthread_create(&thrid[i],NULL,print_digit,(void *)i); i++; pthread_create(&thrid[i],NULL,print_digit,(void *)i); i++; sleep(10000); pthread_exit(0); } void* print_digit(void* arg) { int i,j,digit; digit = (int)arg; printf("\nPID[%d],THR[%d]: digit=%d\n",getpid(),pthread_self(),digit); for (i=0; i < 1000000; i++) { sleep(1); printf("%d",digit); fflush(NULL); } } ===============================================================
address@hidden:~/testgdb2 > gdb
GNU gdb 5.0 Copyright 2000 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) target remote htlim2.etri.re.kr:20000 Remote debugging using htlim2.etri.re.kr:20000 0x40001990 in ?? () (gdb) symbol-file mthrtest Reading symbols from mthrtest...done. (gdb) br 20 Breakpoint 1 at 0x80485dd: file mthrtest.c, line 20. (gdb) cont Continuing. Breakpoint 1, main () at mthrtest.c:20 20 sleep(3); (gdb) br 22 Breakpoint 2 at 0x8048613: file mthrtest.c, line 22. (gdb) cont Continuing. Program received signal SIGPWR, Power fail/restart. 0x40050b7e in ?? () (gdb) |
[Prev in Thread] | Current Thread | [Next in Thread] |