Stream: general

Topic: function names


view this post on Zulip Joey Gouly (Mar 04 2020 at 11:47):

I compiled a rust program cargo build --target wasm32-wasi, I guess that exported functions can be mapped back to rust ones, but is there a way to map non-exported ones? (This is so I can find the rust code that generates some big wasm/clif)

view this post on Zulip Alex Crichton (Mar 04 2020 at 14:52):

@Joey Gouly you mean like exploring a wasm module via the wasmtime API, or just figuring info about the wasm itself?

view this post on Zulip Joey Gouly (Mar 04 2020 at 14:54):

@Alex Crichton the latter. I found a function that takes a long time to compile, and want to figure out the rust code it came from

view this post on Zulip Alex Crichton (Mar 04 2020 at 14:55):

hm wanna gist the wasm module?

view this post on Zulip Alex Crichton (Mar 04 2020 at 14:55):

and/or do you have the rust source to poke around?

view this post on Zulip Alex Crichton (Mar 04 2020 at 14:55):

oh one other thing you may be able to do is to use llvm-dwarfdump somehow

view this post on Zulip Alex Crichton (Mar 04 2020 at 14:56):

I know nothing about dwarfdump but there's presumably filename/location information in there somewhere

view this post on Zulip Alex Crichton (Mar 04 2020 at 14:56):

esp for a debug build

view this post on Zulip Joey Gouly (Mar 04 2020 at 14:57):

I guess the problem with a debug build is that it might not match up to the release one

view this post on Zulip Joey Gouly (Mar 04 2020 at 14:58):

but rust has debug info by default, so I'll give it a try

view this post on Zulip Yury Delendik (Mar 04 2020 at 14:58):

release builds can still have DWARF info

view this post on Zulip Yury Delendik (Mar 04 2020 at 14:59):

name section normally contains rust names for every function

view this post on Zulip Joey Gouly (Mar 04 2020 at 15:01):

Oh, and I guess wasm2wat uses that? I just tried wasm2wat and see the names

view this post on Zulip Yury Delendik (Mar 04 2020 at 15:05):

@Joey Gouly cranelift has ability to read name section -- maybe there is a way to plug that into clif or just instrument code in some other way

view this post on Zulip Joey Gouly (Mar 04 2020 at 15:07):

@Yury Delendik in cranelift/src/wasm.rs line ~175, would be a good place to print it. have you got some pointers on how to do that?

view this post on Zulip Yury Delendik (Mar 04 2020 at 15:12):

@Joey Gouly is DummyEnvironment used by that? it needs to implement declare_func_name https://github.com/bytecodealliance/wasmtime/blob/8597930eed2e5e92c78ec4cb6d6b39d80c5ea220/cranelift/wasm/src/sections_translator.rs#L429

Standalone JIT-style runtime for WebAssembly, using Cranelift - bytecodealliance/wasmtime

view this post on Zulip Joey Gouly (Mar 04 2020 at 15:14):

thanks, it does implement that! I'll try print from that then


Last updated: Dec 23 2024 at 12:05 UTC