miden-vm
miden-vm copied to clipboard
On failure report the opcode position
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 the5
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)