linux 显示每个进程的栈跟踪 命令:pstack

pstack命令可显示每个进程的栈跟踪。pstack 命令必须由相应进程的属主或 root 运行。可以使用 pstack 来确定进程挂起的位置。此命令允许使用的唯一选项是要检查的进程的 PID。

 

命令软件包下载地址:https://packages.debian.org/sid/pstack

 

实例

pstree以树结构显示进程

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为工作用户,-p为显示进程识别码,ad_preprocess共启动了6个子线程,加上主线程共7个线程。

ps -Lf 4551

UID PID PPID LWP C NLWP STIME TTY stat time CMD

work 4551 22670 4551 2 7 16:30 pts/2 Sl+ 0:02 ./ad_preprocess

work 4551 22670 4552 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess

work 4551 22670 4553 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess

work 4551 22670 4554 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess

work 4551 22670 4555 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess

work 4551 22670 4556 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess

work 4551 22670 4557 0 7 16:30 pts/2 Sl+ 0:00 ./ad_preprocess

 

进程共启动了7个线程

 

pstack显示每个进程的栈跟踪:

pstack 4551

Thread 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 ()

#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 ?? ()

.......省略......

付杰
PowerDesigner数据库设计与建模
  • ¥ 58元
  • 市场价:58元
Python数据分析与机器学习实战
  • ¥ 398.0元
  • 市场价:498.0元
微信小程序前后端全栈开发 (Node.js+Express)
  • ¥ 39.0元
  • 市场价:39.0元
服务器管理面板/主机控制面板“安装”服务
服务器管理面板/主机控制面板“安装”服务
  • ¥ 49.9元
  • 市场价:99.9元

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: