Interactive interpreter with debugger

Clarification and motivation

Sometimes a need arises to debug a Michelson contract and a common approach is to execute instructions step-by-step and be able to inspect current state. gdb is one of the most popular examples. We are not aware of any debuggers for Michelson, so we would like to develop one.

Acceptance criteria

A new command should be added to the morley executable, let's call it debug. It takes path to a contract, parameter and storage. It also takes optional arguments that run has (which impact global blockchain state). When you launch it, it waits for some input from you and does something when you press Enter. Possible input:

  1. break – add a breakpoint. It's not clear what should be passed here, you should come up with design.
  2. go – interpret instructions until a breakpoint is reached.
  3. step – interpret only one instruction.
  4. stack – show current stack value. I think it makes sense to show whole stack when just stack is called, but also support stack 0 to show top of the stack, stack 1 to show the item after the top, etc. And stack 2 5 for ranges.
  5. gas – show current gas limit.
  6. Auxiliary commands like help, quit, exit, etc.

You are very welcome to add more commands if you think they make sense.

If you want, you can go further and turn it into a TUI application (e. g. using brick) which always displays current stack and gas limit somewhere and allows you to interact with debugger.