musique/scripts/log-function-calls.sh
Robert Bendun b06ad84514 File hierarchy cleanup by removing etc folder
And moving it's content into scripts and editor directories.
2022-08-18 23:03:21 +02:00

37 lines
693 B
Bash
Executable File

#!/usr/bin/env bash
# Inspired by https://dustymabe.com/2012/12/17/trace-function-calls-using-gdb-revisited/
set -e -o pipefail
if ! command -v gdb >/dev/null; then
echo "$(basename "$1"): error: GDB is required for this script to work" 1>&2
exit 1
fi
if [ ! -d src ]; then
echo "$(basename "$1"): error: Expected directory 'src' in working directory" 1>&2
exit 1
fi
tempfile=$(mktemp "${TMPDIR:-/tmp/}$(basename $0).XXXX")
echo "set confirm off" > $tempfile
for src in src/*.cc; do
echo "rbreak $src:.
command
silent
backtrace 1
continue
end" >> $tempfile
done
echo "run $@" >> $tempfile
set -x
make debug
gdb -quiet -batch -x "$tempfile" bin/musique
set +x
rm "$tempfile"