blob: b950cea79edfeaef99761ae1ab76d5cee09cf974 [file] [log] [blame]
Michael Woerister91a0e182014-12-03 22:48:181#!/bin/sh
Michael Woerister91a0e182014-12-03 22:48:182# Exit if anything fails
3set -e
4
Jeremy Fitzhardinge7a824c82020-04-02 18:49:335# Prefer rustc in the same directory as this script
6DIR="$(dirname "$0")"
7if [ -x "$DIR/rustc" ]; then
8 RUSTC="$DIR/rustc"
9else
10 RUSTC="rustc"
11fi
12
Michael Woerister91a0e182014-12-03 22:48:1813# Find out where the pretty printer Python module is
Jeremy Fitzhardinge7a824c82020-04-02 18:49:3314RUSTC_SYSROOT="$("$RUSTC" --print=sysroot)"
Michael Woerister91a0e182014-12-03 22:48:1815GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
16
17# Run GDB with the additional arguments that load the pretty printers
Nicolas Bigaouette61b7ebe2017-04-20 15:20:3318# Set the environment variable `RUST_GDB` to overwrite the call to a
Nicolas Bigaouette82ed7832017-04-18 18:00:0819# different/specific command (defaults to `gdb`).
Nicolas Bigaouette61b7ebe2017-04-20 15:20:3320RUST_GDB="${RUST_GDB:-gdb}"
ftilded6426e8a2018-08-18 21:48:2621PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" exec ${RUST_GDB} \
Benjamin Lamowskif6df1742018-05-22 00:58:1922 --directory="$GDB_PYTHON_MODULE_DIRECTORY" \
Michael Woerister91a0e182014-12-03 22:48:1823 -iex "add-auto-load-safe-path $GDB_PYTHON_MODULE_DIRECTORY" \
24 "$@"