Skip to content

Instantly share code, notes, and snippets.

@packmad
Created November 9, 2016 14:50
Show Gist options
  • Save packmad/7cc04a957bd5d0bbc5f9bb65ef1126fb to your computer and use it in GitHub Desktop.
Save packmad/7cc04a957bd5d0bbc5f9bb65ef1126fb to your computer and use it in GitHub Desktop.
Wrapper which ensures equal stack offsets
#!/bin/sh
while getopts "dte:h?" opt ; do
case "$opt" in
h|\?)
printf "usage: %s -e KEY=VALUE prog [args...]\n" $(basename $0)
exit 0
;;
t)
tty=1
gdb=1
;;
d)
gdb=1
;;
e)
env=$OPTARG
;;
esac
done
shift $(expr $OPTIND - 1)
prog=$(readlink -f $1)
shift
if [ -n "$gdb" ] ; then
if [ -n "$tty" ]; then
touch /tmp/gdb-debug-pty
exec env - $env TERM=screen PWD=$PWD gdb -tty /tmp/gdb-debug-pty --args $prog "$@"
else
exec env - $env TERM=screen PWD=$PWD gdb --args $prog "$@"
fi
else
exec env - $env TERM=screen PWD=$PWD $prog "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment