blob: c99357f324989efad16938b23cfc35d0def0b367 [file] [edit]
#!/bin/sh
# Exit if anything fails
set -e
# Find the host triple so we can find lldb in rustlib.
host=$(rustc --print host-tuple)
# Find out where to look for the pretty printer Python module
RUSTC_SYSROOT=$(rustc --print sysroot)
RUST_LLDB="$RUSTC_SYSROOT/lib/rustlib/$host/bin/lldb"
lldb=lldb
if [ -f "$RUST_LLDB" ]; then
lldb="$RUST_LLDB"
else
if ! command -v "$lldb" > /dev/null; then
echo "$lldb not found! Please install it." >&2
exit 1
else
LLDB_VERSION=$("$lldb" --version | cut -d ' ' -f3)
if [ "$LLDB_VERSION" = "3.5.0" ]; then
cat << EOF >&2
***
WARNING: This version of LLDB has known issues with Rust and cannot display the contents of local variables!
***
EOF
fi
fi
fi
script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_lookup.py\""
# Unstable (nightly-only) trim-paths feature, activated only if
# - RUST_LLDB_TRIM_PATHS=unstable is set
# - and if the python file is present (only shipped on nightly)
LLDB_TRIM_PATHS="$RUSTC_SYSROOT/lib/rustlib/etc/lldb_trim_paths.py"
if [ "${RUST_LLDB_TRIM_PATHS:-}" = "unstable" ] && [ -f "$LLDB_TRIM_PATHS" ]; then
set -- --one-line-before-file "command script import \"$LLDB_TRIM_PATHS\"" "$@"
fi
# Call LLDB with the commands added to the argument list
exec "$lldb" --one-line-before-file "$script_import" "$@"