liangfm117

家里的雪太美了!

直接读取core文件

#!/bin/sh # Description: read corefile return bt stack in text # modified the original `gstack` script if test $# -ne 1; then echo "Usage: `basename $0 .sh` <corefile>" 1>&2 exit 1 fi if test ! -r $1; then echo "corefile $1 not found." 1>&2 exit 1 fi backtrace="bt" GDB=${GDB:-/usr/bin/gdb} # get process name from corefile get_proc_name() { local core_file=$1 proc_name=$(echo $core_file | cut -d '_' -f2- | rev | cut -d '_' -f2- | rev) echo $proc_name } proc_name=$(get_proc_name $1) proc_path=$(readlink -f /proc/$(pgrep -x -u $USER $proc_name | head -1)/exe) if [ -z ${proc_path} ]; then proc_path="$HOME/run/bin/${proc_name}/${proc_name}" fi # Run GDB, strip out unwanted noise. $GDB --quiet -nx $proc_path $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'