Beruflich Dokumente
Kultur Dokumente
/bin/ksh
#
# Usage
#
PROGNAME=$(basename $0)
function Usage {
print "$(basename $0): Automate getting dbx trace information " 1>&2
print "" 1>&2
print "For core files:" 1>&2
print " Usage: $PROGNAME [executable] [core]" 1>&2
print " or : $PROGNAME -c corefile" 1>&2
print " Example: $PROGNAME /usr/jdk_base/bin/aix/native_threads/java core"
1>&2
print " (Please make sure you use the java executable and not the java
script)" 1>&2
print "" 1>&2
print "To attach to a running or hung process" 1>&2
print " Usage: $PROGNAME -a PID" 1>&2
print " Example: $PROGNAME -a 1234" 1>&2
exit -1
}
#
# Parse command lime arguments
#
typeset PID
EXECUTABLE=/usr/jdk_base/bin/aix/native_threads/java
CORE_FILE=core
if [[ $# > 0 ]]
then
if [[ $1 = "-a" ]]
then
if [[ $# -eq 2 ]]
then
PID=$2
else
Usage
fi
elif [[ $1 = "-c" ]]
then
if [[ $# -eq 2 ]]
then
CORE_FILE=$2
else
Usage
fi
else
EXECUTABLE=$1
if [[ $# -eq 2 ]]
then
CORE_FILE=$2
fi
fi
fi
#
# Check command lime arguments
# then set the appropriate dbx commands
#
if [[ $PID. -eq . ]]
then
if [[ ! ( -f $EXECUTABLE ) ]]
then
print "executable file: $EXECUTABLE does not exist" 1>&2
Usage
fi
if [[ ! ( -x $EXECUTABLE ) ]]
then
print "executable file: $EXECUTABLE is not executable" 1>&2
Usage
fi
if [[ ! ( -f $CORE_FILE ) ]]
then
print "core file: $CORE_FILE does not exist" 1>&2
Usage
fi
if [[ $CORE_FILE = core ]]
then
print "******************************************" 1>&2
print "* Failure of this script or dbx may *" 1>&2
print "* overwrite your existing core file. *" 1>&2
print "* It is recomended that you rename your *" 1>&2
print "* existing core file and use the -c flag *" 1>&2
read Y_OR_N?"* Do you wish to continue (y/n): " 1>&2
print "******************************************" 1>&2
if [[ $Y_OR_N. != y. ]] && [[ $Y_OR_N. != Y. ]]
then
exit 0
fi
fi
typeset -r DBX_COMMAND="/usr/bin/dbx $EXECUTABLE $CORE_FILE"
typeset -r DETACH="quit"
else
ps $PID > /dev/null 2>&1
if [[ $? != "0" ]]
then
print "Process ID : $PID does not exist" 1>&2
Usage
fi
typeset -r DBX_COMMAND="/usr/bin/dbx -a $PID"
typeset -r DETACH="detach"
fi
#---------------------------------------------------------
# Prepare a command file to get all the thread information
#---------------------------------------------------------
# $DBX_COMMAND
# ---- Loop from 1 to MAXTHREADS ----
# > thread current THREAD_NUM
# > where
# ----------------------------
# > $DETACH
typeset THREAD_SUB_COMMAND
typeset -r WHERE="where"
typeset -r
DIVIDER="-----------------------------------------------------------------"
rm $COMMAND_FILE
if [[ $? != "0" ]]
then
print "failed to remove $COMMAND_FILE" 1>&2
fi
print "dbx has ended with RC=$?" 1>&2