Delphi: how to exclude units from the debugger?

Sometimes, when I debug step by step, before the FormCreate event or right after FromDestroy, the debugger starts opening DevExpress elements (cxContainer.pas, ...), and so before FormCreate my “F8” takes me to cxContainer instead of going to the next line of my code.

(this is just an example, it can happen, of course, with any third-party library)

How do I tell the debugger to "debug only my units" (only the pas files listed in the dpr file?)

Of course, it is sometimes useful to debug libraries, but in most cases this is not so.

+6
debugging delphi delphi-2009
source share
4 answers

You are better off following the VCL convention for third-party components:

  • Change the output path of the DCU in all third-party packages to a folder other than the folder in which the PAS files are stored.
  • Compile each package once in debug mode and save the generated DCU files in a folder (for example, Debug DCU).
  • Compile each package again, but this time in Release mode and save the created DCU files in a folder (for example, Release DCU).
  • Go to the Delphi options and add the DCU release path to the "library path".
  • In the Delphi options, add the path to the source files in the "View Path".
  • In the Delphi options, add the debug DCU path for "Debug DCU path".

Thus, when compiling your project, Delphi will only see the DCU releases of this third-party component, so the debugger cannot enter the source code. On the other hand, since the source path is included in the "View Path", you can still go to the source code inside the IDE using Ctrl + Click on the name of the element or everything that is defined in these units.

If you want to debug the component, you can go to "Project | Options | Delphi Compiler | Compiling" and turn on "Use debug.dcus". This will force the compiler to use the "Debug DCU path" instead of the "Library path".

VCL works the same way, as a rule, you do not enter the VCL source code when debugging your project, but if you enable "Use debug.dcus", you can also debug the VCL source code.

The JVCL also organizes its packages and source code in the same way.

EDIT : If you take this approach and want the work in the code view (Ctrl + Click) to work; note that when compiling package release versions, you must set the Symbol Reference Info in "Project | Options | Delphi Compiler | Compiling" to "Reference Info"; otherwise Ctrl + Click will not work for these devices. By default, the assembly configuration of the assembly sets the Symbol Reference value to None.

+25
source share

There is only one way to tell the compiler not to debug a block: compile it without debugging information.

If you have a source in your libraries, you can rebuild your package after disabling the "include debug info" compiler option for each package in the library. If you're lucky, your libraries will include an .inc file that sets the compiler options that they need and which they include in each block. In this case, all you have to do is edit this inc file and rebuild all the packages.

If you don't have a source in your libraries, library developers can provide two sets of dcu: one compiled, the other without debugging information. In this case, just specify the path to the library that you need.

+2
source share

A quick and easy solution turns off the DEBUG switch ({$ D-}) for any libraries that you use. Many libraries (including DevExpress) use a global include file, usually at the top of each source file, either directly above or below the unit statement (for example, unit cxContainer; {$ i cxVer.inc}). Open this include file (click on it and press CTRL-Enter) and add {$ D-} at the top and comment out the existing {$ D +}.

+2
source share

Disable debugging information in units that you do not want the debugger to enter.

+1
source share

All Articles