FAQ
Thread process debugging방법
분류 OS/UNIX 명령어 등록일 2013-07-09 조회수 7404
hwon 2004-02-17 189


Thread process debugging방법
++++++++++++++++++++++++++++

개요
++++
Unix process Debugging방법들이 Utility마다 틀리고 Unix별로도 조금씩 차이가 나기
때문
에 command가 혼동되는 경우가 많습니다. 이 Tech Note에서는 간단한 Command위주로

Thread Stack을 보는 방법을 제공합니다.


/usr/proc/bin/pstack 이용
++++++++++++++++++++++++++

SUN과 기타 몇개의 Unix, Linux에서 제공하는 Utility로서 Running중인 Process의
Call
Stack을 Thread별로 볼수 있는 아주 유용한 Command입니다. DB Hang일때 돌리면 돌리
면 됩
니다.
ex> /usr/proc/bin/pstack 11068 ; 11068이 process pid


dbx를 이용
+++++++++++

1. Running중인 Process에 Attach해서 Thread별 Stack확인.
$dbx $ALTIBASE_HOME/bin/altibase
dbx>threads ; 모든 thread들의 정보를 확인.
dbx>thread t@1 ; 1번 thread로 switch
dbx>where ; 1번 thread의 stack 츨력

2. Core file에서 Thread별 Stack확인.
$dbx $ALTIBASE_HOME/bin/altibase core
dbx>threads ; 모든 thread들의 정보를 확인.
dbx>thread t@1 ; 1번 thread로 switch
dbx>where ; 1번 thread의 stack 출력

3. Zombie Thread까지 모두 출력 : dbx> threads -all


gdb를 이용
++++++++++

$gdb $ALTIBASE_HOME/bin/altibase
gdb> info threads
42 Thread 31 (LWP 4) 0x329614 in _poll ()
41 Thread 30 0x300cf8 in _lwp_sema_wait ()
40 Thread 29 0x300cf8 in _lwp_sema_wait ()
39 Thread 28 (LWP 29) 0x329614 in _poll ()
38 Thread 27 (LWP 28) 0x329614 in _poll ()
37 Thread 26 (LWP 27) 0x329614 in _poll ()
36 Thread 25 (LWP 26) 0x329614 in _poll ()
5 LWP 28 0x329614 in _poll ()
4 LWP 29 0x329614 in _poll ()
3 LWP 30 0x300cf8 in _lwp_sema_wait ()
* 2 Thread 1 (LWP 1) 0x329614 in _poll ()
1 LWP 1 0x329614 in _poll ()

gdb> thread apply all bt ; 모든 thread의 stack trace를 출력
Thread 2 (Thread 1 (LWP 1)):
#0 0x329614 in _poll ()
#1 0x2f2548 in select_large_fdset ()
#2 0x286908 in __1cKidcManagerGselect6FpnGfd_set_pnOPDL_Time_Value__i_ ()
#3 0x978d8 in __1cMmmtThreadMgrIDispatch6M_nGIDE_RC__ ()
#4 0x945f4 in __1cGmmiMgrIMainLoop6F_nGIDE_RC__ ()
#5 0x929e0 in main ()

Thread 1 (LWP 1 ):
#0 0x329614 in _poll ()
#1 0x2f2548 in select_large_fdset ()
#2 0x286908 in __1cKidcManagerGselect6FpnGfd_set_pnOPDL_Time_Value__i_ ()
#3 0x978d8 in __1cMmmtThreadMgrIDispatch6M_nGIDE_RC__ ()
---Type to continue, or q to quit---
#4 0x945f4 in __1cGmmiMgrIMainLoop6F_nGIDE_RC__ ()
#5 0x929e0 in main ()
#0 0x329614 in _poll ()

gdb> t 1 ; 1번 thread로 switch
gdb> bt ; stack출력
gdb> quit


AIX 에서 dbx사용하는 방법.
+++++++++++++++++++++++++++++

$dbx -a $ALTIBASE_HOME/bin/altibase
thread
thread state-k wchan state-u k-tid mode held scope
function
$t1 wait running 24781 k no sys select
(fd_set*,PDL_Time_Value*)
>$t2 run blocked 21941 k no
sys
$t3 wait 0x00000000ea002ca0 blocked 23029 k no sys
_event_wait
$t4 wait running 23747 k no sys run
()
$t5 wait running 9059 k no sys run
()
$t6 wait running 24285 k no sys run
()
$t7 wait running 24001 k no sys run
()
$t8 wait running 25285 k no sys run
()
$t9 wait running 25543 k no sys run
()
$t10 wait 0x00000000ea003220 blocked 25801 k no sys
_event_wait
$t17 wait running 27607 k no sys run
()
$t18 wait running 27865 k no sys run
()
$t19 wait running 28123 k no sys run
()
$t20 wait running 28381 k no sys run
()
$t21 wait running 28639 k no sys run
()
$t22 wait running 28897 k no sys run
()
$t23 wait 0x00000000ea0038a0 blocked 29155 k no sys
_event_wait
$t24 zomb terminated 29413 k no sys
_pthread_body

thread current 1
where
detach all
quit <== 반드시 quit로 나와야 한다. 그렇지 않으면 process가 죽는다.

목록