Files
graphene/Runtime/pal_loader
Michał Kowalczyk 19b8dee8ee pal_loader: Disable the annoying GDB banner
Because GDB is awesome this isn't actually configurable in .gdbinit (or
at least I couldn't find any way to do this) and we need to fix it via
the commandline.
2020-04-25 02:14:31 +02:00

97 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
while :
do
case "$1" in
"SGX")
SGX=1
export SGX
;;
"GDB")
GDB=1
;;
*)
break
;;
esac
shift
done
RUNTIME_DIR=$(/usr/bin/dirname "$(readlink -f "${BASH_SOURCE[0]}")")
if [ -z "$PAL_HOST" ]; then
if [ ! -f /usr/bin/make ]; then
libpal="$RUNTIME_DIR/libpal-*.so"
libpal="$(echo -n "$libpal")"
libpal="${libpal//$RUNTIME_DIR\//}"
if [ "$libpal" = 'libpal-*.so' ]; then
echo "Unable to detect PAL_HOST. Please install the make program."
exit 1
fi
array=("$libpal")
if [ ${#array[@]} -ne 1 ]; then
echo "Multiple libpal detected ($libpal). Please explicitly set the environment variable PAL_HOST."
exit 1
fi
PAL_HOST="${libpal%.so}"
PAL_HOST="${PAL_HOST#libpal-}"
else
PAL_HOST=$(/usr/bin/make --no-print-directory --quiet -f "$RUNTIME_DIR/../Scripts/Makefile.configs" print_host 2>&1)
fi
fi
MANIFEST=
PREFIX=()
PAL_CMD=$RUNTIME_DIR/pal-$PAL_HOST
if [ "$GDB" == "1" ]; then
GDB=$RUNTIME_DIR/pal_gdb-$PAL_HOST
if [ ! -f "$GDB" ]; then
GDB="/usr/bin/gdb"
fi
fi
if [ "$GDB" != "" ] && [ "$GDB" != "0" ]; then
PREFIX=("$GDB" -q)
if [ -n "$INSIDE_EMACS" ]; then
PREFIX+=("-i=mi")
fi
PREFIX+=("--args")
fi
if [ "$PERF" == "1" ]; then
PREFIX=(perf stat)
fi
if [ "$MEMUSG" == "1" ]; then
PREFIX=("$RUNTIME_DIR/../Scripts/memusg")
fi
while [ "$1" != "" ];
do
if [ "$MANIFEST" == "" ]; then
MANIFEST=$1
shift
continue
fi
break
done
if [ "$MANIFEST" == "" ]; then
echo "Usage: $0 [<executable_path>|<manifest_path>] <args>..."
exit 1
fi
if [ ! -f "$PAL_CMD" ]; then
echo "$PAL_CMD is not built"
exit 1
fi
if [ ${#PREFIX[@]} -eq 0 ]; then
exec "$PAL_CMD" init "$MANIFEST" "$@"
else
exec "${PREFIX[@]}" "$PAL_CMD" init "$MANIFEST" "$@"
fi