3 # Exit if anything fails
6 if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then
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.
14 Simple usage : rust-gdbgui target/debug/myprog
15 With arguments: rust-gdbgui 'target/debug/myprog arg1 arg2...'
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
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.
34 # Find out where the pretty printer Python module is
35 RUSTC_SYSROOT=`rustc --print=sysroot`
36 GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
38 # Set the environment variable `RUST_GDB` to overwrite the call to a
39 # different/specific command (defaults to `gdb`).
40 RUST_GDB="${RUST_GDB:-gdb}"
42 # Set the environment variable `RUST_GDBGUI` to overwrite the call to a
43 # different/specific command (defaults to `gdbgui`).
44 RUST_GDBGUI="${RUST_GDBGUI:-gdbgui}"
46 # These arguments get passed through to GDB and make it load the
47 # Rust pretty printers.
48 GDB_ARGS="--directory=\"$GDB_PYTHON_MODULE_DIRECTORY\" -iex \"add-auto-load-safe-path $GDB_PYTHON_MODULE_DIRECTORY\""
50 # Finally we execute gdbgui.
51 PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" \
54 --gdb-args "${GDB_ARGS}" \