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 ...
Peter Sherman
source share