Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Analysis on the use of pstack Command

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Pstack command usage analysis, for this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

The pstack command displays the stack trace for each process. The pstack command must be run by the owner or root of the corresponding process. You can use pstack to determine where the process is suspended. The only option allowed by this command is the PID of the process to be checked.

Command package download address: https://packages.debian.org/sid/pstack

Example

Pstree displays the process in a tree structure

Pstree-p work | grep ad sshd (22669)-- bash (22670)-- ad_preprocess (4551)-+-{ad_preprocess} (4552) |-{ad_preprocess} (4553) |-{ad_preprocess} (4554) | |-{ad_preprocess} (4555) |-{ad_preprocess} (4556) `- {ad_preprocess} (4557) |

Work is the working user,-p is to display the process identification code, ad_preprocess starts a total of 6 child threads, plus the main thread a total of 7 threads.

Ps-Lf 4551UID PID PPID LWP C NLWP STIME TTY stat time CMDwork 4551 22670 4551 2 7 16:30 pts/2 Sl+ 0:02. / ad_preprocesswork 4551 22670 4552 0 7 16:30 pts/2 Sl+ 0:00. / ad_preprocesswork 4551 22670 4553 07 16:30 pts/2 Sl+ 0:00. / ad_preprocesswork 4551 22670 4554 07 16:30 pts/2 Sl+ 0:00. / ad_preprocesswork 4551 22670 4555 0 7 16:30 pts/2 Sl+ 0:00. / ad_preprocesswork 4551 22670 4556 0 7 16:30 pts/2 Sl+ 0:00. / ad_preprocesswork 4551 22670 4557 0 7 16:30 pts/2 Sl+ 0:00. / ad_preprocess

The process started a total of 7 threads

Pstack displays the stack trace for each process:

Pstack 4551Thread 7 (Thread 1084229984 (LWP 4552)): # 0 0x000000302afc63dc in epoll_wait () from / lib64/tls/libc.so.6#1 0x00000000006f0730 in ub::EPollEx::poll () # 2 0x00000000006f172a in ub::NetReactor::callback () # 3 0x00000000006fbbbb in ub::UBTask::CALLBACK () # 4 0x000000302b80610a in start_thread () from / lib64/tls/libpthread.so.0#5 0x000000302afc6003 in clone () from / lib64/tls/libc.so.6#6 0x0000000000000000 in?? Thread 6 (Thread 1094719840 (LWP 4553): # 0 0x000000302afc63dc in epoll_wait () from / lib64/tls/libc.so.6#1 0x00000000006f0730 in ub::EPollEx::poll () # 2 0x00000000006f172a in ub::NetReactor::callback () # 30 x00000000006fbbbb in ub::UBTask::CALLBACK () # 4 0x000000302b80610a in start_thread () from / lib64/tls/libpthread.so.0#5 0x000000302afc6003 in clone () from / lib64/tls/libc.so.6#6 0x0000000000000000 in? () Thread 5 (Thread 1105209696 (LWP 4554): # 0 0x000000302b80baa5 in _ nanosleep_nocancel () # 1 0x000000000079e758 in comcm::ms_sleep () # 2 0x00000000006c8581 in ub::UbClientManager::healthyCheck () # 3 0x00000000006c8471 in ub::UbClientManager::start_healthy_check () # 4 0x000000302b80610a in start_thread () from / lib64/tls/libpthread.so.0#5 0x000000302afc6003 in clone () from / lib64/tls/libc.so.6#6 0x0000000000000000 in? () Thread 4 (Thread 1115699552 (LWP 4555)): # 0 0x000000302b80baa5 In _ _ nanosleep_nocancel () # 1 0x0000000000482b0e in armor::armor_check_thread () # 2 0x000000302b80610a in start_thread () from / lib64/tls/libpthread.so.0#3 0x000000302afc6003 in clone () from / lib64/tls/libc.so.6#4 0x0000000000000000 in? () Thread 3 (Thread 1126189408 (LWP 4556)): # 0 0x000000302af8f1a5 in _ nanosleep_nocancel () from / lib64/tls/libc.so.6#1 0x000000302af8f010 in sleep () from / lib64/tls/libc.so.6 # 2 0x000000000044c972 in Business_config_manager::run () # 3 0x0000000000457b83 in Thread::run_thread () # 4 0x000000302b80610a in start_thread () from / lib64/tls/libpthread.so.0#5 0x000000302afc6003 in clone () from / lib64/tls/libc.so.6#6 0x0000000000000000 in? () Thread 2 (Thread 1136679264 (LWP 4557)): # 0 0x000000302af8f1a5 in _ nanosleep_nocancel () from / lib64/tls/libc.so.6#1 0x000000302af8f010 in sleep () from / lib64/tls/libc .so.6 # 2 0x00000000004524bb in Process_thread::sleep_period () # 3 0x0000000000452641 in Process_thread::run () # 4 0x0000000000457b83 in Thread::run_thread () # 5 0x000000302b80610a in start_thread () from / lib64/tls/libpthread.so.0#6 0x000000302afc6003 in clone () from / lib64/tls/libc.so.6#7 0x0000000000000000 in? () Thread 1 (Thread 182894129792 (LWP 4551)): # 0 0x000000302af8f1a5 in _ nanosleep_nocancel () from / lib64/tls/libc.so .6 answer 1 0x000000302af8f010 in sleep () from / lib64/tls/libc.so.6#2 0x0000000000420d79 in Ad_preprocess::run () # 3 0x0000000000450ad0 in main () the answer to the question about the usage analysis of the pstack command is shared here. I hope the above content can help you to a certain extent, if you still have a lot of doubts to be solved, you can follow the industry information channel to learn more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report