Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate current state of guest debugging #2068

Open
lann opened this issue Nov 8, 2023 · 4 comments
Open

Investigate current state of guest debugging #2068

lann opened this issue Nov 8, 2023 · 4 comments

Comments

@lann
Copy link
Collaborator

lann commented Nov 8, 2023

Reportedly, wasmtime guest debugging has improved significantly over the past months. We should evaluate it for Spin and - if it's useful enough - consider enabling debug_info either by default or via spin up flag and documenting how to get it working for supported languages.

@itowlson
Copy link
Contributor

itowlson commented May 1, 2024

I had a brief and inexpert explore of this. My test case was setting a breakpoint by function name (on a function with #[no_mangle]). I'm no expert but the omens did not seem auspicious. Adding .debug_info(true) to our Wasmtime config did not magically Just Work. Looking further, what I found was:

  • With lldb-17 -- -- wasmtime run -D debug-info <file>:
    • It worked when <file> was a WASI 0.1 module. The breakpoint, although not initially detected, did fire - I guess lldb hooked it up once I resumed execution and the Wasm file had loaded.
    • It did not work when <file> was a component (WASI 0.2 command built with cargo component). The breakpoint was again not initially detected, but this time it did not fire as the function ran.
  • llvm-dwarfdump-17 <file>.wasm produced output on the WASI 0.1 module (including my function name), but gacve an "invalid version number" error when run on a component.
  • I captured the component generated by Spin to wrap a module-based Spin app, and ran llvm-dwarfdump-17 over it: same error.

So my sense of the current situation is that module debugging works but component debugging is not there, and the latter prevents us from doing guest debugging in Spin for now.

That said, maybe there's a LLVM/LLDB extension that makes it work with the component model? I'm happy to try things further but right now my search skills aren't turning one up...

@radu-matei
Copy link
Member

Asking @squillace to share some of his experience debugging Wasm with Wasmtime.

@squillace
Copy link

@itowlson is correct currently. lldb/gdb cannot catch breakpoints navigating components; the problem is that it's quite literally a new file type -- this is the same reason that Ivan notes that llvm-dwarfdump blows chunks. The fixes for this are in flight; but until that happens, you can't turn on debugging in spin and expect it to work with components. :-(

You should lay down the groundwork for this to "suddenly light up" when we teach wasmtime to leave debug symbols in the component modules and lldb to read component files. It won't be "long" but it will be a couple more months, methinks....

@lann
Copy link
Collaborator Author

lann commented Jul 23, 2024

Wasmtime 23 appears to improve the state of debugging for components: bytecodealliance/wasmtime#8693

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🔖 Backlog
Development

No branches or pull requests

5 participants