Michael Woerister | 91a0e18 | 2014-12-03 22:48:18 | [diff] [blame] | 1 | #!/bin/sh |
Michael Woerister | 91a0e18 | 2014-12-03 22:48:18 | [diff] [blame] | 2 | # Exit if anything fails |
| 3 | set -e |
| 4 | |
Jeremy Fitzhardinge | 7a824c8 | 2020-04-02 18:49:33 | [diff] [blame] | 5 | # Prefer rustc in the same directory as this script |
| 6 | DIR="$(dirname "$0")" |
| 7 | if [ -x "$DIR/rustc" ]; then |
| 8 | RUSTC="$DIR/rustc" |
| 9 | else |
| 10 | RUSTC="rustc" |
| 11 | fi |
| 12 | |
Michael Woerister | 91a0e18 | 2014-12-03 22:48:18 | [diff] [blame] | 13 | # Find out where the pretty printer Python module is |
Jeremy Fitzhardinge | 7a824c8 | 2020-04-02 18:49:33 | [diff] [blame] | 14 | RUSTC_SYSROOT="$("$RUSTC" --print=sysroot)" |
Michael Woerister | 91a0e18 | 2014-12-03 22:48:18 | [diff] [blame] | 15 | GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc" |
| 16 | |
| 17 | # Run GDB with the additional arguments that load the pretty printers |
Nicolas Bigaouette | 61b7ebe | 2017-04-20 15:20:33 | [diff] [blame] | 18 | # Set the environment variable `RUST_GDB` to overwrite the call to a |
Nicolas Bigaouette | 82ed783 | 2017-04-18 18:00:08 | [diff] [blame] | 19 | # different/specific command (defaults to `gdb`). |
Nicolas Bigaouette | 61b7ebe | 2017-04-20 15:20:33 | [diff] [blame] | 20 | RUST_GDB="${RUST_GDB:-gdb}" |
ftilde | d6426e8a | 2018-08-18 21:48:26 | [diff] [blame] | 21 | PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" exec ${RUST_GDB} \ |
Benjamin Lamowski | f6df174 | 2018-05-22 00:58:19 | [diff] [blame] | 22 | --directory="$GDB_PYTHON_MODULE_DIRECTORY" \ |
Michael Woerister | 91a0e18 | 2014-12-03 22:48:18 | [diff] [blame] | 23 | -iex "add-auto-load-safe-path $GDB_PYTHON_MODULE_DIRECTORY" \ |
| 24 | "$@" |