Guys, don’t forget that we’re talking about a pre-release beta. Everything can change till release. Also, all our gratitude for Embarcadero for allowing us to talk about these things.
…Once upon a time was a command line compiler. In text mode. You wrote the source in another editor. In text mode also. But the times changed. First, appeared the IDE. All together, way better. In the old text mode. The notion of integrated debugger appeared. What a relief. But in the text mode. But the times changed. We got graphical GUIs. We got form designers. Graphical. But the debugger remained, basically the same. In the old text mode, even if the text was shown in a graphical GUI. But not anymore… Introducing the Debug Visualizers. As we all know, one of the vital part of a Debugger is the so-called Evaluator (or Evaluation Engine) which surfaces itself in the Watches, Local Vars, Evaluate / Modify window etc. Basically is that piece of code which ‘transforms’ the variable name typed in by us in the appropriate value.
In other words, the Evaluator is responsible to ‘transform’ the text
'cMyFilePath' to ‘C:\Documents and Settings\FooUser\FooFile.txt’, showing the actual content of that variable.
As you remarked already, I use the word transform instead of perhaps a more appropriate term of evaluate. This is because it gives us the idea:
Hey, what if we can have more complex transformations of variables, not just simply evaluating their contents?
This is particularly useful when we speak about encoded data types like
TDateTime complex data types like objects.
Usually, for different encoded data types (but not only) is very nice to have a simple Visualizer called in-line visualizer which in fact can be seen like a function to transform the encoded variable in a string with the appropriate human meaning. Of course, for
TDateTime values this in-line visualizer would be based on
While the above is very handy for simple situations, a complex object cannot be displayed as a string and is necessary to open a Popup to display (ie. visualize) it. These are Popup Visualizers.
RAD Studio 2010 supports only one in-line visualizer / type (and if you’d ask me I don’t think that is really needed to support more – but of course is just my opinion).
But it can have multiple Popup Visualizers for a certain type. If a type has a Popup visualizer assigned to it, then a small icon appears next to the variable of that type. See for yourself bellow…
As you see, Delphi ships with some visualizers: one in-line for
TDateTime types (in the green circle) and at least one Popup visualizer for
TStringList types (the loupe icon in the red circle).
Pressing the icon, a popup menu appears showing us all the available visualizers for that type to choose from (in our case just one visualizer):
…and by choosing that visualizer it shows us the actual content of the
How is implemented?
The Debugger Visualizers are implemented as Experts (hence anyone can write such things) using some new
IOTA interfaces. For the interested ones, have a look at
ToolsAPI.Pas located in
The basic interfaces to look are:
IOTADebuggerVisualizer, IOTADebuggerVisualizerValueReplacer (this is for the in-line visualizer aka. Value Replacer), and
IOTADebuggerVisualizerExternalViewerUpdater (this is for the Popup Visualizer).
Source code? (the eternal question…)
Of course! For the editions which include the VCL source code the source for the Visualizers is located in
<RAD Studio Home>\source\Win32\Visualizers
I think that this opens a plethora of possibilities for debugging. We’ll come back after RAD Studio is released. But let me ask you a question:
How do you see possible enhancements of the debugger and / or ensuring code quality in the future? (Feel free to think and speak 🙂 )