Debugging: provide access to private (non-exported) entities. #12367
+235
−3
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.