Skip to content

DWARF debug info: local variables show "no location, value may have been optimized out" in LLDB #12677

@radu-matei

Description

@radu-matei

I'm working on debugging support for WASI HTTP/Spin Rust components.
Breakpoints are correctly triggered; however, inspecting variables through LLDB/VS Code results in "no location, value may have been optimized out".

I have reproduced with a simple Rust program compiled to either wasm32-wasip1 or wasm32-wasip2:

fn main() {
    let x = 42;
    let y = "foo";
    println!("Hello, world!");
}

With this debug profile in Cargo.toml:

[profile.dev]
opt-level = 0
debug = true

Running with Wasmtime 42.0.0 (or 41.0.4) and LLDB, then listing variables results in the message no location, value may have been optimized out for all variables:

lldb -- wasmtime run -D debug-info -O opt-level=0 target/wasm32-wasip1/debug/dwarf-debugging-repro.wasm
(lldb) target create "wasmtime"
Current executable set to '/Users/radu/.wasmtime/bin/wasmtime' (arm64).
(lldb) settings set -- target.run-args  "run" "-D" "debug-info" "-O" "opt-level=0" "target/wasm32-wasip1/debug/dwarf-debugging-repro.wasm"
(lldb) settings set plugin.jit-loader.gdb.enable on
(lldb) b src/main.rs:5
Breakpoint 1: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.
(lldb) r
Process 94942 launched: '/Users/radu/.wasmtime/bin/wasmtime' (arm64)
3 locations added to breakpoint 1
Process 94942 stopped
* thread #1, name = 'main', queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000107e1c3b0 JIT(0x8a6028000)`dwarf_debugging_repro::main::h15ad2e2a588792ef at main.rs:5:5
   2        let x: i32 = 42;
   3        let y: i64 = 100;
   4        let msg: &str = "hello";
-> 5        println!("x={} y={} msg={}", x, y, msg);
   6    }
Target 0: (wasmtime) stopped.
(lldb) frame variable
(WasmtimeVMContext *) __vmctx = 0x00000008a7258ca0
(int) x = <no location, value may have been optimized out>

(long) y = <no location, value may have been optimized out>

(&str) msg = <no location, value may have been optimized out>

(lldb) 

Disclaimer: I have a patch to Wasmtime generated with Claude (plus description) that allows me to retrieve the variables when debugging with lldb:
(I do not claim to fully understand how it works, which is why this is not a PR; feel free to use or ignore the patch I linked):

lldb -- wasmtime-with-the-patch run -D debug-info -O opt-level=0 target/wasm32-wasip2/debug/dwarf-debugging-repro.wasm
(lldb) settings set -- target.run-args  "run" "-D" "debug-info" "-O" "opt-level=0" "target/wasm32-wasip2/debug/dwarf-debugging-repro.wasm"
(lldb) settings set plugin.jit-loader.gdb.enable on
(lldb) b src/main.rs:5
Breakpoint 1: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.
(lldb) r
Process 96860 launched: '/Users/radu/projects/github.com/spinframework/wasmtime/target/release/wasmtime' (arm64)
3 locations added to breakpoint 1
Process 96860 stopped
* thread #1, name = 'main', queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x00000001089d86bc JIT(0xaba000000)`dwarf_debugging_repro::main::hb42100e0c21c7fa3 at main.rs:5:5
   2        let x: i32 = 42;
   3        let y: i64 = 100;
   4        let msg: &str = "hello";
-> 5        println!("x={} y={} msg={}", x, y, msg);
   6    }
Target 0: (wasmtime) stopped.
(lldb) frame variable
(WasmtimeVMContext *) __vmctx = 0x0000000abb0c40a0
(int) x = 42
(long) y = 100
(&str) msg = {
  data_ptr = (__ptr = 1048576)
  length = 5
}

Being able to support breakpoint debugging for WASI HTTP components and variable inspection support would be incredibly valuable for the Spin project. Let me know if there is anything I can help with further.

Environment:

$ lldb --version
lldb-1703.0.234.3
Apple Swift version 6.2.1 (swiftlang-6.2.1.4.8 clang-1700.4.4.1)

$ cargo --version                   
cargo 1.93.1 (083ac5135 2025-12-15)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior in the current implementation that needs fixingwasmtime:debuggingIssues related to debugging of JIT'ed code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions