scilla icon indicating copy to clipboard operation
scilla copied to clipboard

Implement a tracer/debugger for Scilla evaluation

Open vaivaswatha opened this issue 6 years ago • 8 comments

Generalise from the "Result" monad, used now to bind sub-evaluations together (via Functors) and instantiate it differently in a debug mode.

vaivaswatha avatar May 25 '18 09:05 vaivaswatha

@ilyasergey What is your opinion on extending the "DebugMessage" utility we recently added, to have "trace" in addition to "log" and perform tracing the execution similar to logging? (i.e., after executing each operation, we print a trace of what happened in that operation).

vaivaswatha avatar May 30 '18 05:05 vaivaswatha

@vaivaswatha Could you give a rough example of a "trace" you'd like to obtain.

Depending on the requirements, this can be done in a more or less intrusive way wrt. the interpreter logic.

ilyasergey avatar May 30 '18 19:05 ilyasergey

@ilyasergey I'm not sure. It could be something as simple as, after evaluation of each expression, print the before/after values of the variable (if any) that was changed. This is to aid debugging Scilla code (until we have a full fledged debugger in the toolchain).

vaivaswatha avatar May 31 '18 08:05 vaivaswatha

Based on offline discussion, assigning this to myself to implement the following:

  • Flags for the interpreter:
    • Debug verbosity level (statements, expressions, etc)
    • Where to output this stuff (file?)

Once that is complete, I will re-assign this to @ilyasergey for the following:

  • Show expression reductions (?)
  • Show state between statements (?)

vaivaswatha avatar Jun 12 '18 05:06 vaivaswatha

@ilyasergey I have added a branch tracer that has the global config for this. This allows setting a file output (or assumes stdout otherwise) and a trace level: none (default), statements, expressions.

Based on whether GlobalConfig.get_trace_file is empty or not, you decide where the trace goes to, and the level of the trace based on GlobalConfig.get_trace_level. Please let me know if you need any changes in this.

vaivaswatha avatar Jun 26 '18 01:06 vaivaswatha

I think I can make it easier by providing one interface (similar to logging) that you can send strings to, and that will decide where the output goes to. Hold on, let me do that.

vaivaswatha avatar Jun 26 '18 01:06 vaivaswatha

I think I can make it easier by providing one interface (similar to logging) that you can send strings to, and that will decide where the output goes to. Hold on, let me do that.

I've done this now. You can just use ptrace to print the traces.

vaivaswatha avatar Jun 26 '18 02:06 vaivaswatha

Related effort in the Scilla compiler project: https://github.com/Zilliqa/scilla-compiler/wiki/A-Debugger-for-Scilla-:-The-Beginning

anton-trunov avatar Jun 17 '22 13:06 anton-trunov