Skip to content

Commit

Permalink
Pull the list of libraries to preload into a variable in linux/dfhack.
Browse files Browse the repository at this point in the history
This is so that the workaround described here can be applied easily:

http://www.bay12games.com/dwarves/mantisbt/view.php?id=2688
  • Loading branch information
angavrilov committed Apr 21, 2014
1 parent 6bef167 commit 74429f1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions package/linux/dfhack
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,34 @@ old_tty_settings=$(stty -g)

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"./hack/libs":"./hack"

PRELOAD_LIB=./hack/libdfhack.so

case "$1" in
-g | --gdb)
shift
echo "set environment LD_PRELOAD=./hack/libdfhack.so" > gdbcmd.tmp
echo "set environment LD_PRELOAD=$PRELOAD_LIB" > gdbcmd.tmp
echo "set environment MALLOC_PERTURB_=45" >> gdbcmd.tmp
gdb $DF_GDB_OPTS -x gdbcmd.tmp ./libs/Dwarf_Fortress "$@"
rm gdbcmd.tmp
ret=$?
;;
-h | --helgrind)
shift
LD_PRELOAD=./hack/libdfhack.so setarch i386 -R valgrind $DF_HELGRIND_OPTS --tool=helgrind --log-file=helgrind.log ./libs/Dwarf_Fortress "$@"
LD_PRELOAD=$PRELOAD_LIB setarch i386 -R valgrind $DF_HELGRIND_OPTS --tool=helgrind --log-file=helgrind.log ./libs/Dwarf_Fortress "$@"
ret=$?
;;
-v | --valgrind)
shift
LD_PRELOAD=./hack/libdfhack.so setarch i386 -R valgrind $DF_VALGRIND_OPTS --log-file=valgrind.log ./libs/Dwarf_Fortress "$@"
LD_PRELOAD=$PRELOAD_LIB setarch i386 -R valgrind $DF_VALGRIND_OPTS --log-file=valgrind.log ./libs/Dwarf_Fortress "$@"
ret=$?
;;
-c | --callgrind)
shift
LD_PRELOAD=./hack/libdfhack.so setarch i386 -R valgrind $DF_CALLGRIND_OPTS --tool=callgrind --separate-threads=yes --dump-instr=yes --instr-atstart=no --log-file=callgrind.log ./libs/Dwarf_Fortress "$@"
LD_PRELOAD=$PRELOAD_LIB setarch i386 -R valgrind $DF_CALLGRIND_OPTS --tool=callgrind --separate-threads=yes --dump-instr=yes --instr-atstart=no --log-file=callgrind.log ./libs/Dwarf_Fortress "$@"
ret=$?
;;
*)
setarch i386 -R env LD_PRELOAD=./hack/libdfhack.so ./libs/Dwarf_Fortress "$@"
setarch i386 -R env LD_PRELOAD=$PRELOAD_LIB ./libs/Dwarf_Fortress "$@"
ret=$?
;;
esac
Expand Down

0 comments on commit 74429f1

Please sign in to comment.