There is no reliable way to get that information at runtime
The Use Debug DCUs
compiler option only switches the search path; What the compiler will eventually find there is unknown. An (misguided) user might have copied the Release dcu's over the debug directory, or vice-versa.
Even without misugided users, one might have some files added to the project (and compiled with the project) in order to include some bug-fix. For example, if the user has the Graphics.pas
added to the project, does a release/no-debug build, but keeps the Use Debug DCU's
compiler option, then the Graphics.dcu
that's actually linked is not a debug build, because it's re-built with the executable. So you get a "mixed" bag of debug and non-debug dcus.
You could attempt detecting the presence of debug information related to certain objects or methods, but this too would be unreliable: If you use "Build with Debug Dcus" but then set "Debug Information" to false, then you're essentially throwing away the debug information so you can no longer look for it.
But that linked code fails on Debug DCU's
The code from the GLScene project is not a good hack, it uses hard-coded offsets into the code for the TPicture.RegisterFileFormat
, then continues to use hard-coded offsets to get the address of the global FileFormats
variable (doesn't call the GetFileFormats
routine). Too many magic numbers in there!
My first though was to compare the TList
identified using the GLScene
method to the TList
I've identified, but guess what: On my machine there was no problem, both routines got the same result, in both circumstances. On my machine the GLScene
, ugly as it is, is not broken with Debug DCUs.
I've even tried "fingerprinting" some of the rtl/vcl units (SysUtils, Graphics, Classes); I made a list of all the public classes, generated some code that uses RTTI for each method in each class and dumps the first 1024 bytes of the code to a string file. Ran that program with Debug DCUs and non-Debug DCUs and I got the same result. My text files contain the fingerprints for some 3500 methods!
Not a good idea
Since that option doesn't really affect the way the compiler compiles (only what the linker links), creating code that depends on this option is highly unreliable and not a good idea. This only affects low-level hacks, and you don't want low-level hacks that might crash your application under circumstances that are absolutely out of your control.
The only true option is replacing the potentially failing hack with one that's not going to fail (or at least fails in controllable ways).
Graphics.dcu
that's linked in, and that's a significant change. Apparently NGLN's linked hack brakes depending on the DCU version linked. I was probably going a step too far with my analyses. – CatechumenGraphics
unit that executes then is the one in the VCL package loaded by the IDE. And Debug DCUs was disabled. It has no relation to the setting of that compiler option. – Hierarchize