scilla
scilla copied to clipboard
Implement a tracer/debugger for Scilla evaluation
Generalise from the "Result" monad, used now to bind sub-evaluations together (via Functors) and instantiate it differently in a debug mode.
@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 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 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).
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 (?)
@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.
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 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.
Related effort in the Scilla compiler project: https://github.com/Zilliqa/scilla-compiler/wiki/A-Debugger-for-Scilla-:-The-Beginning