1 查看MAN 帮助
NAME gstack - print a stack trace of a running process SYNOPSIS gstack pid DESCRIPTION gstack attaches to the active process named by the pid on the command line, and prints out an execution stack trace. If ELF symbols exist in the binary (usually the case unless you have run strip(1)), then symbolic addresses are printed as well. If the process is part of a thread group, then gstack will print out a stack trace for each of the threads in the group.
根据说明,gstack 会打印出指定pid的栈跟踪。可以使用pstack来确定进程挂起的位置。pstack 命令必须由相应进程的属主或root账号运行。该命令只有一个参数,那就是pid。
通过pstack可以实现:
1). 查看线程数(比pstree, 包含了详细的堆栈信息)
2). 能简单验证是否按照预定的调用顺序/调用栈执行
3). 采用高频率多次采样使用时, 能发现程序当前的阻塞在哪里, 以及性能消耗点在哪里?
4). 能反映出疑似的死锁现象(多个线程同时在wait lock, 具体需要进一步验证)
2 示例
[root@cndba.cn ~]# ps -ef|grep lgwr oracle 3441 1 0 13:41 ? 00:00:00 ora_lgwr_cndba root 5247 5077 0 16:45 pts/1 00:00:00 grep lgwr [root@cndba.cn ~]# pstack 3441 #0 0x00000034abaeb02a in semtimedop () from /lib64/libc.so.6 #1 0x000000000cda833d in sskgpwwait () #2 0x000000000cda5ca8 in skgpwwait () #3 0x000000000c8f2bbb in ksliwat () #4 0x000000000c8f1fc1 in kslwaitctx () #5 0x0000000000c4324c in kslwait () #6 0x0000000002e4e854 in ksarcv () #7 0x0000000002e4ff38 in ksbabs () #8 0x0000000002e6669c in ksbrdp () #9 0x00000000031016f0 in opirip () #10 0x0000000001bb0a18 in opidrv () #11 0x00000000026c0f81 in sou2o () #12 0x0000000000bbd86e in opimai_real () #13 0x00000000026cb6cc in ssthrdmain () #14 0x0000000000bbd73c in main () [root@cndba.cn ~]#
版权声明:本文为博主原创文章,未经博主允许不得转载。