pstack脚本_pstack

pstack脚本_pstack脚本写入shell文件pstack,直接执行这个脚本pstackpid#!/bin/shiftest$#-ne1;thenecho”Usage:`basename$0.sh`<process-id>”1>&2exit1fiiftest!-r/proc/$1;thenecho”Process$1notfound.”1>&2exit1fi#GDBdoe…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

脚本写入shell文件pstack,直接执行这个脚本

pstack pid

 

#!/bin/sh

if test $# -ne 1; then
    echo “Usage: `basename $0 .sh` <process-id>” 1>&2
    exit 1
fi

if test ! -r /proc/$1; then
    echo “Process $1 not found.” 1>&2
    exit 1
fi

# GDB doesn’t allow “thread apply all bt” when the process isn’t
# threaded; need to peek at the process to determine if that or the
# simpler “bt” should be used.

backtrace=”bt”
if test -d /proc/$1/task ; then
    # Newer kernel; has a task/ directory.
    if test `/bin/ls /proc/$1/task | /usr/bin/wc -l` -gt 1 2>/dev/null ; then
    backtrace=”thread apply all bt”
    fi
elif test -f /proc/$1/maps ; then
    # Older kernel; go by it loading libpthread.
    if /bin/grep -e libpthread /proc/$1/maps > /dev/null 2>&1 ; then
    backtrace=”thread apply all bt”
    fi
fi

GDB=${GDB:-/usr/bin/gdb}

if $GDB -nx –quiet –batch –readnever > /dev/null 2>&1; then
    readnever=–readnever
else
    readnever=
fi

# Run GDB, strip out unwanted noise.
$GDB –quiet $readnever -nx /proc/$1/exe $1 <<EOF 2>&1 | 
set width 0
set height 0
set pagination no
$backtrace
EOF
/bin/sed -n \
    -e ‘s/^\((gdb) \)*//’ \
    -e ‘/^#/p’ \
    -e ‘/^Thread/p’
    

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/193930.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • fastclick.js

    fastclick.js;(function(){‘usestrict’;/***@preserveFastClick:polyfilltoremoveclickdelaysonbrowserswithtouchUIs.**@codingstandardftlabs-jsv2*@copyrightTheFinancia

    2022年6月19日
    22
  • 怎么使用virsh命令_isql命令

    怎么使用virsh命令_isql命令virsh.c中main->vshParseArgv->vshCommandArgvParse->vshCommandParse->vshCmddefSearchintmain(intargc,char**argv){if(!vshParseArgv(ctl,argc,argv)){vshDeinit(ctl);exit(EXIT_FAILURE);}staticboolvshParseA…

    2022年8月11日
    3
  • 【Ubuntu 】Ubuntu 更换国内源—解决终端下载错误或速度慢的问题「建议收藏」

    【Ubuntu 】Ubuntu 更换国内源—解决终端下载错误或速度慢的问题「建议收藏」前言:安装好ubuntu双系统后,默认的软件更新源是国外的,在国内使用速度很慢,用”aptinstallxxx”安装软件时可能出现”网络不可达”、”你的网络需要认证吗”、”无法定位软件包”等错误,所以我们需要更换成国内的源,这样才能正常安装和更新软件。目录一、ubuntu16.04更换国内源二、ubuntu18.04更换国内源三、UbuntuROS更换国内源

    2022年5月14日
    44
  • append函数的用法[通俗易懂]

    append函数的用法[通俗易懂]append()函数类似于尾插就是给元素后面追加一个字符串stringstr;stringstr2=“123”;1.str.append(str2);就是给str后面追加一个str2即输出为123str.strappend(str2,1,1);就是给后面追加上str2中从第二个元素开始连续一个元素1232str.append(“abc”);就是给str后面追加上abc1232abcstr.append(“123456”,6);就是给str后面加上字符串

    2022年6月16日
    50
  • ipset常用命令

    ipset常用命令ipset设置安装#yuminstallipset创建ipset黑名单(黑名单名称为blacklist)#ipsetcreateblacklisthash:iptimeout259200hashsize4096maxelem1000000查看列表#ipsetlistblacklist向黑名单中添加IP/端口#ipsetaddbl…

    2022年10月7日
    0
  • matlab2016a下载包及安装教程

    matlab2016a下载包及安装教程链接:https://pan.baidu.com/s/1wMGK5jYxYdqs1IxRDfJl8A 提取码:y72e 复制这段内容后打开百度网盘手机App,操作更方便哦1 下载R2016a_win64.iso(安装文件,包括part1以及part2两部分,只需解压part1)及Matlab2016aWin64Crack.rar(破解文件),百度云盘的提取地址及密码如上所示2 解…

    2022年5月25日
    41

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号