UNPKG

4.6 kBMarkdownView Raw
1pstack
2===
3
4显示每个进程的栈跟踪
5
6## 补充说明
7
8**pstack命令** 可显示每个进程的栈跟踪。<kbd>pstack</kbd> 命令必须由相应进程的属主或 <tt>root</tt> 运行。可以使用 <kbd>pstack</kbd> 来确定进程挂起的位置。此命令允许使用的唯一选项是要检查的进程的 <tt>PID</tt>
9
10命令软件包下载地址:https://packages.debian.org/sid/pstack
11
12### 实例
13
14pstree以树结构显示进程
15
16```shell
17pstree -p work | grep ad
18sshd(22669)---bash(22670)---ad_preprocess(4551)-+-{ad_preprocess}(4552)
19 |-{ad_preprocess}(4553)
20 |-{ad_preprocess}(4554)
21 |-{ad_preprocess}(4555)
22 |-{ad_preprocess}(4556)
23 `-{ad_preprocess}(4557)
24```
25
26work为工作用户,-p为显示进程识别码,ad_preprocess共启动了6个子线程,加上主线程共7个线程。
27
28```shell
29ps -Lf 4551
30UID PID PPID LWP C NLWP STIME TTY stat time CMD
31work 4551 22670 4551 2 7 16:30 pts/2 Sl+ 0:02 ./ad_preprocess
32work 4551 22670 4552 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess
33work 4551 22670 4553 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess
34work 4551 22670 4554 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess
35work 4551 22670 4555 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess
36work 4551 22670 4556 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess
37work 4551 22670 4557 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess
38```
39
40进程共启动了7个线程
41
42pstack显示每个进程的栈跟踪:
43
44```shell
45pstack 4551
46Thread 7 (Thread 1084229984 (LWP 4552)):
47#0 0x000000302afc63dc in epoll_wait () from /lib64/tls/libc.so.6
48#1 0x00000000006f0730 in ub::EPollEx::poll ()
49#2 0x00000000006f172a in ub::NetReactor::callback ()
50#3 0x00000000006fbbbb in ub::UBTask::CALLBACK ()
51#4 0x000000302b80610a in start_thread () from /lib64/tls/libpthread.so.0
52#5 0x000000302afc6003 in clone () from /lib64/tls/libc.so.6
53#6 0x0000000000000000 in ?? ()
54Thread 6 (Thread 1094719840 (LWP 4553)):
55#0 0x000000302afc63dc in epoll_wait () from /lib64/tls/libc.so.6
56#1 0x00000000006f0730 in ub::EPollEx::poll ()
57#2 0x00000000006f172a in ub::NetReactor::callback ()
58#3 0x00000000006fbbbb in ub::UBTask::CALLBACK ()
59#4 0x000000302b80610a in start_thread () from /lib64/tls/libpthread.so.0
60#5 0x000000302afc6003 in clone () from /lib64/tls/libc.so.6
61#6 0x0000000000000000 in ?? ()
62Thread 5 (Thread 1105209696 (LWP 4554)):
63#0 0x000000302b80baa5 in __nanosleep_nocancel ()
64#1 0x000000000079e758 in comcm::ms_sleep ()
65#2 0x00000000006c8581 in ub::UbClientManager::healthyCheck ()
66#3 0x00000000006c8471 in ub::UbClientManager::start_healthy_check ()
67#4 0x000000302b80610a in start_thread () from /lib64/tls/libpthread.so.0
68#5 0x000000302afc6003 in clone () from /lib64/tls/libc.so.6
69#6 0x0000000000000000 in ?? ()
70Thread 4 (Thread 1115699552 (LWP 4555)):
71#0 0x000000302b80baa5 in __nanosleep_nocancel ()
72#1 0x0000000000482b0e in armor::armor_check_thread ()
73#2 0x000000302b80610a in start_thread () from /lib64/tls/libpthread.so.0
74#3 0x000000302afc6003 in clone () from /lib64/tls/libc.so.6
75#4 0x0000000000000000 in ?? ()
76Thread 3 (Thread 1126189408 (LWP 4556)):
77#0 0x000000302af8f1a5 in __nanosleep_nocancel () from /lib64/tls/libc.so.6
78#1 0x000000302af8f010 in sleep () from /lib64/tls/libc.so.6
79#2 0x000000000044c972 in Business_config_manager::run ()
80#3 0x0000000000457b83 in Thread::run_thread ()
81#4 0x000000302b80610a in start_thread () from /lib64/tls/libpthread.so.0
82#5 0x000000302afc6003 in clone () from /lib64/tls/libc.so.6
83#6 0x0000000000000000 in ?? ()
84Thread 2 (Thread 1136679264 (LWP 4557)):
85#0 0x000000302af8f1a5 in __nanosleep_nocancel () from /lib64/tls/libc.so.6
86#1 0x000000302af8f010 in sleep () from /lib64/tls/libc.so.6
87#2 0x00000000004524bb in Process_thread::sleep_period ()
88#3 0x0000000000452641 in Process_thread::run ()
89#4 0x0000000000457b83 in Thread::run_thread ()
90#5 0x000000302b80610a in start_thread () from /lib64/tls/libpthread.so.0
91#6 0x000000302afc6003 in clone () from /lib64/tls/libc.so.6
92#7 0x0000000000000000 in ?? ()
93Thread 1 (Thread 182894129792 (LWP 4551)):
94#0 0x000000302af8f1a5 in __nanosleep_nocancel () from /lib64/tls/libc.so.6
95#1 0x000000302af8f010 in sleep () from /lib64/tls/libc.so.6
96#2 0x0000000000420d79 in Ad_preprocess::run ()
97#3 0x0000000000450ad0 in main ()
98```
99
100