Skip to content

[Based on #131] debug: add Wasmtime WASI source sessions - #135

Open
cpunion wants to merge 1 commit into
codex/debug-command-2164-20260802from
codex/wasi-debug-2164-20260802
Open

[Based on #131] debug: add Wasmtime WASI source sessions#135
cpunion wants to merge 1 commit into
codex/debug-command-2164-20260802from
codex/wasi-debug-2164-20260802

Conversation

@cpunion

@cpunion cpunion commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Based on #131. Tracks Task 5 of xgo-dev#2164; it does not close the umbrella proposal.

What this adds

  • make llgo debug -target=wasip1 use the existing GOOS=wasip1 GOARCH=wasm build path and retain embedded DWARF;
  • validate final Wasm DWARF, the versioned llgo.debugger custom-section record, and imported-memory shape before launch;
  • locate and require Wasmtime 44+ with its built-in gdbstub;
  • locate and require LLDB 22+ with the WebAssembly process plugin;
  • start Wasmtime without consuming its single debugger connection during readiness checks, then connect LLDB with the Wasm process plugin;
  • load the common LLGo LLDB adapter when Python scripting is available, including marker discovery from a Wasm custom section;
  • explicitly downgrade to raw source debugging when a Wasm-aware LLDB (including wasi-sdk 33) is built without Python;
  • add a focused Wasmtime/LLDB acceptance fixture and CI lane.

The runtime environment module is generated from the artifact's actual env.memory limits instead of hardcoding an address or reverse-engineering the function at runtime. Self-contained memories remain accepted.

Verified locally

  • source-file/line breakpoint in main.increment;
  • parameter value=41 and named local result=42;
  • Go source backtrace through main.main;
  • clean process exit;
  • llvm-dwarfdump --verify reports no errors on the final Wasm;
  • the common LLGo adapter recognizes schema/runtime-layout/ABI v1 from the Wasm custom section;
  • relevant unit/command tests pass;
  • go test -timeout 20m -skip '^TestRunPrintfWithStdioNobuf$' ./internal/build passes.

Remaining runtime capability gate

LLGo's current WASI artifact imports shared linear memory. Wasmtime 47's guest-debug gdbstub omits SharedMemory from its RSP address space, so source breakpoints, Wasm locals, and backtraces work, but globals and runtime-backed LLGo formatters cannot yet read guest memory. This was reduced to an independent WAT reproduction and reported upstream:

bytecodealliance/wasmtime#14062

The session reports debugger capability downgrades explicitly and does not claim runtime presentation when it is unavailable.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant