Skip to content

Debugging: implement debug component support for wasmtime serve #12776

@cfallin

Description

@cfallin

After #12771, we have wasmtime run -g <PORT> and wasmtime run -Ddebugger=<COMPONENT>, providing a good debugging experience for WASI-CLI programs.

We should build the top-level plumbing to allow attaching debug components, both custom ones and the built-in gdbstub one, to wasmtime serve request handlers as well.

The challenge that occurs in this environment is that there is not just one program lifetime, but a Store lifetime per HTTP request (modulo instance reuse). Both the gdbstub protocol, and the underlying debug-main environment, are oriented around debugging one program execution from start to finish.

There are three general approaches I can imagine:

  • Treat each HTTP request as a program execution. This would spawn an instance of the debug component alongside the instance of the wasi-http component. That debug component could listen for a gdbstub connection before continuing, like wasmtime run today. When the one request is done, LLDB sees this as "process exited".
  • Somehow stitch together all HTTP requests into one "virtual program execution" from the point of view of the debugger WIT API. In practice this would mean persisting some state (which breakpoints are set, for example). It would also imply building an invalidation mechanism for all Instance/Module/Table/Global/Func/... handles at the debug API level.
  • Lean into instance reuse, and only have one long-running wasi-http component when we have debugging enabled.

The top-level user experience we probably want is something like: attach LLDB; set a breakpoint somewhere in a handler in a wasi-http component; get control and step through code after sending an HTTP request.

Option 1 is thus a terrible user-experience that we want to reject, I think. Either option 2 or option 3 could provide this desired experience. I favor option 3 for simplicity, in the sense that it bends the conceptual model the least, but I'm curious what others think as well!

Metadata

Metadata

Assignees

No one assigned

    Labels

    wasmtime: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