c-api: Enable debugger DWARF export for guest code#9915
Merged
alexcrichton merged 2 commits intoDec 30, 2024
Conversation
In order to allow source level debugging of hosted webassembly code in C-based embeddings, we must enable the debug-builtins cargo feature when building the C api.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Previously we were testing and confirming only that the options can be set using the API, not that they actually have any effect. In order to (simply) confirm that enabling debug information actually created some debug information, we can somewhat hackily inspect the generated GDB JIT descriptor to see that it's populated.
989032b to
bb88e3b
Compare
alexcrichton
approved these changes
Dec 30, 2024
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.
In order to allow source level debugging of hosted webassembly code in C-based embeddings, we must enable the debug-builtins cargo feature when building the C api. This allows for embeddings of wasmtime in non-rust environments to benefit from the integration with gdb/lldb's JIT debug interface.
Fixes #9909
Tests: I have tested this manually per the notes in the linked issue, and have single-stepped through the code to confirm it is behaving as I expect (I basically did a side-by side step through with an equivalent rust program linked with the default settings and
wasmtimecargo dependency).For automated tests, I have a simple strategy: I can validate that the GDB structures are actually set up in the fib-debug/main.c. It's a little hacky so I've added as a second commit. The strategy is to validate the actual
__jit_debug_descriptorthat's created is non-NULL after instantiation. As these examples are used by other people, I have gated the code with a compile definition that's only set during the tests.I have confirmed this test fails without my patch and passes with it.