diff --git a/package/linux/dfhack b/package/linux/dfhack index 68de25245..008f691cf 100755 --- a/package/linux/dfhack +++ b/package/linux/dfhack @@ -68,12 +68,37 @@ setarch_arch=$(cat hack/dfhack_setarch.txt || printf i386) case "$1" in -g | --gdb) shift + echo "set exec-wrapper env LD_LIBRARY_PATH='$LD_LIBRARY_PATH' LD_PRELOAD='$PRELOAD_LIB' MALLOC_PERTURB_=45" > gdbcmd.tmp + gdb $DF_GDB_OPTS -x gdbcmd.tmp --args ./libs/Dwarf_Fortress "$@" + rm gdbcmd.tmp + ret=$? + ;; + -r | --remotegdb) + shift + if [ "$#" -gt 0 ]; then + echo "****" + echo "gdbserver doesn't support spaces in arguments." + echo "If your world gen name has spaces you need to remove spaces from the name in data/init/world_gen.txt" + echo "****" + fi echo "set environment LD_LIBRARY_PATH $LD_LIBRARY_PATH" > gdbcmd.tmp echo "set environment LD_PRELOAD $PRELOAD_LIB" >> gdbcmd.tmp echo "set environment MALLOC_PERTURB_ 45" >> gdbcmd.tmp echo "set startup-with-shell off" >> gdbcmd.tmp - gdb $DF_GDB_OPTS -x gdbcmd.tmp ./libs/Dwarf_Fortress "$@" - rm gdbcmd.tmp + echo "target extended-remote localhost:12345" >> gdbcmd.tmp + echo "set remote exec-file ./libs/Dwarf_Fortress" >> gdbcmd.tmp + # For some reason gdb ignores sysroot setting if it is from same file as + # target extended-remote command + echo "set sysroot /" > gdbcmd_sysroot.tmp + gdb $DF_GDB_OPTS -x gdbcmd.tmp -x gdbcmd_sysroot.tmp --args ./libs/Dwarf_Fortress "$@" + rm gdbcmd.tmp gdbcmd_sysroot.tmp + ret=$? + ;; + -s | --gdbserver) # -s for server + shift + echo "Starting gdbserver in multi mode." + echo "To exit the gdbserver you can enter 'monitor exit' command to gdb or use kill signal" + gdbserver --multi localhost:12345 ret=$? ;; -h | --helgrind) @@ -91,6 +116,11 @@ case "$1" in LD_PRELOAD="$PRELOAD_LIB" setarch "$setarch_arch" -R valgrind $DF_CALLGRIND_OPTS --tool=callgrind --separate-threads=yes --dump-instr=yes --instr-atstart=no --log-file=callgrind.log ./libs/Dwarf_Fortress "$@" ret=$? ;; + --strace) + shift + strace -f setarch "$setarch_arch" -R env LD_PRELOAD="$PRELOAD_LIB" ./libs/Dwarf_Fortress "$@" 2> strace.log + ret=$? + ;; *) setarch "$setarch_arch" -R env LD_PRELOAD="$PRELOAD_LIB" ./libs/Dwarf_Fortress "$@" ret=$?