-
Notifications
You must be signed in to change notification settings - Fork 826
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
Add wasm-opt log-execution support #1210
Comments
I have created such tracer, based on |
That's great @vshymanskyy! I think it would be good to have it in Wasmer. I think creating a function that receives an import object, and returns the same import object vitaminized with the extra import would be a way to have it working for all different integrations (WASI, Emscripten and standalone). Any contribution on that front will be welcome (we can give guidance if needed!) |
I have uploaded some example input/output files here: |
@syrusakbary I have implemented support for Wasmer-js in the |
Implementation for Wasm3 was also quite simple: Here's an example of engine decoupling: $ wasm3 ./test/hello.instrumented.wasm
Hello WebAssembly!
$ wasm-trace --process=wasm3_trace.csv -o wasm3_trace.log ./test/hello.instrumented.wasm
[tracer] Processing...
$ cat wasm3_trace.log | head -n 10
2 | enter _start {
0 | set i32: 0 68256
41 | enter __wasilibc_init_preopen {
4 | enter malloc {
32 | get i32: 0 16
21 | enter dlmalloc {
33 | set i32: 1 68240
34 | get i32: 0 16
5 | load i32: 0+1056 0
35 | set i32: 2 0 @syrusakbary However, I expect some imported functions will change as the instrumentation gets more mature. So no rush, it may take time until it stabilizes. |
@vshymanskyy I'm looking into this now and ran into an issue: my copy of
|
Correct. This is performed by a custom pass I'm working on.
The pre-instrumented file (`./test/hello.instrumented.wasm`) contains this transformation.
However the API for this pass can change. I'd like to add tracing of imported function calls and arguments/return values.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Still relevant. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Feel free to reopen the issue if it has been closed by mistake. |
Motivation
wasm-opt --log-execution
allows to instrument an existing wasm file and trace execution.It would be great if wasmer could support running such files out of the box.
A use case for this would be:
Run an instrumented wasm file in multiple engines, compare the execution flow (with
diff
, etc).Proposed solution
The instrumented file imports
log_execution
function:(the number argument is just an id of a tracepoint).
This feature should be very simple to implement.
Whenever wasm module calls
env:log_execution
, the runtime should print the tracepoint id to a text log file (in current directory, i.e../wasmer_trace.log
).Additional context
There are also other tracing instrumentation options in
wasm-opt
, like--instrument-memory
,--instrument-locals
, which require implementing a few more imported functions, but would be really awesome to have them working out of the box. They should output to the same trace file.The text was updated successfully, but these errors were encountered: