Stream: wasmtime

Topic: ✔ Get invoked function name when module invokes hostcalls


view this post on Zulip Jeff Charles (Apr 11 2022 at 17:10):

I'd like to log the hostcalls a wasm module running on wasmtime is making. I can see there's a call hook API that I can use to invoke a function whenever a hostcall is invoked. But I can't see a way to determine the name of the host function invoked. Is it possible to get the name of the host function invoked within the function provided to call_hook or an alternative API that would expose this information?

view this post on Zulip Alex Crichton (Apr 11 2022 at 17:15):

It's true that the import name is not available to the call hook and I don't think there's other means by which you can get this right now. That being said I don't think this is something that we can easily support because functions are hooked up as values to one another which means that there's not necessarily a defined name in the embedding api for a particular function.

Is this something possible you can inject into the host functions themselves or are you looking to primarily hook this at the engine level? One thing we might be able to do is to auto-inject hooks at the Linker layer rather than the Store layer

view this post on Zulip Jeff Charles (Apr 11 2022 at 18:09):

I don't think we can inject this into the host functions themselves. Right now, it's mostly calls out to WASI functions that we want to log rather than logging proprietary calls that we've implemented ourselves. I'm not sure if there's a clean way for us to implement a decorator pattern that would include our logging with how the WASI calls are wired up in wasmtime. Doing it at the engine level would be one approach that helps get around that.

view this post on Zulip Alex Crichton (Apr 11 2022 at 23:18):

Sorry forgot to respond earlier today, mind opening an issue to track this? There are a few ways we could go about this and having something on file as a place to discuss would be good

view this post on Zulip Jeff Charles (Apr 12 2022 at 15:02):

I've opened this Github issue to track this.

Feature I'd like a way to retrieve the name of the invoked hostcall in a call hook. Ideally getting the arguments and return values would also be useful. Benefit Adding this feature would allow...

view this post on Zulip Notification Bot (Apr 12 2022 at 15:02):

Jeff Charles has marked this topic as resolved.


Last updated: Nov 22 2024 at 16:03 UTC