2014-12-03 23:48:18 +01:00
|
|
|
#!/bin/sh
|
|
|
|
# Exit if anything fails
|
|
|
|
set -e
|
|
|
|
|
2020-04-02 20:49:33 +02:00
|
|
|
# Prefer rustc in the same directory as this script
|
|
|
|
DIR="$(dirname "$0")"
|
|
|
|
if [ -x "$DIR/rustc" ]; then
|
|
|
|
RUSTC="$DIR/rustc"
|
|
|
|
else
|
|
|
|
RUSTC="rustc"
|
|
|
|
fi
|
|
|
|
|
2014-12-03 23:48:18 +01:00
|
|
|
# Find out where the pretty printer Python module is
|
2020-04-02 20:49:33 +02:00
|
|
|
RUSTC_SYSROOT="$("$RUSTC" --print=sysroot)"
|
2014-12-03 23:48:18 +01:00
|
|
|
GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
|
|
|
|
|
|
|
|
# Run GDB with the additional arguments that load the pretty printers
|
2017-04-20 17:20:33 +02:00
|
|
|
# Set the environment variable `RUST_GDB` to overwrite the call to a
|
2017-04-18 20:00:08 +02:00
|
|
|
# different/specific command (defaults to `gdb`).
|
2017-04-20 17:20:33 +02:00
|
|
|
RUST_GDB="${RUST_GDB:-gdb}"
|
2018-08-18 23:48:26 +02:00
|
|
|
PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" exec ${RUST_GDB} \
|
2018-05-22 02:58:19 +02:00
|
|
|
--directory="$GDB_PYTHON_MODULE_DIRECTORY" \
|
2014-12-03 23:48:18 +01:00
|
|
|
-iex "add-auto-load-safe-path $GDB_PYTHON_MODULE_DIRECTORY" \
|
|
|
|
"$@"
|