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

Can't load wasm usin the Loader (Probably not supported) #340

Open
MaartenS11 opened this issue Jan 17, 2025 · 3 comments
Open

Can't load wasm usin the Loader (Probably not supported) #340

MaartenS11 opened this issue Jan 17, 2025 · 3 comments

Comments

@MaartenS11
Copy link

I was going to try to read dwarf debugging info from a wasm binary but I get the error Error("Unknown file magic") is loading webassembly binaries and their associated dwarf debug info sections supported by the Loader in addr2line? I know gimli can load wasm binaries and their associated debugging info using the object crate but it seems the loader might work differently here in addr2line.

I'm currently just doing something like this. Any help appreciated!

let loader = Loader::new(wasm_binary).expect(&format!("Failed to get dwarf info for \"{}\"", wasm_binary));
loader.find_location(150);
@MaartenS11
Copy link
Author

Looking at it a bit more it seems I just need to enable to wasm feature on the object crate used by addr2line. I'm not really an expert at rust, what is the best way to specify this? Currently I just have this and this seems to work but this doesn't seem ideal.

object = { version = "0.36.0", features = ["wasm"] }
addr2line = "0.24.2"

@philipc
Copy link
Contributor

philipc commented Jan 18, 2025

For now, that's all you can do.

We could add a wasm feature to addr2line that in turn enables wasm for object. However, before doing that I would like confirmation that using addr2line for Wasm is actually useful for you. The reason I ask is because I think that the normal use case for DWARF in Wasm files is that when compiling the Wasm to native instructions, the DWARF will get transformed to match the native addresses, and addr2line is used on that transformed DWARF instead.

@MaartenS11
Copy link
Author

The VM which I use for development does not compile wasm down to native instructions, it is a traditional bytecode interpreter. Consequently, the program counter is a location in the original wasm binary and I use the dwarf in the binary itself to map that program counter into a line number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants