cfallin opened PR #12750 from cfallin:one-may-try-to-return-but-it-is-never-to-the-place-one-started to bytecodealliance:main:
In working out why a
finishcommand in
LLDB-attached-to-Wasmtime-via-gdbstub wasn't working, I discovered that our current debugging APIs, when presenting info from a frame suspended at a callsite up the stack, present the current PC as at the call instruction, rather than past it (at the return address). The latter is conventional on all real ISAs, and is hence what the debugger expects.This PR makes the most straightforward fix: the debug tuple attached to the call, and hence the metadata read out by the debug frame walker, now encodes the PC of the next opcode. This is sufficient to fix
finishwithin LLDB.An alternative I considered, and prototyped, is also worth mentioning: one might see the argument for allowing a debugger to see the callsite that invoked the next frame, and separately, see the return address (i.e., both pieces of information are useful). In [an alternative branch], there is a new table in the debug frame info metadata giving the size of each callsite, so the debug frame-handle API can present a
get-return-addressaccessor on aframeresource alongsideget-pc. Ultimately I opted not to go with this because it has more overhead and complexity and a concrete use-case wasn't forthcoming to me, but I'm happy to reconsider if someone wants that instead.[an alternative branch]: https://github.com/cfallin/wasmtime/tree/debugger-return-address-separate
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
cfallin requested alexcrichton for a review on PR #12750.
cfallin requested wasmtime-compiler-reviewers for a review on PR #12750.
cfallin requested wasmtime-core-reviewers for a review on PR #12750.
cfallin commented on PR #12750:
(To expand out why this was necessary in more detail, LLDB's "finish" / "step-out-of" command works by looking at the return address of the frame one level up, and setting a temporary breakpoint there, then continuing. It expects the callstack to report the return address rather than the call-instruction address for this to work.)
alexcrichton submitted PR review:
Oof I suspect that was quite the debugging journey to reach on this, but seems reasonable to me!
cfallin updated PR #12750.
cfallin has enabled auto merge for PR #12750.
cfallin updated PR #12750.
cfallin added PR #12750 Debugging: PC in a frame at a callsite should be the return address, not the call. to the merge queue
cfallin merged PR #12750.
cfallin removed PR #12750 Debugging: PC in a frame at a callsite should be the return address, not the call. from the merge queue
Last updated: Mar 23 2026 at 16:19 UTC