Stream: SIG-Debugging

Topic: missing mapping info in DWARF?


view this post on Zulip Yoshua Wuyts (May 13 2024 at 11:58):

Heya! - I was chatting with the author of Wasmphobia (@Surma) about adding Component support to their wasmphobia project (wasm binary -> code size flame graph tool), and we noticed that several sections don't seem to carry any DWARF information.

view this post on Zulip Yoshua Wuyts (May 13 2024 at 11:59):

Some of that is expected and can probably be resolved - but maybe 1/3 of the @section: code seems to not have any information, and that doesn't seem right?

image.png

view this post on Zulip Yoshua Wuyts (May 13 2024 at 11:59):

Surma specifically asked the following:

I was under the impression that — even in the component model — all code from all modules would be in the code section. So I’d expect that DWARF debugging data would provide correct attributions. Am I wrong?

Heya! I was trying to upload some of my WASI 0.2 experiments, and I'm getting the following error: Could not create flamegraph: Error: Unsupported Wasm encoding I assume this has something to do wi...

view this post on Zulip Yoshua Wuyts (May 13 2024 at 12:02):

I don't know whether this is expected, a limitation of Wasm Components, of our current tooling, or perhaps a bug in wasmphobia. I figured this would be the right place to ask people who are more clued in than I am. Any help here would be appreciated!

view this post on Zulip Ralph (May 13 2024 at 12:05):

wasm-tools (or the language equivalent) doesn't inject the dwarf properly yet.

view this post on Zulip Ralph (May 13 2024 at 12:06):

I had been chatting with @Till Schneidereit about this at wasmio and @fitzgen (he/him) prior to wasmio, and we had a few steps that we need to take.

view this post on Zulip Ralph (May 13 2024 at 12:06):

among them that llvm-dwarfdump doesn't understand the component file format yet, for example.

view this post on Zulip Yoshua Wuyts (May 13 2024 at 12:06):

ahhh, ok! thank you!

view this post on Zulip Yoshua Wuyts (May 13 2024 at 12:07):

So I thought https://github.com/rustwasm/wasm-bindgen/issues/2389 was the issue tracking that, and since it had been closed all known issues had been resolved

Motivation Chrome, Firefox and now also Sentry support DWARF for WebAssembly as debug format. In particularly for crash reporting systems like Sentry DWARF is a very important tool to create accura...

view this post on Zulip Yoshua Wuyts (May 13 2024 at 12:07):

I didn't realized there was outstanding work here

view this post on Zulip Yoshua Wuyts (May 13 2024 at 12:08):

Are there any open issues about this I could link to?

view this post on Zulip Ralph (May 13 2024 at 12:08):

wasm-bindgen works FINE

view this post on Zulip Ralph (May 13 2024 at 12:09):

wasi 1.0 (which is just wasm core with structure!) works fine with mild exceptions like not enough type information because the wasm compilers are trying to optimize out code steps.

view this post on Zulip Ralph (May 13 2024 at 12:10):

I was able to get components to retain dwarf info, but I couldn't find a debugger to pick it up at all, so I'm entirely unsurprised here

view this post on Zulip Ralph (May 13 2024 at 12:12):

it had been my intention to work with Nick to figure out which steps hit the biggest bang for the buck here, or whether we might parallelize our work. His presentation on work needed was here: https://github.com/bytecodealliance/rfcs/pull/34

Implement guest debugging capabilities in Wasmtime and integrate those abilities with surrounding debugging toolchains. Rendered Co-authored-by: Nick Fitzgerald - @fitzgen Co-authored-by: Rainy Si...

view this post on Zulip Ralph (May 13 2024 at 12:12):

So if you wanna have fun, and I know you do, try using a wasi preview 1 module with dwarf in wasmphobia and I would expect it to work!!!

view this post on Zulip Ralph (May 13 2024 at 12:12):

but components, NOPE, not yet

view this post on Zulip Yoshua Wuyts (May 13 2024 at 12:13):

ok ok ok, so what I'm hearing is that this is an LLVM / Rust Toolchain issue more than anything else?

view this post on Zulip Ralph (May 13 2024 at 12:13):

