From 73b5c7eda2a44aea26b5e62f8caaddc6902a45bb Mon Sep 17 00:00:00 2001 From: ftilde Date: Sat, 18 Aug 2018 23:46:52 +0200 Subject: [PATCH 1/2] Avoid creation of command temp file in rust-lldb Arguments are passed on the command line via --one-line-before-file (instead of in a file via --source-before-file) to lldb. --- src/etc/rust-lldb | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb index f70ab65bce717..56851595dd5ba 100755 --- a/src/etc/rust-lldb +++ b/src/etc/rust-lldb @@ -23,19 +23,16 @@ display the contents of local variables!" echo "***" fi -# Create a tempfile containing the LLDB script we want to execute on startup -TMPFILE=`mktemp /tmp/rust-lldb-commands.XXXXXX` - -# Make sure to delete the tempfile no matter what -trap "rm -f $TMPFILE; exit" INT TERM EXIT - # Find out where to look for the pretty printer Python module RUSTC_SYSROOT=`rustc --print sysroot` -# Write the LLDB script to the tempfile -echo "command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\"" >> $TMPFILE -echo "type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust" >> $TMPFILE -echo "type category enable Rust" >> $TMPFILE +# Prepare commands that will be loaded before any file on the command line has been loaded +script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\"" +category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust" +category_enable="type category enable Rust" -# Call LLDB with the script added to the argument list -lldb --source-before-file="$TMPFILE" "$@" +# Call LLDB with the commands added to the argument list +lldb --one-line-before-file="$script_import" \ + --one-line-before-file="$category_definition" \ + --one-line-before-file="$category_enable" \ + "$@" From d6426e8a25baa3011b9db14aca660b39b9867578 Mon Sep 17 00:00:00 2001 From: ftilde Date: Sat, 18 Aug 2018 23:48:26 +0200 Subject: [PATCH 2/2] Exec gdb and lldb in rust-* wrappers This way the process we get by calling rust-{gdb,lldb} is an actual {gdb,lldb} instance and not (perhaps surprisingly) a script waiting for the debugger process to finish. Thus, sending a SIGINT to the spawned process stops execution of the child, for example. --- src/etc/rust-gdb | 2 +- src/etc/rust-lldb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/etc/rust-gdb b/src/etc/rust-gdb index 6835d6aa90874..743952a5bef89 100755 --- a/src/etc/rust-gdb +++ b/src/etc/rust-gdb @@ -20,7 +20,7 @@ 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}" -PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" ${RUST_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" \ "$@" diff --git a/src/etc/rust-lldb b/src/etc/rust-lldb index 56851595dd5ba..6a2849b55485e 100755 --- a/src/etc/rust-lldb +++ b/src/etc/rust-lldb @@ -32,7 +32,7 @@ category_definition="type summary add --no-value --python-function lldb_rust_for category_enable="type category enable Rust" # Call LLDB with the commands added to the argument list -lldb --one-line-before-file="$script_import" \ +exec lldb --one-line-before-file="$script_import" \ --one-line-before-file="$category_definition" \ --one-line-before-file="$category_enable" \ "$@"