签到成功

知道了

CNDBA社区CNDBA社区

linux pstack 命令说明

2016-10-24 21:05 2948 0 原创 Linux
作者: dave


http://www.cndba.cn/dave/article/299

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.

 

http://www.cndba.cn/dave/article/299

 http://www.cndba.cn/dave/article/299http://www.cndba.cn/dave/article/299

根据说明,gstack 会打印出指定pid栈跟踪。可以使用pstack来确定进程挂起的位置。pstack 命令必须由相应进程的属主或root账号运行。该命令只有一个参数,那就是pidhttp://www.cndba.cn/dave/article/299

 http://www.cndba.cn/dave/article/299

http://www.cndba.cn/dave/article/299

通过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 ~]#

 

 http://www.cndba.cn/dave/article/299

 http://www.cndba.cn/dave/article/299http://www.cndba.cn/dave/article/299


版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2261
    原创
  • 3
    翻译
  • 578
    转载
  • 191
    评论
  • 访问:7967493次
  • 积分:4346
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