summaryrefslogtreecommitdiff
path: root/src/etc/rust-lldb
blob: 424302d495f3eb9d7d9742eb8c359dbdd9c1f0ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh

# Exit if anything fails
set -e

# Find out where to look for the pretty printer Python module
RUSTC_SYSROOT=`rustc --print sysroot`

# Find the host triple so we can find lldb in rustlib.
host=`rustc -vV | sed -n -e 's/^host: //p'`

lldb=lldb
if [ -f "$RUSTC_SYSROOT/lib/rustlib/$host/bin/lldb" ]; then
    lldb="$RUSTC_SYSROOT/lib/rustlib/$host/bin/lldb"
else
    LLDB_VERSION=`"$lldb" --version 2>/dev/null | head -1 | cut -d. -f1`

    if [ "$LLDB_VERSION" = "lldb-350" ]
    then
        echo "***"
	echo \
"WARNING: This version of LLDB has known issues with Rust and cannot \
display the contents of local variables!"
        echo "***"
    fi
fi

# 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 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" \
    "$@"