Search code examples
debuggingrustlldb

Debugging Rust in VSCode, no debug symbols on library, but debug symbols on example


I'm trying to debug with LLDB on VSCode. I added a breakpoint into my library, it stops on the breakpoint but I get a call stack with unnamed symbols and I can't see any variables:

enter image description here

This is an example from the library, which I built with cargo build --example my_example_name. I researched and to build in release mode, --release should be added. So I think I built in debug mode.

I'd guess the library is being built somehow in release mode. How can I check this?

If I put the breakpoint in the example file itself, then the symbol appear when the breakpoint happens. When I put the breakpoint in the library used by the example, then no symbols appear when the breakpoint happens.

Is it possible that cargo build --example my_example builds the example in debug mode but the library in release mode?


Solution

  • According to https://doc.rust-lang.org/cargo/commands/cargo-build.html, "Dependencies use the dev/release profiles."

    To override that, you could try RUSTFLAGS=-g cargo build ... (-g is equivalent to -C debuginfo=2).