Skip to content

[WIP] Enable native debugging for wasm modules/components #129

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dblnz
Copy link
Contributor

@dblnz dblnz commented Jul 24, 2025

This PR address part of hyperlight-dev/hyperlight#684 and closes #120 that concerns the hyperlight-wasm related work to enable the wasm modules/components native debugging running in hyperlight-wasm guest.

What this includes:

Signed-off-by: Doru Blânzeanu <dblnz@pm.me>
@dblnz dblnz self-assigned this Jul 24, 2025
@dblnz dblnz added the kind/enhancement New feature or request label Jul 24, 2025
Copy link
Member

@syntactically syntactically left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! If I understand it correctly, the actual "registering loaded code with GDB" is taken care of by the upstream wasmtime code that handles the GDB jit interface, which automatically works for us since when gdb loads the debug information for the sandbox binary, it gets the jit interface symbols from wasmtime?

One minor note that is not really completely related to this PR---this changeset made me notice that we still have a .vscode in this directory, which we removed from hyperlight core in hyperlight-dev/hyperlight#66. Do we want to remove that here as well, and make sure that any/all relevant settings are documented?

"HelloWorld",
"Message from Rust Example to Wasm Function".to_string(),
),
// (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a plan to move a test from the Rust code here to exercise both C and Rust source code of the debug symbols.

#[cfg(feature = "gdb")]
{
config.debug_info(true);
config.cranelift_opt_level(OptLevel::None);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want this to be unconditional? Sometimes it's quite useful to be able to debug the optimized code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was is still in dev, I'll remove it

@@ -17,6 +17,6 @@ limitations under the License.
fn main() {
println!("cargo:rustc-link-arg=-zstack-size=4096");
println!("cargo:rustc-link-arg=--initial-memory=65536");
println!("cargo:rustc-link-arg=--strip-all");
//println!("cargo:rustc-link-arg=--strip-all");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this either be a cfg gate or removed entirely, rather than commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll gate it somehow before finalizing

@dblnz
Copy link
Contributor Author

dblnz commented Jul 24, 2025

This looks great! If I understand it correctly, the actual "registering loaded code with GDB" is taken care of by the upstream wasmtime code that handles the GDB jit interface, which automatically works for us since when gdb loads the debug information for the sandbox binary, it gets the jit interface symbols from wasmtime?

One minor note that is not really completely related to this PR---this changeset made me notice that we still have a .vscode in this directory, which we removed from hyperlight core in hyperlight-dev/hyperlight#66. Do we want to remove that here as well, and make sure that any/all relevant settings are documented?

Thanks for taking a look at this. You are correct, the GDB jit interface is handled by the changes in wasmtime that enable it for no_std environments also.

I'll remove the .vscode, I don't have a strong preference.

@ludfjig
Copy link
Contributor

ludfjig commented Jul 25, 2025

I'm a fan of keeping the .vscode for what it's worth. We brought it back in hl-core as well.

@simongdavies
Copy link
Contributor

I'm a fan of keeping the .vscode for what it's worth. We brought it back in hl-core as well.

Agreed, I don't think this impacts folks who don't care and helps those who do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add flag to hyperlight-wasm-aot to include debug symbols
4 participants