Skip to content

Commit 73b5c7e

Browse files
committed
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.
1 parent 33b923f commit 73b5c7e

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/etc/rust-lldb

+9-12
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,16 @@ display the contents of local variables!"
2323
echo "***"
2424
fi
2525

26-
# Create a tempfile containing the LLDB script we want to execute on startup
27-
TMPFILE=`mktemp /tmp/rust-lldb-commands.XXXXXX`
28-
29-
# Make sure to delete the tempfile no matter what
30-
trap "rm -f $TMPFILE; exit" INT TERM EXIT
31-
3226
# Find out where to look for the pretty printer Python module
3327
RUSTC_SYSROOT=`rustc --print sysroot`
3428

35-
# Write the LLDB script to the tempfile
36-
echo "command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\"" >> $TMPFILE
37-
echo "type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust" >> $TMPFILE
38-
echo "type category enable Rust" >> $TMPFILE
29+
# Prepare commands that will be loaded before any file on the command line has been loaded
30+
script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
31+
category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
32+
category_enable="type category enable Rust"
3933

40-
# Call LLDB with the script added to the argument list
41-
lldb --source-before-file="$TMPFILE" "$@"
34+
# Call LLDB with the commands added to the argument list
35+
lldb --one-line-before-file="$script_import" \
36+
--one-line-before-file="$category_definition" \
37+
--one-line-before-file="$category_enable" \
38+
"$@"

0 commit comments

Comments
 (0)