BTW, using flamegraphs with dwarf info would be the BOMB and I'll help doing anything to make that begin working

view this post on Zulip Yoshua Wuyts (May 13 2024 at 12:14):

@Ralph fwiw wasmphobia already supports components now! - this is just about making that better

view this post on Zulip Yoshua Wuyts (May 13 2024 at 12:14):

filling out the final missing sections

view this post on Zulip Ralph (May 13 2024 at 12:14):

Yoshua Wuyts said:

ok ok ok, so what I'm hearing is that this is an LLVM / Rust Toolchain issue more than anything else?

for the original dwarf insertion, but ALSO the compilation step needs to be able to NOT optimize away tons of code

view this post on Zulip Ralph (May 13 2024 at 12:14):

Yoshua Wuyts said:

Ralph fwiw wasmphobia already supports components now! - this is just about making that better

WAIT WUT

view this post on Zulip Ralph (May 13 2024 at 12:14):

WAIT WUT

view this post on Zulip Yoshua Wuyts (May 13 2024 at 12:14):

Yoshua Wuyts said:

Some of that is expected and can probably be resolved - but maybe 1/3 of the @section: code seems to not have any information, and that doesn't seem right?

image.png

hehehe yeah this right here

view this post on Zulip Yoshua Wuyts (May 13 2024 at 12:15):

this is my wasm-http-tools concurrent HTTP client example

view this post on Zulip Yoshua Wuyts (May 13 2024 at 12:15):

surma got it working yesterday

view this post on Zulip Ralph (May 13 2024 at 12:15):

that is EITHER an insertion bug OR a wasmtools bug/compile opt

view this post on Zulip Ralph (May 13 2024 at 12:15):

Yoshua Wuyts said:

surma got it working yesterday

who is this Surma person and how do we get them more donuts?

view this post on Zulip Ralph (May 13 2024 at 12:15):

Does Surma have a gofundme for donuts?

view this post on Zulip Ralph (May 13 2024 at 12:16):

_gets out wallet_

view this post on Zulip Yoshua Wuyts (May 13 2024 at 12:17):

haha, yeah Surma is great

view this post on Zulip Alex Crichton (May 13 2024 at 14:51):

Reading over the component support I think that there may need to be a bit more refactoring to support components. Right now it's slurping all dwarf sections into one object when each core wasm module will need to be treated separately. I'm not sure if that'd explain the current thing you're seeing though, it depends on the size of the component. Additionally though there's going to be multiple code sections within a component so it'd be good to confirm that the dwarf info is relative to the right code section start.

Additionally though I see that the "component-type" custom section is in the component that has a flame graph, but that should be stripped out by wit-component when a component is created, so that's also suspect (but perhaps just a bug in wit-component?)

view this post on Zulip Ralph (May 13 2024 at 15:11):

right. So some sorting out of these things is necessary.

view this post on Zulip Ralph (Aug 19 2024 at 16:30):

following up! finally. https://hachyderm.io/deck/tags/webassembly shows that you can do this now with a component using wasmtime serve in v23.1

Hachyderm is a safe space, LGBTQIA+ and BLM, primarily comprised of tech industry professionals world wide. Note that many non-user account types have restrictions - please see our About page.

view this post on Zulip Ralph (Aug 19 2024 at 16:31):

image-8.png

view this post on Zulip Ralph (Aug 19 2024 at 16:31):

look at all those handles!!!

view this post on Zulip bjorn3 (Aug 19 2024 at 19:38):

You probably meant to link https://hachyderm.io/@squillace/112989210932769282

Attached: 1 video Back in March at #wasmio, @anfibiacreativa@mastodon.social and I showed a WIDE array of #webassembly debugging in #vscode: https://www.youtube.com/watch?v=sofGOtwGWu8. But, you'll note: the debugger couldn't navigate #webassemblycomponent files. Now it can!

view this post on Zulip Ralph (Aug 19 2024 at 19:39):

Dammit

view this post on Zulip Ralph (Aug 19 2024 at 19:39):

Yes

view this post on Zulip Ralph (Aug 19 2024 at 19:41):

Thank you, @bjorn3


Last updated: Dec 23 2024 at 12:05 UTC