miden-vm icon indicating copy to clipboard operation
miden-vm copied to clipboard

On failure report the opcode position

Open hackaugusto opened this issue 2 years ago • 0 comments

Feature request

Report the opcode position in addition to the cycle at which the VM failed. For example, with this assembly:

begin
    push.20
    dup neq.0 while.true
        sub.1 dup neq.0
    end

    push.0 assert
end

The opcode that fails is the assert after push, which is the 11th word on the assembly. But the error reports the number 172, which is unclear what it means (from testing it doesn't appear to be the clock cycle). This is a problem for large assemblies with dozens of places where a failure can occur, since one can't easily tell what is causing the error. Ideally the report would be the source code position in column/row format. But I suppose this information is not always available, so here are a few ideas:

  • Dump the top 16 elements on the stack and the 5 opcodes before and after the failing one
  • Report the path to the opcode (I assume we don't always have the absolute opcode offset, because not every branch is opened)

hackaugusto avatar Jan 13 '23 08:01 hackaugusto