Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c-api: Enable debugger DWARF export for guest code #9915

Merged
merged 2 commits into from
Dec 30, 2024

Conversation

puremourning
Copy link
Contributor

@puremourning puremourning commented Dec 30, 2024

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 wasmtime cargo 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_descriptor that'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.

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.
@puremourning puremourning requested a review from a team as a code owner December 30, 2024 10:49
@puremourning puremourning requested review from pchickey and removed request for a team December 30, 2024 10:49
@puremourning

This comment was marked as outdated.

@puremourning

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.
@github-actions github-actions bot added the wasmtime:c-api Issues pertaining to the C API. label Dec 30, 2024
@alexcrichton alexcrichton added this pull request to the merge queue Dec 30, 2024
Merged via the queue into bytecodealliance:main with commit 6a95189 Dec 30, 2024
41 checks passed
@puremourning puremourning deleted the c-api-debug-info branch December 30, 2024 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasmtime:c-api Issues pertaining to the C API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

c-api: JIT debugging of wasm guest code not enabled
2 participants