博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux pstack命令总结
阅读量:7188 次
发布时间:2019-06-29

本文共 2803 字,大约阅读时间需要 9 分钟。

pstack命令用来显示进程的栈跟踪。 pstack 命令必须由相应进程的属主或root账号运行。可以使用pstack来确定进程挂起的位置。此命令只有一个参数,那就是pid,具体关于pstack的介绍可以查看man手册,如下所示:

[root@DB-Server ~]# man pstack
PSTACK(1)                  Linux Programmer’s Manual                 PSTACK(1)
 
NAME
       pstack - print a stack trace of a running process
 
SYNOPSIS
       pstack pid
 
DESCRIPTION
       pstack  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 pstack will print out a stack trace for each of the threads in the group.
 
SEE ALSO
       nm(1), ptrace(2), gdb(1)
 
AUTHORS
       Ross Thompson 
 
       Red Hat, Inc. 
 
Red Hat Linux                     Dec 17 2004                        PSTACK(1)
(END)

例如我们可以使用pstack命令来查看Oracle监听进程的栈跟踪,如下所示

1: 首先找到监听进程的进程号

[oracle@DB-Server~]$ ps -ef | grep lsn
 
oracle 12027 11806 0 11:18 pts/1 00:00:00 grep lsn
 
oracle 31440 1 0 Mar04 ? 00:01:41 /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit

2: 将监听进程的栈跟踪信息写入文件lsn_pstack.log

[oracle@DB-Server~]$ pstack 31440 >> lsn_pstack.log
 
[oracle@DB-Server~]$ pstack 31440 >> lsn_pstack.log
 
[oracle@DB-Server~]$ pstack 31440 >> lsn_pstack.log
 
[oracle@DB-Server~]$

3:如下所示,我们可以看到函数调用关系为:main->nsglma->nsevwait->ntevque->ntevpque->poll.

[oracle@DB-Server~]$ more lsn_pstack.log
#0  0x0000003c7d0cb65f in poll () from /lib64/libc.so.6
#1  0x00007f82c63292e7 in ntevpque () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#2  0x00007f82c6326aab in ntevque () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#3  0x00007f82c62fc81e in nsevwait () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#4  0x00000000004108d9 in nsglma ()
#5  0x0000000000405abd in main ()
#0  0x0000003c7d0cb65f in poll () from /lib64/libc.so.6
#1  0x00007f82c63292e7 in ntevpque () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#2  0x00007f82c6326aab in ntevque () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#3  0x00007f82c62fc81e in nsevwait () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#4  0x00000000004108d9 in nsglma ()
#5  0x0000000000405abd in main ()
#0  0x0000003c7d0cb65f in poll () from /lib64/libc.so.6
#1  0x00007f82c63292e7 in ntevpque () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#2  0x00007f82c6326aab in ntevque () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#3  0x00007f82c62fc81e in nsevwait () from /u01/app/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
#4  0x00000000004108d9 in nsglma ()
#5  0x0000000000405abd in main ()
[oracle@DB-Server~]$

转载地址:http://mkykm.baihongyu.com/

你可能感兴趣的文章
Python知识点总结篇(五)
查看>>
一致性算法探寻(扩展版)1
查看>>
Java中的浅拷贝与深拷贝
查看>>
微信小程序联盟:官方文档+精品教程+demo集合(6月9日更新,持续更新中……)...
查看>>
spring 事务的传播特性
查看>>
react学习(1)-Why React?
查看>>
RESTful风格的API接口开发教程
查看>>
用 Lua 实现一个微型虚拟机-基本篇
查看>>
php 安装 memcached 扩展出现 zlib 错误
查看>>
CentOS中服务程序随系统启动
查看>>
我的友情链接
查看>>
14个Web移动编程视频网站资源分享
查看>>
Linux(CentOS)下安装Dubbo管理控制台(dubbo-admin-2.5.4)
查看>>
rsyslog安装配置
查看>>
Excel写入
查看>>
我的友情链接
查看>>
802.11b网络标准
查看>>
串口编程时,出现Cannot open /dev/ttyS0 Permission denied解决
查看>>
阿里开发者们的第20个感悟:好的工程师为人写代码,而不仅是为编译器
查看>>
linux 磁盘管理
查看>>