Subject: Re: gdb seems to ignore threads
To: Nathan J. Williams <nathanw@wasabisystems.com>
From: felix zaslavskiy <felix@students.poly.edu>
List: current-users
Date: 05/31/2003 19:36:46
On Sat, 2003-05-31 at 19:21, Nathan J. Williams wrote:
> felix zaslavskiy <felix@students.poly.edu> writes:
> 
> > My question is , is this the normal behavior or is gdb totaly useless at
> > debuging threads the way it supposed to at this time ?
> 
> What architecture, and what date of -current?
Just build i386 -current couple of hours ago

here is a output of my debuger
I interupted the program about 5 seconds into it running.
It only seems like the output is created after i interupt the program.
It seems like tee was buffering the output.  If i run the program
without interupting it , it will not break a second time.

GNU gdb 5.0nb1
Copyright 2000 Free Software Foundation, Inc.
.....
This GDB was configured as "i386--netbsdelf"...
(gdb) b main
Breakpoint 1 at 0x8048ab6: file simple_thread.c, line 20.
(gdb) b thread_execution 
Breakpoint 2 at 0x8048a6e: file simple_thread.c, line 9.
(gdb) run
Starting program: /root/src/./simple 

Breakpoint 1, main () at simple_thread.c:20
20		pthread_create (&thread, NULL, thread_execution, NULL);
(gdb) c
Continuing.
[New LWP 0]

Program received signal SIGINT, Interrupt.
[Switching to LWP 0]
0x48084a4b in sa_yield () at
/usr/src/lib/csu/i386_elf/../common_elf/crti.c:56
56		INIT_FALLTHRU();
(gdb) info threads
  3 Thread 21 ()  0x4805ff92 in pthread__locked_switch ()
    at /usr/src/lib/csu/i386_elf/../common_elf/crti.c:56
* 2 LWP 0  0x48084a4b in sa_yield ()
    at /usr/src/lib/csu/i386_elf/../common_elf/crti.c:56
  1 Thread 0 ()  0x4805ff92 in pthread__locked_switch ()
    at /usr/src/lib/csu/i386_elf/../common_elf/crti.c:56
(gdb) thread 1
[Switching to thread 1 (Thread 0 ())]
#0  0x4805ff92 in pthread__locked_switch ()
    at /usr/src/lib/csu/i386_elf/../common_elf/crti.c:56
56		INIT_FALLTHRU();
(gdb) bt
#0  0x4805ff92 in pthread__locked_switch ()
    at /usr/src/lib/csu/i386_elf/../common_elf/crti.c:56
#1  0x4806334e in pthread__block (self=0xbfbc0000, queuelock=0x486400b0)
    at /usr/src/lib/libpthread/pthread_run.c:102
#2  0x480665be in pthread_join (thread=0x48640000, valptr=0x0)
    at /usr/src/lib/libpthread/pthread.c:537
#3  0x8048ad9 in main () at simple_thread.c:21
#4  0x8048724 in ___start (argc=1, argv=0xbfbff8b4, envp=0xbfbff8bc, 
    cleanup=0x4804c4e0 <_rtld_exit>, obj=0x48055200,
ps_strings=0xbfbffff0)
    at /usr/src/lib/csu/i386_elf/crt0.c:94
(gdb) thread 2
[Switching to thread 2 (LWP 0)]
#0  0x48084a4b in sa_yield ()
    at /usr/src/lib/csu/i386_elf/../common_elf/crti.c:56
56		INIT_FALLTHRU();
(gdb) bt
#0  0x48084a4b in sa_yield ()
    at /usr/src/lib/csu/i386_elf/../common_elf/crti.c:56
#1  0x48066178 in pthread__idle () at
/usr/src/lib/libpthread/pthread.c:394
(gdb) thread 2 3
[Switching to thread 3 (Thread 21 ())]
#0  0x4805ff92 in pthread__locked_switch ()
    at /usr/src/lib/csu/i386_elf/../common_elf/crti.c:56
56		INIT_FALLTHRU();
(gdb) bt
#0  0x4805ff92 in pthread__locked_switch ()
    at /usr/src/lib/csu/i386_elf/../common_elf/crti.c:56
#1  0x4806334e in pthread__block (self=0x48640000, queuelock=0x48069524)
    at /usr/src/lib/libpthread/pthread_run.c:102
#2  0x4805fd37 in nanosleep (rqtp=0x4867ff88, rmtp=0x4867ff80)
    at /usr/src/lib/libpthread/pthread_sleep.c:123
#3  0x480bc7a0 in _sleep (seconds=1) at /usr/src/lib/libc/gen/sleep.c:61
#4  0x8048a9e in thread_execution (p=0x0) at simple_thread.c:11
#5  0x480660d2 in pthread__create_tramp (start=0x8048a68
<thread_execution>, 
    arg=0x0) at /usr/src/lib/libpthread/pthread.c:356
(gdb) c
Continuing.
Thread counter:0 sleeping
Thread counter:1 sleeping
Thread counter:2 sleeping
Thread counter:3 sleeping
Thread counter:4 sleeping
Thread counter:5 sleeping
Thread counter:6 sleeping
Thread counter:7 sleeping
Thread counter:8 sleeping
Thread counter:9 sleeping
thead has finished
Program exited normally.
(gdb) quit