#!/bin/sh # # Usage # dbgvmkdrv {serial_port} [--break] [gdb_options] # dbgvmkdrv {core_file} [gdb_options] # # Optionally # The environment variable 'VMKERNEL_IMAGE' specifies the # VMkernel debug symbol image file. # The environment variable 'MODULE_DIRS' specifies the # directories that locates VMkernel module symbol files. # The directories are separated by colon (:). # PATH="/bin:/usr/bin" GDBINIT_CMD=/tmp/.gdbinit.$$ # Top directory for debug tools DEBUG_DIR="`dirname $0`" DEBUG_DIR=`cd ${DEBUG_DIR};pwd` VMKGDB=$DEBUG_DIR/gdb-wrapper GDBMACROS_DIR=$DEBUG_DIR/gdbmacros GDB_DIR=$DEBUG_DIR/gdb if [ -z "$VMK_MODE" ] then if [ -d "$DEBUG_DIR/beta" ] then VMK_MODE=beta elif [ -d "$DEBUG_DIR/release" ] then VMK_MODE=release fi fi if [ -z "$VMKERNEL_IMAGE" ] then VMKERNEL_IMAGE=$DEBUG_DIR/$VMK_MODE/vmkernel-visor fi if [ ! -f "$VMKERNEL_IMAGE" ] then echo "Cannot find VMkernel image file: $VMKERNEL_IMAGE" exit 1 fi if [ -z "$MODULE_DIRS" ] then MODULE_DIRS=$DEBUG_DIR/debug if [ -n "$VMK_MODE" ] then MODULE_DIRS="$DEBUG_DIR/$VMK_MODE:$MODULE_DIRS" fi fi if [ -z "$SRC_TOP" ] then case $DEBUG_DIR in /opt/vmware/ddk*) SRC_TOP=${DEBUG_DIR}/../src; SRC_TOP=`cd $SRC_TOP; pwd` ;; /opt/vmware/nativeddk*) SRC_TOP=${DEBUG_DIR}/../src SRC_TOP=`cd $SRC_TOP; pwd` ;; /opt/vmware/kmdk*) DIRS= for f in `echo ${DEBUG_DIR}/../samples/*` do if [ -d $f ] then DIRS=${DIRS}:`cd $f;pwd` fi done SRC_TOP=${DIRS#:} ;; esac fi COM= CORE= NET= case $1 in "") COM=/dev/ttyS0 ;; /dev/*) COM=$1; shift ;; -*) COM=/dev/ttyS0 ;; tcp:*) NET=$1; shift ;; udp:*) NET=$1: shift ;; *) CORE=$1; shift ;; esac if [ -n "$CORE" ] then if [ ! -f "$CORE" ] then echo "Cannot find core file: $CORE" exit 1 fi fi if [ -n "$COM" ] then if [ ! -c "$COM" ] then echo "$COM does not exist or is not a char device." exit 1 fi if [ ! -w "$COM" ] then echo "$COM is not writable." exit 1 fi fi if [ -n "$NET" ] then COM=$NET fi # # Generate GDB init command script # cat <$GDBINIT_CMD set solib-search-path $MODULE_DIRS directory $SRC_TOP EOF # Produce remote connection commands if [ -n "$COM" ] then cat <>$GDBINIT_CMD set serial baud 115200 set remote read-aux-vector-packet on target remote $COM set print thread-events off EOF fi # Produce source gdb macro lines echo "source $GDB_DIR/gdb-vmk" >>$GDBINIT_CMD for f in `ls $GDBMACROS_DIR/*.gdb` do echo "source $f" >>$GDBINIT_CMD done # Cleanup gdb command script if [ -z "$KEEP_GDBINIT_CMD" ] then echo "shell rm $GDBINIT_CMD" >>$GDBINIT_CMD fi # Run gdb if [ -n "$CORE" ] then exec $VMKGDB $@ -q -x $GDBINIT_CMD $VMKERNEL_IMAGE $CORE else exec $VMKGDB $@ -q -x $GDBINIT_CMD $BREAK $VMKERNEL_IMAGE fi