[Solved] How to step into std source code when debugging in VS Code?

Thanks for help. After a few missteps I think I figured it out:

First I found rust std sources on my computer at:

/Users/jessegrosjean/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/

Next what I tried to step into Vec::new() I saw (which contains a "Source location"):

; id = {0x00000180}, range = [0x0000000100002760-0x00000001000027b0), name="_$LT$alloc..vec..Vec$LT$T$GT$$GT$::new::h50925563cb2ee1ff", mangled="_ZN33_$LT$alloc..vec..Vec$LT$T$GT$$GT$3new17h50925563cb2ee1ffE"
; Source location: /rustc/9fda7c2237db910e41d6a712e9a2139b352e558b/src/liballoc/vec.rs:329
100002760: 55                         pushq  %rbp
100002761: 48 89 E5                   movq   %rsp, %rbp
100002764: 48 83 EC 20                subq   $0x20, %rsp
...

I then combined these two things in .vscode/settings.json like this:

{
  "lldb.executable": "rust-lldb",
  "lldb.launch.sourceLanguages": ["rust"],
  "lldb.launch.sourceMap": {
    "/rustc/9fda7c2237db910e41d6a712e9a2139b352e558b/": "/Users/jessegrosjean/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/"
  },
}

And I can step into std! Yeah and thank you!

15 Likes