Search code examples
delphidebuggingdelphi-xe5

What does '()' mean in the Delphi Debugger?


The value '()' keeps coming up whenever I inspect or watch an expression in the Delphi debugger.

What does it mean ? And if it represents an object of some kind, how can I visualize that object's state ?


Solution

  • It can mean two different things, depending on whether you're looking at an array or an object.

    For an array, it means you have an array (usually a dynamic array) containing 0 elements.

    For an object, it's a bit more complicated. It means that you're examining an object that's declared as a type that does not contain any data members. If you're looking at a variable that's declared as TObject in the code (such as a Sender: TObject in an event handler), the actual type is almost certainly not TObject, but the debugger will evaluate it as the type it's declared as.

    To get actual data about the object, do this:

    • Pull up Evaluate/Modify (Ctrl-F7).
    • Evaluate the object's real type. (Sender.classtype)
    • Evaluate the object, cast to its real type. (TMyObject(Sender)). This will tell you what the object actually contains.