From 0902fc88db6d51f3f22735d26a2b2e8caedd25bc Mon Sep 17 00:00:00 2001 From: Philip Daniels Date: Tue, 28 Aug 2018 22:05:00 +0100 Subject: [PATCH 1/2] Add rust-gdbgui script. This script invokes the gdbgui graphical GDB front-end with the Rust pretty printers loaded. The script does not install gdbgui, that must be done manually. --- src/etc/rust-gdbgui | 65 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 src/etc/rust-gdbgui diff --git a/src/etc/rust-gdbgui b/src/etc/rust-gdbgui new file mode 100755 index 0000000000000..6786fe015bca1 --- /dev/null +++ b/src/etc/rust-gdbgui @@ -0,0 +1,65 @@ +#!/bin/sh +# Copyright 2014 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +# Exit if anything fails +set -e + +if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then + echo " +rust-gdbgui +=========== +gdbgui - https://gdbgui.com - is a graphical front-end to GDB +that runs in a browser. This script invokes gdbgui with the Rust +pretty printers loaded. + +Simple usage : rust-gdbgui target\debug\myprog +With arguments: rust-gdbgui 'target\debug\myprog arg1 arg2...' + (note the quotes) + + +Hints +===== +gdbgui won't be able to find the rust 'main' method automatically, so +in its options make sure to disable the 'Add breakpoint to main after +loading executable' setting to avoid a 'File not found: main' warning +on startup. + +Instead, type 'main' into the file browser and you should get +auto-completion on the filename. Just pick 'main.rs', add a breakpoint +by clicking in the line number gutter, and type 'r' or hit the Restart +icon to start your program running. +" + exit 0 +fi + +# Find out where the pretty printer Python module is +RUSTC_SYSROOT=`rustc --print=sysroot` +GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc" + +# Set the environment variable `RUST_GDB` to overwrite the call to a +# different/specific command (defaults to `gdb`). +RUST_GDB="${RUST_GDB:-gdb}" + +# Set the environment variable `RUST_GDBGUI` to overwrite the call to a +# different/specific command (defaults to `gdbgui`). +RUST_GDBGUI="${RUST_GDBGUI:-gdbgui}" + +# These arguments get passed through to GDB and make it load the +# Rust pretty printers. +GDB_ARGS="--directory=\"$GDB_PYTHON_MODULE_DIRECTORY\" -iex \"add-auto-load-safe-path $GDB_PYTHON_MODULE_DIRECTORY\"" + +# Finally we execute gdbgui. +PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" \ + exec ${RUST_GDBGUI} \ + --gdb ${RUST_GDB} \ + --gdb-args "${GDB_ARGS}" \ + "${@}" + From 47aa4758664ee7b054261f09de3375cfb3cc926d Mon Sep 17 00:00:00 2001 From: Philip Daniels Date: Thu, 30 Aug 2018 20:23:41 +0100 Subject: [PATCH 2/2] Fix direction of slashes in the help text example. --- src/etc/rust-gdbgui | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/etc/rust-gdbgui b/src/etc/rust-gdbgui index 6786fe015bca1..7e179ba927dff 100755 --- a/src/etc/rust-gdbgui +++ b/src/etc/rust-gdbgui @@ -20,8 +20,8 @@ gdbgui - https://gdbgui.com - is a graphical front-end to GDB that runs in a browser. This script invokes gdbgui with the Rust pretty printers loaded. -Simple usage : rust-gdbgui target\debug\myprog -With arguments: rust-gdbgui 'target\debug\myprog arg1 arg2...' +Simple usage : rust-gdbgui target/debug/myprog +With arguments: rust-gdbgui 'target/debug/myprog arg1 arg2...' (note the quotes) @@ -32,7 +32,7 @@ in its options make sure to disable the 'Add breakpoint to main after loading executable' setting to avoid a 'File not found: main' warning on startup. -Instead, type 'main' into the file browser and you should get +Instead, type 'main' into gdbgui's file browser and you should get auto-completion on the filename. Just pick 'main.rs', add a breakpoint by clicking in the line number gutter, and type 'r' or hit the Restart icon to start your program running.