Debugging: provide access to private (non-exported) entities.#12367
Merged
cfallin merged 3 commits intobytecodealliance:mainfrom Jan 21, 2026
Merged
Debugging: provide access to private (non-exported) entities.#12367cfallin merged 3 commits intobytecodealliance:mainfrom
cfallin merged 3 commits intobytecodealliance:mainfrom
Conversation
A debugger will need to access all entities (globals, tables, memories), even those that are not exported, in order to provide a full debugging experience: for example, a developer who has a debugger attached to a Wasm component will expect to be able to see data in its memory. Historically we have been very careful in Wasmtime to provide access to Wasm instances' entities only as the Wasm type system allows -- that is, only if they are exported. However, debugging is privileged -- in the same way that a native host debugger has `ptrace` and can view everything about the debuggee, we need to provide APIs for seeing through the encapsulation boundary. To ensure that this "violation of encapsulation" is scoped only to the extent needed for the legitimate need (debugging), this API is dynamically available only when `guest_debug` is configured true for a given engine. Otherwise, the accessor returns `None`. I opted not to provide a full introspection API that enumerates all of the entities as the debugger should already have access to the debuggee module and be able to enumerate the entities. Thus, the API only provides a host-API handle when asking for an entity by index in a given instance's index space.
c70a0cb to
7c835c6
Compare
Member
Author
|
Reworked now -- a bit more verbose API but seems more in line with what is there already. Thanks! |
alexcrichton
approved these changes
Jan 21, 2026
Member
alexcrichton
left a comment
There was a problem hiding this comment.
FWIW we more-or-less consider wasmtime-environ to be a private crate for now. It's "more public" than everything else we have that's not actually public given its history, but we haven't pulled the trigger on making it actually official or anything like that. I think it would need a lot of API cleanups to have the same quality as wasmtime-the-crate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A debugger will need to access all entities (globals, tables, memories), even those that are not exported, in order to provide a full debugging experience: for example, a developer who has a debugger attached to a Wasm component will expect to be able to see data in its memory.
Historically we have been very careful in Wasmtime to provide access to Wasm instances' entities only as the Wasm type system allows -- that is, only if they are exported. However, debugging is privileged -- in the same way that a native host debugger has
ptraceand can view everything about the debuggee, we need to provide APIs for seeing through the encapsulation boundary.To ensure that this "violation of encapsulation" is scoped only to the extent needed for the legitimate need (debugging), this API is dynamically available only when
guest_debugis configured true for a given engine. Otherwise, the accessor returnsNone.I opted not to provide a full introspection API that enumerates all of the entities as the debugger should already have access to the debuggee module and be able to enumerate the entities. Thus, the API only provides a host-API handle when asking for an entity by index in a given instance's index space.