puremourning opened PR #9915 from puremourning:c-api-debug-info
to bytecodealliance:main
:
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).I took a look at the automated tests and the most obvious place to add a regression test is
tests/all/debug/lldb.rs
ortests/all/debug/gdb.rs
. I haven't done this yet because I don't see any other places where the c-api is currently tested and wonder if it's even simple to build such a test. Let me know if there's a good path to adding something.
puremourning requested pchickey for a review on PR #9915.
puremourning requested wasmtime-core-reviewers for a review on PR #9915.
puremourning commented on PR #9915:
Well now, I see CI / Test C-API macos-latest in the CI runs.
I'll dig further on how this is done.
puremourning updated PR #9915.
puremourning commented on PR #9915:
OK I have a testing strategy. I can validate that the GDB structures are actually set up in the fib-debug/main.c.
It's a little tacky 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.I have confirmed this test fails without my patch and passes with it.
puremourning edited a comment on PR #9915:
OK I have a testing 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.I have confirmed this test fails without my patch and passes with it.
puremourning edited a comment on PR #9915:
OK I have a testing 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.
puremourning updated PR #9915.
puremourning edited PR #9915:
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.
alexcrichton submitted PR review.
alexcrichton merged PR #9915.
Last updated: Jan 24 2025 at 00:11 UTC