We have been discussing such a feature again and again - we just never found the time to do it! I.e. yes this would be a fantastic contribution!
A simple way if implementing this is to:
add an interpreter state that is toggled by .trace, and if enabled:
dump the AST of the transaction
dump the IR / module that CodeGen creates of the transaction
and then maybe even show the symbols that OrcJIT emitted.
At a later stage we could have .trace symbol and only trace the declarations / symbols whose names contain "symbol". We already have a rudimentary start of this, see MetaParser::istraceCommand().
That would indeed be a super useful tool: for teaching, for understanding and debugging code, and even for debugging cling!
Let me know whether you’d be interested in trying to contribute this. We would be happy to help!
I just tried out .trace ast and was delighted to see that indeed, it does print out something. However, it’s a lot and I couldn’t easily decipher where it starts and ends
Are there more docs somewhere around .trace? do you have to start tracing, and then stop at some point + print?
Sure, I’d be happy to contribute. I’ll have to figure out how much work it is, though.
So far I’ve been able to hack cling so that it prints the LLVM bytecode for every execution. That was actually really simple, as I am just calling M->dump() (or M->print(...)) on the generated module.