All Projects → wasm3 → node-wasm-trace

wasm3 / node-wasm-trace

Licence: MIT License
Instruments wasm files and traces execution

Programming Languages

javascript
184084 projects - #8 most used programming language
WebAssembly
147 projects
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to node-wasm-trace

Wasmtime
Standalone JIT-style runtime for WebAssembly, using Cranelift
Stars: ✭ 6,413 (+26620.83%)
Mutual labels:  webassembly, wasi
Wasmer
🚀 The leading WebAssembly Runtime supporting WASI and Emscripten
Stars: ✭ 11,047 (+45929.17%)
Mutual labels:  webassembly, wasi
Lucet
Lucet, the Sandboxing WebAssembly Compiler.
Stars: ✭ 4,006 (+16591.67%)
Mutual labels:  webassembly, wasi
Uftrace
Function graph tracer for C/C++/Rust
Stars: ✭ 1,986 (+8175%)
Mutual labels:  trace, tracer
shield-dubbo-tracer
基于dubbo2.6.4的Dubbo TraceId的设置/获取/传递工具包
Stars: ✭ 28 (+16.67%)
Mutual labels:  trace, tracer
Lunatic
Lunatic is an Erlang-inspired runtime for WebAssembly
Stars: ✭ 2,074 (+8541.67%)
Mutual labels:  webassembly, wasi
Tinygo
Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
Stars: ✭ 9,068 (+37683.33%)
Mutual labels:  webassembly, wasi
barectf
Generator of ANSI C tracers which output CTF data streams
Stars: ✭ 50 (+108.33%)
Mutual labels:  trace, tracer
Trace
Creates super long stack traces
Stars: ✭ 183 (+662.5%)
Mutual labels:  debugging, trace
Tapping device
TappingDevice makes objects tell you what they do, so you don't need to track them yourself.
Stars: ✭ 296 (+1133.33%)
Mutual labels:  debugging, trace
peekaboo
An standalone execution trace library built on DynamoRIO.
Stars: ✭ 17 (-29.17%)
Mutual labels:  trace, tracer
node-wasi
WASI for Node.js
Stars: ✭ 64 (+166.67%)
Mutual labels:  webassembly, wasi
jquery-manager
Manage jQuery and jQuery Migrate on a WordPress website, activate a specific jQuery and/or jQuery Migrate version. The ultimate jQuery debugging tool for WordPress
Stars: ✭ 27 (+12.5%)
Mutual labels:  debugging
tracehash
Compress long exception traces down to short signatures
Stars: ✭ 20 (-16.67%)
Mutual labels:  debugging
lxgui
Portable, real time, modular and data-driven GUI C++ library.
Stars: ✭ 50 (+108.33%)
Mutual labels:  webassembly
swam
WebAssembly engine in Scala
Stars: ✭ 38 (+58.33%)
Mutual labels:  webassembly
ycecream
Sweeter debugging and benchmarking Python programs.
Stars: ✭ 38 (+58.33%)
Mutual labels:  debugging
wgpu-rust-renderer
A tiny WebGPU renderer written in Rust
Stars: ✭ 81 (+237.5%)
Mutual labels:  webassembly
cache-trace
A collection of Twitter's anonymized production cache traces.
Stars: ✭ 89 (+270.83%)
Mutual labels:  trace
apollo-link-tracer
Trace your apollo queries and mutations with https://github.com/apollographql/apollo-link
Stars: ✭ 20 (-16.67%)
Mutual labels:  trace

wasm-trace

Instruments wasm files using Binaryen.js, runs them and traces execution

Areas of application

  • Wasm/WASI debugging
  • Wasm engine and runtime debugging
  • Quality assurance and maintenance
  • Security research
  • Reverse engineering

Install

npm install -g wasm-trace

Example

$ wasm-trace -ELM ./test/hello.wasm
[tracer] Instrumenting and optimizing...
[tracer] Running WASI...
Hello WebAssembly!
[tracer] Processing...

The trace can be found in trace.log:

     2 |     | enter _start {
     0 | i32 |   set    0 70784
    43 |     |   enter __wasilibc_init_preopen {
     6 |     |     enter malloc {
    38 | i32 |       get    0 16
    23 |     |       enter dlmalloc {
    39 | i32 |         set    1 70768
    40 | i32 |         get    0 16
     8 | i32 |         load   0+3424 0
    41 | i32 |         set    2 0
       |     |         ...

How it works

  1. Analyzes the input wasm file (checks for WASI, instrumentation, etc.)
  2. Instruments it using Binaryen.js
  3. Runs the instrumented file with injected instrumentation handlers
  4. Writes CSV trace file
  5. Post-processes the CSV trace file and produces a structured log file

Following Binaryen instrumentation passes are supported:

  • --execution logs execution at each function entry, loop header, and return
  • --memory intercepts all memory reads and writes
  • --locals intercepts all local reads and writes

Instrumentation, execution and post-processing stages are completely decoupled.
You can run each step separately:

  1. Add instrumentation to a wasm binary file.

    node ./wasm-trace.js -ELM --save-wasm=./instrumented.wasm ./test/hello.wasm

    Or using Binaryen directly:

    wasm-opt --log-execution --instrument-memory --instrument-locals ./test/hello.wasm -o ./instrumented.wasm
  2. Run instrumented wasm file.
    For Node.js, this step currently requires enabling bigint and wasi features:

    node --experimental-wasm-bigint --experimental-wasi-unstable-preview1 ./wasm-trace.js --save-csv=trace.csv ./instrumented.wasm

    Or using Wasm3:

    wasm3 ./instrumented.wasm        # The trace will be written to wasm3_trace.csv
  3. Analyze/post-process the CSV trace file.

    node ./wasm-trace.js --process=trace.csv ./instrumented.wasm        # Produces trace.log

Usage

wasm-trace.js [options] <file> [args..]

Options:
  --execution, -E    Instrument execution  [boolean]
  --locals, -L       Instrument locals  [boolean]
  --memory, -M       Instrument memory  [boolean]
  --optimize, --opt  Optimize (use --no-opt to disable)  [boolean] [default: true]
  --output, -o       Output filename  [string] [default: "trace.log"]
  --save-wasm        Save instrumented wasm to ...  [string]
  --save-csv         Save CSV log file to ...  [string]
  --process          Process CSV log file  [string]
  --invoke, -i       Invoke a specified function  [string]
  --version          Show version number  [boolean]
  --help             Show help  [boolean]

Examples:
  wasm-trace.js -E ./test/hello.wasm                     Instrument, run and trace WASI app
  wasm-trace.js -ELM --invoke=fib ./test/fib32.wasm 20   Instrument, run and trace plain wasm file
  wasm-trace.js ./test/hello.instrumented.wasm           Run pre-instrumented wasm file
  wasm-trace.js --process=trace.csv ./instrumented.wasm  Just process an existing CSV trace file
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].