From 82d6023296ea370fee57fcbf17fe545772653021 Mon Sep 17 00:00:00 2001 From: Uttarayan Mondal Date: Tue, 23 Jan 2024 13:49:37 +0530 Subject: [PATCH] [feat] Added a script to easily add rust-src map to rust-lldb --- scripts/rust-src-map-lldb.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 scripts/rust-src-map-lldb.py diff --git a/scripts/rust-src-map-lldb.py b/scripts/rust-src-map-lldb.py new file mode 100644 index 00000000..c3e87c1e --- /dev/null +++ b/scripts/rust-src-map-lldb.py @@ -0,0 +1,27 @@ +import subprocess + +# Get the default Rust toolchain +toolchain_command = "rustup toolchain list | grep '(default)' | cut -d' ' -f 1" +TOOLCHAIN = subprocess.check_output( + toolchain_command, shell=True, text=True).strip() + +# Get the commit hash of the installed Rust compiler +commit_hash_command = "rustc -Vv | grep commit-hash | cut -d' ' -f 2" +COMMIT_HASH = subprocess.check_output( + commit_hash_command, shell=True, text=True).strip() + +# Get the Rustup home directory +rustup_home_command = "rustup show home" +RUSTUP_HOME = subprocess.check_output( + rustup_home_command, shell=True, text=True).strip() + +# Create the settings string +settings = f"\nsettings set target.source-map /rustc/{COMMIT_HASH}/ {RUSTUP_HOME}/toolchains/{TOOLCHAIN}/lib/rustlib/src/rust/" +commands = f"{RUSTUP_HOME}/toolchains/{TOOLCHAIN}/lib/rustlib/etc/lldb_commands" + +# Print or use the 'settings' variable as needed +print(settings) + +# Append settings to commands file +with open(commands, "a") as f: + f.write(settings)