Shop OBEX P1 Docs P2 Docs Learn Events
Post-mortem debugging of time critical code — Parallax Forums

Post-mortem debugging of time critical code

ManAtWorkManAtWork Posts: 2,178
edited 2024-02-23 19:29 in Propeller 2

The graphical debug features of Spin2 are really handy to diagnose real time systems as you can watch what's going on like with a scope for hardware circuits. But sometimes the run-time impact of the serial communication is still too much even at 2MBd. For extremely time-critical code it's better to write the debug output to a logfile, set a trigger for "problem detected" and examine the logfile later (post-mortem).

I've written a bunch of functions for logging. I thought this might be useful for somebody else. It supports timestamping so the timing of all outputs are also recorded.

The first version was in Spin2 to make it usable for both PropTool and FlexProp users but I had problems with printf() and Eric is currently busy and can't help me out. So I have re-written it in C. I don't use the ellipsis operator (...) but implemented seperate functions Print0 to Print5() with different numbers of arguments, so it might look a bit clumsy. But the advantage is that the print functions can also be called from Spin.

If anybody finds it useful I'll add it to the Obex. Critique and suggestions welcome.

Comments

  • I just found out that one of the disadvantages is that if the main program crashes or hangs in an endless loop the trigger point is never reached and the logging buffer is not dumped. So I think I should start an extra cog with a watchdog/timeout. Would be good to add a lock to make it multi-cog proof, anyway.

Sign In or Register to comment.