Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Jul 2004 12:07:10 +0800
From:      David Xu <davidxu@freebsd.org>
To:        Scott Long <scottl@freebsd.org>
Cc:        cvs-all@freebsd.org
Subject:   Re: cvs commit: src/lib/libthread_db Makefile src/lib/libthread_d b/include         thread_db.h thread_db_int.h src/lib/libthread_db/pthrea d Makefile         pthread_db.c pthread_db.h pthread_db_i386.c         sr c/lib/libthread_db/src Makefile thread_db.c
Message-ID:  <40F602EE.4060103@freebsd.org>
In-Reply-To: <40F5FED0.8050908@freebsd.org>
References:  <40F5FED0.8050908@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Scott Long wrote:
> David Xu wrote:
> 
>>davidxu     2004-07-15 03:36:35 UTC
>>
>>  FreeBSD src repository
>>
>>  Added files:
>>    lib/libthread_db     Makefile 
>>    lib/libthread_db/include thread_db.h thread_db_int.h 
>>    lib/libthread_db/pthread Makefile pthread_db.c pthread_db.h 
>>                             pthread_db_i386.c 
>>    lib/libthread_db/src Makefile thread_db.c 
>>  Log:
>>  Add my initial work of libthread_db. The library is used by gdb to
> 
> debug
> 
>>  threaded process. Current, only libpthread is supported, but macrel
> 
> will
> 
>>  work on it to support libthr and libc_r.
>>  
> 
> 
> This is excellent!  Can you give a quick summary of what one should
> expect from this when using GDB?
> 
When you are debugging a program linked with libpthread, you can
see a list of threads when you type 'info threads', you can
get info about how to debug threaded process by typing 'info gdb'
on command line.

Here is an example:
avidxu@davidbsd:/home/davidxu/ptest> gdb ./crew
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 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 "i386-marcel-freebsd"...
(gdb) break worker_routine
Breakpoint 1 at 0x8048dae: file crew.c, line 73.
(gdb) run node /usr/src/sys
Starting program: /usr/home/davidxu/ptest/crew node /usr/src/sys
setenv SSH_AUTH_SOCK /tmp/ssh-jKcG3qxNRo/agent.1292;
setenv SSH_AGENT_PID 1293;
echo Agent pid 1293;
[Switching to Thread 1 (LWP 100082)]

Breakpoint 1, worker_routine (arg=0xbfbfeab4) at crew.c:73
73          worker_p mine = (worker_t*)arg;
(gdb) info threads
   11 Thread 10 (sleeping)  0x280964d6 in pthread_mutexattr_init () from 
/usr/lib/libpthread.so.1
   10 Thread 9 (LWP 100116)  0x2809e94b in pthread_testcancel () from 
/usr/lib/libpthread.so.1
   9 Thread 8 (runnable)  0x2814b3b0 in _ctx_start () from /lib/libc.so.5
   8 Thread 7 (runnable)  0x2814b3b0 in _ctx_start () from /lib/libc.so.5
   7 Thread 6 (runnable)  0x2814b3b0 in _ctx_start () from /lib/libc.so.5
   6 Thread 5 (runnable)  0x2814b3b0 in _ctx_start () from /lib/libc.so.5
   5 Thread 4 (runnable)  0x2814b3b0 in _ctx_start () from /lib/libc.so.5
   4 Thread 3 (runnable)  0x2814b3b0 in _ctx_start () from /lib/libc.so.5
   3 Thread 2 (runnable)  0x2814b3b0 in _ctx_start () from /lib/libc.so.5
* 2 Thread 1 (LWP 100082)  worker_routine (arg=0xbfbfeab4) at crew.c:73
(gdb)


After I commit source code for gdb, you can do it same as me.

 > Scott
 >

David Xu




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40F602EE.4060103>