Download presentation
Presentation is loading. Please wait.
1
Advanced Debugging in Delphi
Primož Gabrijelčič
2
Breakpoints
3
Basics F9 Run with debugging Shift+Ctrl+F9 Run without debugging
Ctrl+F2 Program reset F4 Run to current position F8 Step over F7 Trace into Shift+F7 Trace to next source line Shift+F8 Run until return F5 Toggle breakpoint Shift+F5 Enable/disable breakpoint
4
Settings Project, Options Tools, Options Delphi Compiler, Compiling
Optimization Stack frames Debug information Use debug .dcu‘s Tools, Options Debugger Options General Event log
5
Properties Enabled Condition Pass count slow code
DebugBreak(condition) GpStuff.pas, GpDelphiUnits on GitHub Pass count Narrowing down reproducible problems Enabled Shift-F5 TestConditionalDebugger I = 888 TestConditionalIf If I = 888 then sleep(0); TestConditionalDebugBreak DebugBreak(I = 888); badInitialization Debug dcus! F8, F8 F8, F7
6
Side effects Break Log message Eval expression Log call stack
OutputDebugString Loggers (CodeSite …) Log to console Log call stack Stack tracers (JVCL, MadExcept, EurekaLog, FastMM …) “FastMM” session TestEvaluate (Break) IntToStr(value.Value) TestOutputDebugString OutputDebugString(PChar(Format('%d', [value.Value]))); FormCreate: AllocConsole TestLogToConsole Writeln(value.Value); TestCallStack
7
Groups Group Enable group Disable group manual toggle Bkpt/group v
Disable group in btnCallStackClick Enable group in TestCallStackIntermediate2 Poženi še enkrat, da pokažeš, da se takoj ustavi
8
Multithreaded programs
Properties, Thread Freeze all other threads Thaw all threads CheckSomething
9
Exceptions Tools, Options Ignore subsequent exceptions
Debugger Options Embarcadero Debuggers Language Exceptions Ignore subsequent exceptions Handle subsequent exceptions ExceptionClass type EUnusedException = class(Exception); ExceptionClass := EUnusedEception;
10
Hardware breakpoints Address Data Limited number
Code execution Can be set on read-only memory Data Data access Limited number DR0 … DR3 Disabled on program restart TTestObject.Create
11
Getting out of assembler
Return from method Selective Debugging Expert by Uwe Raabe Call stack breakpoints ShowMessage Selective debugging expert ReturnFromMethod
12
Tidbits Moving a breakpoint Moving execution point
with mouse Options, Line number Moving execution point Set next statement “repeat last statement” Use with care! Call stack breakpoints Disable/enable all Watch out for inline! Call stack breakpoints ShowMessage Selective debugging expert ReturnFromMethod
13
Evaluate & Watch
14
Evaluating expressions
Ctrl+F5 Add watch Ctrl+F7 Evaluate/Modify Alt+F5, Ctrl+Shift+click Inspect
15
Evaluate / Watch Display format specifiers Groups
x, h, d ,r <repeat> Groups A A,x A,r a.Signature a.Signature^ a.Signature^,20 PChar(a.Signature)^ PChar(a.Signature)^,20 string(a.Signature)
16
Optimizer DontOptimize procedure DontOptimize(var data); begin
// do nothing end;
17
Debugging remotely
18
Remote Debugger Platform Assistant [PAServer]
Remote Debugger [rmtdbgXXX.exe] Firewall!
19
AsmProfiler André Mussche https://github.com/andremussche/asmprofiler
MiniDumpReader Process Explorer [Mark Russinovich]
20
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.