#!/bin/sh # File: crash.sh # Author: Dominic J. Eidson # Created: May 15th, 1999 # Last Modified: May 19th, 1999 # Description: Script to do core file analysis - crash.sh -h for more info # Init time. TEMP_FILE="/tmp/`basename ${0}`.${$}" # Temp file INFO="no" # Weather you want "info locals" LIST="no" # Weather you want "list" HELP="no" # Show help or not. # Trap signals - clean up after exit. trap 'rm -f ${TEMP_FILE}' 0 1 2 6 9 11 13 15 # check options list. set -- `getopt hil $* 2>/dev/null` if [ ${?} -ne 0 ] then echo "USAGE: `basename ${0}` [-h] [-i] [-l] binary_file core_file" exit 1 fi for i do case "$i" in -h) HELP="yes"; shift;; -i) INFO="yes"; shift;; -l) LIST="yes"; shift;; esac done # Get rid of "--" shift if [ "${HELP}" = "yes" ] ; then cat << EOF USAGE: `basename ${0}` [-h] [-i] [-l] binary_file core_file Options: -h This screen. -i Includes the output from "info locals" for each frame. -l Includes the output from "list" for each frame. Copyright 1999, Dominic J. Eidson EOF exit 1 fi # Do we have enough files? if [ ${#} -ne 2 ] then echo "USAGE: `basename ${0}` [-h] [-i] [-l] binary_file core_file" exit 1 fi # No check for whether files exist or not - yet. # Create a temp script to run with GDB echo "bt" > ${TEMP_FILE} for gdb_frame in `echo 'backtrace' | eval gdb ${1} ${2} 2> /dev/null | grep '^#' | awk '{print $1}' | cut -c2-10` do echo "echo ==> FRAME $gdb_frame\\n" >> ${TEMP_FILE} echo "frame $gdb_frame" >> ${TEMP_FILE} if [ "${LIST}" = "yes" ] ; then echo "echo -> list\\n" >> ${TEMP_FILE} echo "list" >> ${TEMP_FILE} fi if [ "${INFO}" = "yes" ] ; then echo "echo -> info locals\\n" >> ${TEMP_FILE} echo "info locals" >> ${TEMP_FILE} fi done # Run GDB a second time. eval gdb -batch -x ${TEMP_FILE} ${1} ${2}