#!/bin/sh # Copyright 2015 VMware, Inc. All rights reserved. -- VMware Confidential usage () { echo 'Usage : esxgdb -e ' echo ' where is where you want to debug/test' exit } if [ "$#" -ne 2 ] then usage fi echo 'The purpose of this shell script is to install/copy all the required gdb ' echo 'files to the desired ESX host to enable ESX debugging. After this script ' echo 'finishes, login to the ESX host and execute the shell script ' echo echo '/tmp/gdbDir/esxgdb-wrapper' echo echo 'to start debugging. Note: while this script runs, you will be asked for the root ' echo 'password of the target ESX host several times while attempting to work on top of ' echo 'scp and ssh.' while [ "$1" != "" ]; do case $1 in -e ) shift ESX_HOST=$1 ;; * ) usage esac shift done CAYMAN_ESX_GDB_ROOT=`/bin/rpm -q --qf '%{INSTPREFIXES}\n' \ vmware-esx-cayman_esx_gdb-1af75dbb095cc2348c35c6708c8b326ac1661974-toolchain` CAYMAN_PYTHON_ROOT=$(/bin/rpm -q --qf '%{INSTPREFIXES}\n' \ vmware-esx-cayman_python-99788ba0a9e40ea80ae7b05efb941377abfb31e4-toolchain) CAYMAN_ESX_NCURSES_ROOT=$(/bin/rpm -q --qf '%{INSTPREFIXES}\n' \ vmware-esx-cayman_esx_ncurses-9bf45330b538505c6325906c08c4ecf834184b5c-toolchain) SCRATCHDIR=/tmp/scratchDir ESX_GDB_WRAPPER_SCRIPT=esx-gdb-wrapper mkdir -p ${SCRATCHDIR}/{python,ncurses-lib64,esxgdb} STARTDIR=$(pwd) if [ ! -d "${CAYMAN_ESX_GDB_ROOT}/esx64-cayman/usr" -o \ ! -d "${CAYMAN_ESX_NCURSES_ROOT}/usr/lib64" -o \ ! -d "${CAYMAN_PYTHON_ROOT}/esx64-cayman" ]; then echo 'One of the required cayman components was not installed correctly.' echo 'Exiting due to error ...' exit 1 fi mkdir -p ${SCRATCHDIR}/esxgdb/{bin,share} cp -r ${CAYMAN_ESX_GDB_ROOT}/esx64-cayman/usr/bin/gdb ${SCRATCHDIR}/esxgdb/bin/ cp -r ${CAYMAN_ESX_GDB_ROOT}/esx64-cayman/usr/share/* ${SCRATCHDIR}/esxgdb/share/ cp -r ${CAYMAN_ESX_NCURSES_ROOT}/usr/lib64/*.so* ${SCRATCHDIR}/ncurses-lib64/ cp -r ${CAYMAN_PYTHON_ROOT}/esx64-cayman/{bin,lib,share} ${SCRATCHDIR}/python/ tar cf - -C ${SCRATCHDIR} esxgdb ncurses-lib64 python \ -C ${STARTDIR}/vmkernel-gdb ${ESX_GDB_WRAPPER_SCRIPT} | \ ssh root@${ESX_HOST} mkdir -p /tmp/gdbDir \; cd /tmp/gdbDir \; tar xf - if [ $? -ne 0 ]; then echo 'The esx gdb files could not be copied over to the target esx host.' echo 'Exiting due to error ...' exit 1 fi echo echo echo 'This script executed successfully' echo 'To start debugging, login to the target ESX host and ' echo 'run /tmp/gdbDir/esx-gdb-wrapper'