Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exec gdb/lldb in rust-{gdb/lldb} wrapper scripts #53477

Merged
merged 2 commits into from
Aug 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/etc/rust-gdb
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
"$@"
21 changes: 9 additions & 12 deletions src/etc/rust-lldb
Original file line number Diff line number Diff line change
Expand Up @@ -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
exec lldb --one-line-before-file="$script_import" \
--one-line-before-file="$category_definition" \
--one-line-before-file="$category_enable" \
"$@"