CRMScript: improved tracing and call stack information

Hi,

This is a small announcement of some improvements to CRMScript tracing that will be available in next release.

I believe the tracing capability is a cool feature to figure out what a script was doing. However, viewing some traces of large scripts using Ganske Enkelt's HTTP modules, we soon realized that navigating a trace can be quite confusing since the trace will step down into every single function call. There was no "Step over" function, allowing you to go to the next line in the code, and not into the function call on the current. One of the reasons for this was that in fact CRMScript did not keep track of it's current call stack depth. We have now added this, and it is saved with the tracing information. This allows you to do much more advanced stepping when viewing a script trace:

The buttons now allow you to:

  • Step back: Go back to the previous statement at the same call stack depth as you are. Normally this is one line up in the code, even if the previous statement was actually inside a sub function.
  • Step in: The same as "next" before, which means go to the next trace frame. This will go inside a function call, or e.g. into an event handler called by ticket.save().
  • Step out scope: This one we should trademark, since I have not seen it in any other development environment I know. It will step out from the current variable scope. For instance, if you are inside a loop, it will go to the next statement outside that loop.
  • Step out: This is the classic step out, which will go out of the current function.
  • Step next: Same as "Step over", meaning go to the next statement at the same or higher call stack level. I.e. do not step into functions.

As a side effect of this system, we now also have a more detailed call stack when executing CRMScript. We have modified the information printed on exceptions to include this stack, with a cleaned up "source location" system giving you some better information about where your script crashed:

 

Hope this will be useful :-)

Sverre

 

RE: CRMScript: improved tracing and call stack information

Nice work Sverre! This will save some time when debugging complex CRMScripts! :)

Any indication when this will be available in production?

Af: David Hollegien 21. jun 2020

RE: CRMScript: improved tracing and call stack information

Aha, that's nice!

Af: Frode Lillerud 21. jun 2020

RE: CRMScript: improved tracing and call stack information

That's a great addition to CRMScript.

Af: Henk Bergevoet 22. jun 2020

RE: CRMScript: improved tracing and call stack information

That sounds pretty cool. It is a great feature!

Af: Georg Diczig 22. jun 2020