Debugging

To support basic debugging capabilities, Miden assembly provides a debug instruction. This instruction prints out the state of the VM at the time when the debug instruction is executed. The instruction can be parameterized as follows:

  • debug.stack prints out the entire contents of the stack.
  • debug.stack.<n> prints out the top items of the stack. must be an integer greater than and smaller than .
  • debug.mem prints out the entire contents of RAM.
  • debug.mem.<n> prints out contents of memory at address .
  • debug.mem.<n>.<m> prints out the contents of memory starting at address and ending at address (both inclusive). must be greater or equal to .
  • debug.local prints out the whole local memory of the currently executing procedure.
  • debug.local.<n> prints out contents of the local memory at index for the currently executing procedure. must be greater or equal to and smaller than .
  • debug.local.<n>.<m> prints out contents of the local memory starting at index and ending at index (both inclusive). must be greater or equal to . and must be greater or equal to and smaller than .

Debug instructions do not affect the VM state and do not change the program hash.

To make use of the debug instruction, programs must be compiled with an assembler instantiated in the debug mode. Otherwise, the assembler will simply ignore the debug instructions.