Debugging RTL/VCL Code with CodeSite

By | September 15, 2017

I managed to do something the other day I don’t know you could do involving debugging and Code Site.

Code Site is my go to tool for logging information and usually I’ll add Code Site to my library path and embed the unit reference in code like this:

Uses
  SystemSysUtils,
  {$IFDEF DEBUG}
  CodeSiteLogging,
  {$ENDIF}
  VCL.Classes;

and then call Code Site with a simple call like this:

CodeSite.Send('MyLabel', AVariable);

Obviously to do this you need to alter the source code which is find for your own code but not okay for the Embarcadero RTL/VCL code.

What I found was that I could place a CodeSite.Send() statement in a breakpoint evaluation and this would output the message as shown below:

There are some prerequisites for this to work as follows:

  1. First you need Code Site. There is a free express version in GetIt;
  2. You need to add Code Site to your library path;
  3. You need to debug with debugging DCUs;
  4. You need to add CodeSiteLogging to one of your uses clauses so its compiled into your application.

This allows me to debug an issue in the VCL with TDockTabSet not closing a form but hiding it. I think its a bug (and I’ll raise it if its not already raised) but have found a workaround for my application.

I hope this is helpful to you all.

regards Dave