xref: /aosp_15_r20/prebuilts/rust/linux-musl-x86/1.80.1/bin/rust-lldb (revision b40554a23088fb75aa6945dfe8e65169c8484da3)
1*b40554a2SAndroid Build Coastguard Worker#!/bin/sh
2*b40554a2SAndroid Build Coastguard Worker
3*b40554a2SAndroid Build Coastguard Worker# Exit if anything fails
4*b40554a2SAndroid Build Coastguard Workerset -e
5*b40554a2SAndroid Build Coastguard Worker
6*b40554a2SAndroid Build Coastguard Worker# Find the host triple so we can find lldb in rustlib.
7*b40554a2SAndroid Build Coastguard Workerhost=$(rustc -vV | sed -n -e 's/^host: //p')
8*b40554a2SAndroid Build Coastguard Worker
9*b40554a2SAndroid Build Coastguard Worker# Find out where to look for the pretty printer Python module
10*b40554a2SAndroid Build Coastguard WorkerRUSTC_SYSROOT=$(rustc --print sysroot)
11*b40554a2SAndroid Build Coastguard WorkerRUST_LLDB="$RUSTC_SYSROOT/lib/rustlib/$host/bin/lldb"
12*b40554a2SAndroid Build Coastguard Worker
13*b40554a2SAndroid Build Coastguard Workerlldb=lldb
14*b40554a2SAndroid Build Coastguard Workerif [ -f "$RUST_LLDB" ]; then
15*b40554a2SAndroid Build Coastguard Worker    lldb="$RUST_LLDB"
16*b40554a2SAndroid Build Coastguard Workerelse
17*b40554a2SAndroid Build Coastguard Worker    if ! command -v "$lldb" > /dev/null; then
18*b40554a2SAndroid Build Coastguard Worker        echo "$lldb not found! Please install it." >&2
19*b40554a2SAndroid Build Coastguard Worker        exit 1
20*b40554a2SAndroid Build Coastguard Worker    else
21*b40554a2SAndroid Build Coastguard Worker        LLDB_VERSION=$("$lldb" --version | cut -d ' ' -f3)
22*b40554a2SAndroid Build Coastguard Worker
23*b40554a2SAndroid Build Coastguard Worker        if [ "$LLDB_VERSION" = "3.5.0" ]; then
24*b40554a2SAndroid Build Coastguard Worker            cat << EOF >&2
25*b40554a2SAndroid Build Coastguard Worker***
26*b40554a2SAndroid Build Coastguard WorkerWARNING: This version of LLDB has known issues with Rust and cannot display the contents of local variables!
27*b40554a2SAndroid Build Coastguard Worker***
28*b40554a2SAndroid Build Coastguard WorkerEOF
29*b40554a2SAndroid Build Coastguard Worker        fi
30*b40554a2SAndroid Build Coastguard Worker    fi
31*b40554a2SAndroid Build Coastguard Workerfi
32*b40554a2SAndroid Build Coastguard Worker
33*b40554a2SAndroid Build Coastguard Workerscript_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_lookup.py\""
34*b40554a2SAndroid Build Coastguard Workercommands_file="$RUSTC_SYSROOT/lib/rustlib/etc/lldb_commands"
35*b40554a2SAndroid Build Coastguard Worker
36*b40554a2SAndroid Build Coastguard Worker# Call LLDB with the commands added to the argument list
37*b40554a2SAndroid Build Coastguard Workerexec "$lldb" --one-line-before-file "$script_import" --source-before-file "$commands_file" "$@"
38