linux pstack命令總結,linuxpstack命令

來源:互聯網
上載者:User

linux pstack命令總結,linuxpstack命令

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 <ross@whatsis.com>
 
       Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
 
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~]$ 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.