Ultimate Delphi Debug Guide

Is there a complete debugging resource in Delphi that instructs on how to use all IDE debugging tools? There used to be a manual from Marco CantΓΉ, but it has been updated to Delphi 5, if I'm not mistaken.

Can you redirect me to a full resource, updated at least to D2009 (better if XE).

+8
debugging delphi
source share
4 answers

The IMO official debugging documentation is comprehensive: Debugging Applications and Debugging Applications . AFAICS two sites have the same content, but the latter may be more relevant.

I would also like to mention the Warren Postma remote debugging tutorial that helped me get started as soon as possible.

+5
source share

The PDF debugging resource did not mention my favorite debugging technique:

Let's say you wanted to break if you were satisfied with a specific, complex, accessible only at execution.

Can say

if <MyExpressionA> then asm int 3; // Enter CPU Debugger end; Or you could say if not <MyExpressionB> then asm int 3; // Enter CPU Debugger end; 

Where ExpressionA is that you NEVER expect to be true (i.e. if it is true, it signals an abnormal state), OR where ExpressionB is that you ALWAYS expect to be true (that is, if it is false, it signals an abnormal condition).

Remember that any expression can contain several function calls - if you need them.

You can put them inside a block inside {$ IFDEF DEBUG}, for example:

 procedure MyProcedure; var X: Integer; begin X := GetTheAnswerToLifeTheUniverseAndEverything(); {$IFDEF DEBUG} if X <> 42 then // Highly contrived example asm int 3; // Enter CPU Debugger -- Press F8 when here to step back into source... end; {$ENDIF} // More code here... end; 

You can also use

ASSERT (expression, "message"); ASSERT (not an expression, "message");

To make sure that your code functions properly.

If ASSERTs are included in the IDE and ASSERT fails, ASSERT will throw an exception that will disable the stack until the last exception handler for its type ...

Using my int3 method - you immediately get to the processor debugger - where, if you press F8 (go), you will go to the next line of code - you can check the variables, see the whole call stack, and even continue the step in your code ...

+5
source share

Internet is your friend, here are two debugging links

Delphi - debugging methods

[PDF] http://www.scip.be/ScipViewFile.php?Page=ArticlesDelphi11

The content in it is still very relevant.

+3
source share

Also invest some time in the exception handling infrastructure, for example:

There are all good things like stack traces, line numbers, etc.

+3
source share

All Articles