utils/gdb: add helper to debug a helper

This commit is contained in:
Philippe Gerum 2020-02-04 10:18:07 +01:00
parent 360156366a
commit 0d8639ceb8
1 changed files with 50 additions and 0 deletions

50
utils/gdb.evl Normal file
View File

@ -0,0 +1,50 @@
#! /bin/sh
# SPDX-License-Identifier: MIT
usage() {
echo >&2 "usage: $(basename $1) <cmd> -- <gdb-args>"
}
args=$(getopt -n $(basename $0) 'h@' "$@")
if [ $? -ne 0 ]; then
usage $0
exit 1
fi
help=false
set -- $(eval echo $args)
for opt
do
case "$opt" in
-h) help=true;
shift;;
-@) echo "debug EVL utility with GDB"
exit 0;;
--) shift; break;;
esac
done
if test x$help = xtrue; then
usage $0
exit 0
fi
if test x$1 = x; then
usage $0
exit 2
fi
program=$EVL_CMDDIR/evl-$1
if test \! -f $program; then
echo >&2 "$(basename $0): cannot find $program"
exit 2
fi
export EVL_CMDDIR
export EVL_TESTDIR
export EVL_SYSDIR
export EVL_TRACEDIR
shift
gdb $program "$@"