#!/usr/bin/ksh # Author: Dick.Dunbar@Oracle.com _Version="pstack.sh HPUX v0.3 2012-08-20"; _s="--------" export LANG=C; export LC_ALL=C; [ 'HP-UX' = $(uname -s) ] || { echo "Designed for HPUX ( $_Version )"; exit 1; } _HOST=$(uname -n); _MYID=$(whoami); _gdbC=$(2>&1 which gdb64 | grep -v which:) [ -x $_gdbC ] || _gdbC=/opt/langtools/bin/gdb64 [ -x $_gdbC ] || { echo "Unable to find gdb64. ( $_Version )" ; exit 1; } _gdbV=$($_gdbC --version | head -1) [ -z "$1" ] && { echo "Please provide the core name"; exit 2; } [ -r "$1" ] || { echo "$1 core name is missing." ; exit 3; } _corepath=$1; _core=$( basename $_corepath ); _corefile=$(ls -l $_corepath) _execpath=$(file $_core |sed "s/'//g" |sed -e 's/.*from //' |sed 's/ .*//') _exec=$(basename $_execpath) _pstack=${_core}.${_exec}.pstack; _strings=${_core}.${_exec}.strings; _libs=${_core}.${_exec}.libs; [ -r "$_strings" ] || strings $_corepath|grep '='|grep '^[A-Z]'|egrep -v ' =|= ' |tail -100 > $_strings _coreLIBP=$(grep '^SHLIB_PATH=' $_strings | sed 's/.*=//') _corePATH=$(grep '^PATH=' $_strings | sed 's/.*=//') _cmd() { echo "$_s $*" >> $_pstack; $* 2>&1 >> $_pstack; } _cmd1() { cout=$($*); echo "$_s $* := $cout " >> $_pstack; } _md5() { _P=$1; [ -z "$_P" ] && return _B=$(basename $_P) _md5sum=$(openssl md5 $_P |sed "s/.*)= //" ) echo "$_md5sum $_B" } _find_path() { _P=$1; [ -z "$_P" ] && return IFS=':' for _dir in $_P ; do [ -d $_dir ] && _path=${_dir}/$_exec [ -r $_path ] && return done } _find_path_exec() { [ -r $_execpath ] && return; _execpath='.'$_execpath ; [ -r $_execpath ] && return; _find_path $coreLIBP; [ -r $_execpath ] && return; _find_path $corePATH; [ -r $_execpath ] && return; _find_path $PATH; [ -r $_execpath ] && return; _execpath=$(find . -name $_exec | head -1) ; [ -r $_execpath ] || { echo "Executable $_exec not found."; exit 4; } } _find_path_exec; echo "$_s $_HOST $_MYID $_corepath $_execpath ( $_Version )" > $_pstack; _cmd1 ls -l $_corepath _cmd1 file $_corepath _cmd1 file $_execpath _cmd what /usr/lib/libCsup.2 _cmd1 file $_gdbC echo "$_s env ( from $_core )" >> $_pstack egrep '^_=|HOST|HOME|PATH|ODBC|LOGNAME|USER' $_strings |egrep -v ',|MANP' |sort |sed 's/:/\\`:/g' | tr '`' '\n' >> $_pstack [ -z "$gdbOpts" ] && gdbOpts="-nx -q " # crashes gdb. gdbOpts="$gdbOpts -exec $_execpath -core $_corepath " echo "$_gdbV" >> $_pstack echo "$_s $_gdbC $gdbOpts" >> $_pstack 2>&1 $_gdbC $gdbOpts <<+ \ |egrep -v 'No symbol |^No local|Reading sym|Missing |^Loaded |Symbols already|^Try:|^\(no|\[New LWP| is ' \ |sed 's/(gdb)//g' \ |sed 's/const //g' \ |sed 's/unsigned /u/g' \ |sed 's/\(no debugging symbols found\)\.\.\. //g' \ >> $_pstack set verbose on set verbose off set pagination off echo \n file $_execpath\n file $_execpath echo \n core-file $_corepath\n core-file $_corepath echo \n info registers\n info registers set width 2048 echo \n disassemble \$pc-16*8 \$pc+16*4 \n disassemble \$pc-16*8 \$pc+16*4 echo \n backtrace full\n backtrace full echo \n info frame \n info frame echo \n thread apply all backtrace full\n thread apply all backtrace full echo \n show paths show paths echo \n info target \n info target echo \n info program \n info program echo \n info sharedlibrary \n info sharedlibrary echo \n info files \n info files echo \n show version \n show version quit + _cmd ulimit -a _cmd ulimit -Ha echo "-------- md5sum library" >> $_pstack _md5 $_path >> $_pstack grep '^/' $_pstack |grep -v ':$' |sort |while read _lib; do _md5 $_lib ; done >> $_pstack echo "Please upload file '$_pstack' to Oracle Technical Support "