#!/bin/sh ## # Quick analyze of core or pid thru GDB # Author: Andrey Zakharov ( aazaharov81( ).at.( )gmail(.dot.)com, vaulter( ).at.( )nm(.dot.)ru ) # 2009-04-17 # 2009-06-17 Improved bunch mode # 2010-03-17 Added handling of pid's # # ID='$Id$' usage() { echo "$0 " } [ -z "$1" ] && usage && exit 1 # globals: BIN= BINDIR= REASON= nTHREADS= ## # Get threads info from running proc # # @param $1 dir # @param $2 bin # @param $3 core | pid # @return nothing # @output gdb output infothreads() { ( if is_integer $3; then gdb -cd="$1" -nx -quiet -batch -command=/dev/stdin "$2" "$3" else gdb -cd="$1" -nx -quiet -batch -command=/dev/stdin "$2" -c "$3" fi )< /dev/null; then # just core from aborted by stopping routine.... # need notify that current timeout is wrong or service was in deadlock? # echo "#[ II ] Just from Aborted `basename $BIN`" # echo -n "#[ ?? ] Sweeping..."; rm -v -i "$1" #else return $? #fi } ## # Checks for integer function is_integer() { printf "%d" $1 > /dev/null 2>&1 return $? } if [ 1 -eq $# ]; then mode=${mode:-1} #numthread "$1" where "$1" else ## bunch of core... #kdialog --yesno "Show about every file sep. info". TODO... atree mode=${mode:-2} for c in $@; do echo -n -e "$c\t" dump="$(gdb -nx -quiet -batch -core="$c")" ds="$(echo "$dump" | head --lines=1)" echo -n -e "$ds\t" echo "$dump\t" | grep "Program terminated with signal" | awk '{ print $5 $6 $7 }' #where "$c" done fi