From 0d0faa5300f370678c495582baec6b5cfe7ccad2 Mon Sep 17 00:00:00 2001 From: Alexey Gladkov Date: Fri, 7 Apr 2023 17:24:39 +0300 Subject: ALT: gdb: Fix libdir Signed-off-by: Alexey Gladkov --- src/etc/rust-gdb | 6 ++++-- src/etc/rust-gdbgui | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb index 9abed30ea6f..bfd69b0ef15 100755 --- a/src/etc/rust-gdb +++ b/src/etc/rust-gdb @@ -10,9 +10,11 @@ else RUSTC="rustc" fi +LIBDIR="$(getconf LIBDIR)" + # Find out where the pretty printer Python module is RUSTC_SYSROOT="$("$RUSTC" --print=sysroot)" -GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc" +GDB_PYTHON_MODULE_DIRECTORY="$LIBDIR/rustlib/etc" # Get the commit hash for path remapping RUSTC_COMMIT_HASH="$("$RUSTC" -vV | sed -n 's/commit-hash: \([a-zA-Z0-9_]*\)/\1/p')" @@ -23,6 +25,6 @@ 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" \ - -iex "set substitute-path /rustc/$RUSTC_COMMIT_HASH $RUSTC_SYSROOT/lib/rustlib/src/rust" \ + -iex "set substitute-path /rustc/$RUSTC_COMMIT_HASH $LIBDIR/rustlib/src/rust" \ "$@" diff --git a/src/etc/rust-gdbgui b/src/etc/rust-gdbgui index 913269316bd..28536ad8ea3 100755 --- a/src/etc/rust-gdbgui +++ b/src/etc/rust-gdbgui @@ -31,6 +31,8 @@ icon to start your program running. exit 0 fi +LIBDIR="$(getconf LIBDIR)" + # Prefer rustc in the same directory as this script DIR="$(dirname "$0")" if [ -x "$DIR/rustc" ]; then @@ -41,7 +43,7 @@ fi # Find out where the pretty printer Python module is RUSTC_SYSROOT="$("$RUSTC" --print=sysroot)" -GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc" +GDB_PYTHON_MODULE_DIRECTORY="$LIBDIR/rustlib/etc" # Get the commit hash for path remapping RUSTC_COMMIT_HASH="$("$RUSTC" -vV | sed -n 's/commit-hash: \([a-zA-Z0-9_]*\)/\1/p')" @@ -57,7 +59,7 @@ RUST_GDBGUI="${RUST_GDBGUI:-gdbgui}" # Rust pretty printers. GDB_ARGS="--directory=\"$GDB_PYTHON_MODULE_DIRECTORY\"" \ "-iex \"add-auto-load-safe-path $GDB_PYTHON_MODULE_DIRECTORY\"" \ - "-iex \"set substitute-path /rustc/$RUSTC_COMMIT_HASH $RUSTC_SYSROOT/lib/rustlib/src/rust\"" + "-iex \"set substitute-path /rustc/$RUSTC_COMMIT_HASH $LIBDIR/rustlib/src/rust\"" # Finally we execute gdbgui. PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" \ -- 2.25.4