Hi,I'm not sure whether this is a bug of gdb 5.0.I
made a very simple multi-threaded program in RedHat 7.1 andtried to debug it
with gdb 5.0 that is distributed on May 2000.When I run the program in gdb
5.0,it shows "Program exits with code 01" in the middle of execution of the
program.
Following is my multi-threaded program.It
createspthreas.
test.c
#include pthread.hvoid* runProc();int
main(){pthread_t threadID;
pthread_create(threadID,NULL,runProc,NULL);
printf("main-threadID:
%d\n",threadID);}void*
runProc(){pthread_t threadID;
pthread_create(threadID,NULL,runProc,NULL);
printf("runProc-threadID: %d\n",threadID);
return NULL;}
compile : gcc -o test test.c -lpthreadFollowing is the
result of debugging my program with gdb 5.0:
gdb testGNU gdb 5.0rh-5 Red Hat Linux 7.1Copyright
2000 Free Software Foundation, Inc.GDB is free software, covered by the GNU
General Public License, and you arewelcome to change it and/or distribute
copies of it under certainconditions.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"...(gdb)
runStarting program: /root/test[New Thread 1024 (LWP 3122)][New
Thread 2049 (LWP 3123)]Delayed SIGSTOP caught for LWP 3123.
[New Thread 1026 (LWP 3124)]
Delayed SIGSTOP caught for LWP 3124.
ReceivedReal-timesignal 0 in LWP 3122 while
waiting for SIGSTOP.
[New Thread 2051 (LWP 3125)]
Using pending wait status for LWP 3122.
main-threadID; 1026
Delayed SIGSTOP caught for LWP 3125.
LWP 3123 exited.
LWP 3125 exited.
LWP 3124 exited.
Program exited with code 01.
(gdb) quit
2002/8/1anny
** PID[31946],THR[1026]: digit=00[New
Thread 2051 (LWP 31947)]00 ** PID[31947],THR[2051]:
digit=101[New Thread 3076 (LWP 31948)]011 **
PID[31948],THR[3076]: digit=212Program exited normally.(gdb)
1(gdb) info threadsNo stack.(gdb) btNo stack.(gdb)
quit[htlim@esto
testgdb]$==ENDOnly
three pthreads are created and my program dies without creating fourthand
fifth pthreads.But debugging my program with a gdb that comes with
RedHat 7.1 works nicely.Following is the result of debugging my program with
gdb in RedHat
7.1.==BEGIN==[htlim@esto
testgdb]$ gdb mthrtest1GNU gdb 5.0rh-5 Red Hat Linux 7.1Copyright 2001
Free Software Foundation, Inc.GDB is free software, covered by the GNU
General Public License, and you arewelcome to change it and/or distribute
copies of it under certainconditions.Type "show copying" to see the
conditions.There is absolutely no warranty for GDB. Type "show
warranty" for details.This GDB was configured as
"i386-redhat-linux"...(gdb) runStarting program:
/home/htlim/testgdb/mthrtest1[New Thread 1024 (LWP 31951)] **
main thread:PID[31951],THR[1024][New Thread 2049 (LWP 31952)]Delayed
SIGSTOP caught for LWP 31952.[New Thread 1026 (LWP 31953)]Delayed
SIGSTOP caught for LWP 31953. ** PID[31953],THR[1026]:
digit=0[New Thread 2051 (LWP 31954)]Delayed SIGSTOP caught for LWP
31954.0 ** PID[31954],THR[2051]: digit=1[New Thread 3076 (LWP
31955)]Delayed SIGSTOP caught for LWP 31955.10 **
PID[31955],THR[3076]: digit=2[New Thread 4101 (LWP 31956)]Delayed
SIGSTOP caught for LWP 31956.210 ** PID[31956],THR[4101]:
digit=3[New Thread 5126 (LWP 31957)]Delayed SIGSTOP caught for LWP
31957.3210 ** PID[31957],THR[5126]: digit=401234LWP 31953
exited. ** THR[1026] terminated1234LWP 31954 exited. **
THR[2051] terminated234LWP 31955 exited. ** THR[3076]
terminated34LWP 31956 exited. ** THR[4101] terminated4LWP
31957 exited. ** THR[5126] terminated Test program
terminates LWP 31952 exited.Program exited normally.(gdb)
quit[htlim@esto
testgdb]$==END