Skip to content

debugger: expose shared memories to gdbstub - #14087

Open
AlisinaDevelo wants to merge 2 commits into
bytecodealliance:mainfrom
AlisinaDevelo:fix/14062-shared-memory-debugger
Open

debugger: expose shared memories to gdbstub#14087
AlisinaDevelo wants to merge 2 commits into
bytecodealliance:mainfrom
AlisinaDevelo:fix/14062-shared-memory-debugger

Conversation

@AlisinaDevelo

Copy link
Copy Markdown

shared linear memories were omitted from the synthetic Wasm address space; this maps both memory types, implements shared-memory access, and adds an LLDB regression test proving address 0 reads correctly.

@AlisinaDevelo
AlisinaDevelo requested a review from a team as a code owner August 6, 2026 19:57
@AlisinaDevelo
AlisinaDevelo requested review from dicej and removed request for a team August 6, 2026 19:57
@dicej

dicej commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@cfallin would you be able to take a look at this?

@cfallin cfallin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I have a number of comments below, as well as one top-level thought:

Lack of support for shared memories is downstream of the bigger issue that we don't support debugging multithreaded programs. That is because wasi-threads has an instance+store-per-thread model, and the debugger controls only one debuggee store. A good debugging experience on a multithreaded program must pause all threads, and that's what a debugger like LLDB expects. The fact that the rest-of-the-world may keep running is visible implicitly in this patch: you need to cast the *UnsafeCell<u8> representing a byte in the shared memory to an *AtomicU8 and do an atomic access to avoid UB on the access because another thread may also be mutating it. But that's a bad debug experience, violates LLDB's assumptions, and so I don't think it makes sense to expose.

Aside from all that, the gdbstub protocol has a bunch of stuff to report and control thread state; I'd expect we would want all that as well if we truly supported multithreaded debugging.

So a question: do you have a plan for those broader questions? Or if not, what is the use-case for attaching a debugger to just one thread and observing its shared memory?

Comment thread crates/debugger/src/host/api.rs Outdated
Comment thread crates/debugger/src/host/api.rs Outdated
Comment thread tests/all/guest_debug/mod.rs Outdated
Comment thread tests/all/guest_debug/mod.rs Outdated
@AlisinaDevelo

Copy link
Copy Markdown
Author

Thanks @cfallin I addressed the comments. Shared memories now use a stable debugger ID, the extra unit test and manual qXfer packet are gone, and the LLDB test now reads the memory directly. Local tests pass. This only covers inspecting shared memory in the current single-store debugger; multi-store wasi-threads debugging remains separate. Thanks again fir the review.

@github-actions github-actions Bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasmtime:api Related to the API of the `wasmtime` crate itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants