summaryrefslogtreecommitdiffstats
path: root/src/etc/rust-gdb
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/etc/rust-gdb
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/etc/rust-gdb')
-rwxr-xr-xsrc/etc/rust-gdb24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb
new file mode 100755
index 000000000..b950cea79
--- /dev/null
+++ b/src/etc/rust-gdb
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Exit if anything fails
+set -e
+
+# Prefer rustc in the same directory as this script
+DIR="$(dirname "$0")"
+if [ -x "$DIR/rustc" ]; then
+ RUSTC="$DIR/rustc"
+else
+ RUSTC="rustc"
+fi
+
+# Find out where the pretty printer Python module is
+RUSTC_SYSROOT="$("$RUSTC" --print=sysroot)"
+GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
+
+# Run GDB with the additional arguments that load the pretty printers
+# Set the environment variable `RUST_GDB` to overwrite the call to a
+# different/specific command (defaults to `gdb`).
+RUST_GDB="${RUST_GDB:-gdb}"
+PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" exec ${RUST_GDB} \
+ --directory="$GDB_PYTHON_MODULE_DIRECTORY" \
+ -iex "add-auto-load-safe-path $GDB_PYTHON_MODULE_DIRECTORY" \
+ "$@"