VS Code debugging with LLDB: How can we watch &a_slice[start..end]?

Hi there ^^

I recently dove deeper into rust debugging with VS Code and the LLDB Plugin. It would be great if we could use rust expressions. Sadly I can only use C and python expressions to some extent. While digging around I found this open RFC: https://github.com/rust-lang/rust/issues/48168

The RFC leads me to the assumption there must be a LLDB binary with rust capabilities somewhere. I don't know if the LLDB binary shipped with the VS Code extension is a copy of the before mentioned LLDB binary.

Do you know where or how I can obtain a LLDB binary bundled with the rust plugin?

I also found Miri.

Could Miri be used inside a debugger to evaluate Rust expressions?

Background: Currently I write a parser with the goal of writing a parser generator. I like programming languages and tinkering around with parsers. My knowledge on this topic is superficial. Maybe it is too early for me to get my hands on something like this. Yet it has been time consuming and fun at the same time. So I consider this to be fine as it is.

The parser returns ranges of the input &str. I would like to watch the expression &context.input[start..end] while debugging. This python expression does the trick:
/py "".join([chr(c) for c in $context.input[$start:$end]])
It is rather long, uneasy to handle and was sort of hard to come up with, because I have very little experience with python.

Do you know of a C expression I could use instead?

/nat context.input delivers the whole &str. I couldn't find a way to get a slice with C though.

Or is there even a debugger in which I can use Rust expressions out there?

Happy coding everyone :sparkling_heart: :crab: :heartpulse:

On my machine the Rust-enabled LLDB is installed at ~/.cargo/bin/rust-lldb. I don't know how to hook that up to VS Code, though.

thankyou for the hint. As far as I know rust-lldb and rust-gdb are wrapper programs for the debuggers lldb and gdb. They reformat parts of the output (and maybe input) such that handling is easier.

Starting rust-lldb prints lldb not found! Please install it.

You're right—sorry for the unhelpful post! I'm afraid I don't know any more about installing/setting up LLDB for use with Rust. If you don't get any leads from posting here, you could try Zulip, which is where a lot of the discussion around compiler and tooling development happens.

You will need to install lldb on your system first. rust-lldb only registers a couple of pretty-printers with the system lldb it runs. How to install it depends on the OS. macOS should already have it installed. On Linux your distro probably has it in the package repository. On Windows you should use windbg or the visual studio debugger instead I think. There are natvis pretty printers somewhere in the rust installation dir (I think somewhere in share) that you can enable. (never debugged anything on windows, so I don't know how to enable it.)

thankyou for your reply. The main reason for this thread is to find a debugger in which we can use rust expressions. I thought there might be one capable interpreting rust expressions out there. The links to my findings are in the starting post.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.