-
Notifications
You must be signed in to change notification settings - Fork 726
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
wasm2wat can't read debug names of params / vars #1290
Comments
The was format specifies a way to provide names for various elements (functions, variables, etc.) in a custom name section. This has been in the spec for a long time, and wabt tools (including wasm2wat) support it. The dwarf section data is much newer, and wabt tools do not yet support it. I don't know if there's a way for LLVM to produce both sections (@tlively do you know?) |
Redirecting to @kripken for comments on how debuginfo works with the name section. |
I think the two sections are orthogonal. A wasm file can have both DWARF debug sections (that include name info) and a Names section, that's what happens in practice actually when you build with |
so it's incompatibility issue, since we have two types of debug sections... what's the global plan for wasm debug sections? is wasm spec Name section going to be stripped in favor of DWARF section, or somehow extended to have all metadata DWARF has? what's more appropriate to do right now? ask i've tried to compile simple c++ function with |
The name section allows assigning names to wasm locals. When you compile using clang or rustc, the variables often are not presented as wasm local. It can be a location in memory (via shadow stack) or placed on the operand stack, be a constant, just a wasm var/param. Or it can be all of the above but in different parts of the wasm function. IMHO the name section is useless in presenting original language variable names. At this moment DWARF's .debug_info section is the best way to represent original language variable locations. See docs for DW_TAG_variable. Also, keep in mind, if output wasm from clang or rustc, processed by wasm-pack, wasm-opt or any other tools, the DWARF section information/references are invalid. |
i'm compiling rust project to wasm with
wasm-pack
, then converting resulting wasm to wat and trying to read it.currently I can find functions by their original names, but function params and variables lack original names.
so for this rust function
i have this wat
there's only auto generated names for params/vars like
$p0
,$p1
,$l1
,$l2
, etc.but this is strange because I've configured rust project to include DWARF debug symbols to wasm
i can even see those
my_param
andmy_arg
strings in target wasm fileapparently original names for params/vars are included in wasm, but
wasm2wat
cannot find them.also i've checked that wasm file in dev tools of chrome and firefox, and i don't see original params/vars there either (i assume those browsers have their own wasm to wat converters)
also i've tried to write simple function in wat, feed it to
wat2wasm
, and then feed resulting wasm towasm2wat
back again. and i see that custom names for params are preserved. it meanswasm2wat
can extract param names from wasm ok.simple function in wat
so i assume that problem is
wasm-pack
, which generates invalid debug symbols, sowasm2wat
cannot extract themwasm2wat
, which cannot read valid debug symbols from wasmany thoughts?
i've created minimum rust project for testing.
wasm_debug_symbols_bg.wasm (from
wasm-pack
)wasm_debug_symbols_bg.wat (from
wasm2wat
)The text was updated successfully, but these errors were encountered: