ejrgilbert / whamm

Debugging WebAssembly? Put some Whamm! on it.
https://ejrgilbert.github.io/whamm/
16 stars 3 forks source link

Support Injecting Arbitrary `wat` code #136

Open ejrgilbert opened 3 months ago

ejrgilbert commented 3 months ago

Justification

It may be easier for the user to express their instrumentation by directly writing wat code.

Example

wasm:opcode:if:before {
    wat {
        i32.const 0
        drop
    }
}

Further Ideas

What if we expanded this to enable writing a script for postprocessing inside the whamm script itself, e.g.:

END {
    // (The END will need to feed some data into python that can be post-processed (e.g. report vars, CSV file, etc.))
    //  ||  ||  ||
    //  V V V
    python {
        // Python script to perform the postprocessing steps
        ......
    }
}

The output of whamm would be:

  1. app.mon.wasm: the instrumented wasm module
  2. app.mon.py: the python script referenced in the END
  3. run.bash OR Makefile: A file that runs app.mon.wasm and then calls app.mon.py with the relevant data as args