bloat-buster/debug.sh
2024-08-01 13:23:07 +02:00

32 lines
677 B
Bash
Executable File

#!/bin/bash
set -e
path=$1
if [ "$path" == "" ]
then
echo "error: a valid binary path must be provided to debug"
exit 1
fi
source ./compile.sh
build_dir="build"
exe_name="nest"
exe_path=$build_dir/$exe_name
debug_flags="-g"
optimization_flags="-O0"
bootstrap_args="$path c"
case "$OSTYPE" in
darwin*) static=0;;
linux*) static=1;;
*) echo "unknown: $OSTYPE" ;;
esac
compile $build_dir $exe_name $debug_flags $optimization_flags $static
case "$OSTYPE" in
darwin*) lldb -- $exe_path $bootstrap_args;;
linux*) gf2 -ex "set auto-solib-add off" -ex "r" --args $exe_path $bootstrap_args;;
*) echo "unknown: $OSTYPE" ;;
esac