wabt icon indicating copy to clipboard operation
wabt copied to clipboard

Document wasm-interp trace output

Open jiayihu opened this issue 4 years ago • 0 comments

Is there any documentation on how to read the wasm-interp trace output? I can intuitively understand some of it, but most of the output is ambigous to me. For instance I was debugging an issue:

>>> running export "bench":
#0.    0: V:0  | alloca 4
#0.    8: V:4  | global.get $0
#0.   16: V:5  | i32.const 32
#0.   24: V:6  | i32.sub 16, 32
#0.   28: V:5  | local.set $5, 4294967280
#0.   36: V:4  | i32.const 0
#0.   44: V:5  | local.set $4, 0
#0.   52: V:4  | local.get $3
#0.   60: V:5  | i32.const 4
#0.   68: V:6  | i32.eq 0, 4
#0.   72: V:5  | br_unless @88, 0
#0.   88: V:4  | local.get $4
#0.   96: V:5  | i32.const 28
#0.  104: V:6  | i32.add 4294967280, 28
#0.  108: V:5  | local.get $4
#0.  116: V:6  | i32.add 12, 0
#0.  120: V:5  | i32.const 0
#0.  128: V:6  | i32.store $0:12+$0, 0
#0.  140: V:4  | local.get $3
#0.  148: V:5  | i32.const 4
#0.  156: V:6  | i32.add 0, 4
#0.  160: V:5  | local.set $4, 4
#0.  168: V:4  | br @52
#0.   52: V:4  | local.get $3
#0.   60: V:5  | i32.const 4
#0.   68: V:6  | i32.eq 4, 4
#0.   72: V:5  | br_unless @88, 1
#0.   80: V:4  | br @176
#0.  176: V:4  | i32.const 0
#0.  184: V:5  | local.set $4, 0
#0.  192: V:4  | local.get $4
#0.  200: V:5  | i32.load $0:4294967280+$28
bench() => error: out of bounds memory access: access at 4294967308+4 >= max value 65536

I don't know what the first value #0 is, or what the second column values (0, 8, 16...) are, what V:5 stays for and so on. I can imagine it is obvious for most of you who closely work on Wasm compilers/interpreters, but for a non-expert a little help would be valuable.

My guess would be that the first column is the call stack depth maybe? The column column is the value stack size, the V: x is the value at the top of the value stack depth, and then finally the instruction where the implicit operands taken from the top of the stack are made explicit.

jiayihu avatar Apr 11 '21 15:04 jiayihu