]> git.proxmox.com Git - rustc.git/blob - src/etc/rust-gdbgui
New upstream version 1.44.1+dfsg1
[rustc.git] / src / etc / rust-gdbgui
1 #!/bin/sh
2
3 # Exit if anything fails
4 set -e
5
6 if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then
7 echo "
8 rust-gdbgui
9 ===========
10 gdbgui - https://gdbgui.com - is a graphical front-end to GDB
11 that runs in a browser. This script invokes gdbgui with the Rust
12 pretty printers loaded.
13
14 Simple usage : rust-gdbgui target/debug/myprog
15 With arguments: rust-gdbgui 'target/debug/myprog arg1 arg2...'
16 (note the quotes)
17
18
19 Hints
20 =====
21 gdbgui won't be able to find the rust 'main' method automatically, so
22 in its options make sure to disable the 'Add breakpoint to main after
23 loading executable' setting to avoid a 'File not found: main' warning
24 on startup.
25
26 Instead, type 'main' into gdbgui's file browser and you should get
27 auto-completion on the filename. Just pick 'main.rs', add a breakpoint
28 by clicking in the line number gutter, and type 'r' or hit the Restart
29 icon to start your program running.
30 "
31 exit 0
32 fi
33
34 # Prefer rustc in the same directory as this script
35 DIR="$(dirname "$0")"
36 if [ -x "$DIR/rustc" ]; then
37 RUSTC="$DIR/rustc"
38 else
39 RUSTC="rustc"
40 fi
41
42 # Find out where the pretty printer Python module is
43 RUSTC_SYSROOT="$("$RUSTC" --print=sysroot)"
44 GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
45
46 # Set the environment variable `RUST_GDB` to overwrite the call to a
47 # different/specific command (defaults to `gdb`).
48 RUST_GDB="${RUST_GDB:-gdb}"
49
50 # Set the environment variable `RUST_GDBGUI` to overwrite the call to a
51 # different/specific command (defaults to `gdbgui`).
52 RUST_GDBGUI="${RUST_GDBGUI:-gdbgui}"
53
54 # These arguments get passed through to GDB and make it load the
55 # Rust pretty printers.
56 GDB_ARGS="--directory=\"$GDB_PYTHON_MODULE_DIRECTORY\" -iex \"add-auto-load-safe-path $GDB_PYTHON_MODULE_DIRECTORY\""
57
58 # Finally we execute gdbgui.
59 PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" \
60 exec ${RUST_GDBGUI} \
61 --gdb ${RUST_GDB} \
62 --gdb-args "${GDB_ARGS}" \
63 "${@}"
64