probe-rs / vscode

VSCode debug extension for probe-rs. It uses the MS DAP protocol to communicate directly with the probe (via probe-rs), and supports basic command line debugging in addition to VSCode UI.
https://probe.rs/
Other
65 stars 5 forks source link

Can't step into standard library when debugging #100

Open staticintlucas opened 1 week ago

staticintlucas commented 1 week ago

If I try to step into any standard library function the source file is not found, which can be pretty annoying:

image

Rust standard libraries use the source path translation: /rustc/<commit-hash><sysroot>/lib/rustlib/src/rust

rust-analyzer takes care of this translation automatically here: https://github.com/rust-lang/rust-analyzer/blob/1b283db47f8de1412c851c92bb4ce4ef039ff8ff/editors/code/src/debug.ts#L144

Would it be possible to support the same here too?

noppej commented 6 days ago

It is definitely possible, and would be a nice addition. The implementation would be in dap-server component of the https://github.com/probe-rs/probe-rs repo. I'd be more than happy to help you get started on that code base if you want to submit a PR.

staticintlucas commented 6 days ago

The implementation would be in dap-server component of the https://github.com/probe-rs/probe-rs repo.

Ah sorry, didn't realise it was there

I'd be more than happy to help you get started on that code base if you want to submit a PR.

Yeah I'd be happy to work on a PR if you gave me a few pointer on where to look

noppej commented 5 days ago

As a starting point, have a look at the DAP specification for Source. We construct this in the dap-server as part of creating a StackFrame from the stack trace information.

My first instinct suggests that you will need to specify a sourceReference in the StackFrame definition, so that it forces the client to issue a Source request, where the 'translation' you refer to above, will be implemented.

Once you've had a look at that, the next step I'd suggest is to create a PR in the probe-rs repo, and then tag me from there to continue the conversation in more detail.