How to debug DCU in Borland Delphi 2006? - delphi

I use Borland Delphi 2006 (folder name: C:\Program files\borland\BDS\4.0), and I want to enable debug DCUs. Where can I find this option? in tools->options->debugger options it doesn't exist.
Note: I have also Embarcadero developer studio, but I hate it. My project is written under BDS 4.0 too.
A screenshot:

You may be confused by the fact that debug .dcu's is not a debugger option, but a compiler option.
Is the compiler the one which generates and includes the symbols required to debug inside the Delphi RTL/VCL.
The debug DCUILs (.NET) or DCUs (Win32) contain debug information and are built with stack frames. When this option is checked, the compiler prepends the debug DCUIL/DCU path to the unit search path specified in Debug Source Path on the Directories/Conditionals page.
The option is under the compiler options in each project, in:
Project\Options\Compiler\Debugging\Use debug DCUs
Note I really don't have BDS2006 right now, the closest version I have is BDS2007, but AFAIK the option is named the same.

Related

Delphi XE - F1027 Unit not found: 'System.pas' or binary equivalents (.dcu) upon Activation of trial version

I just purchased the full version of Delphi XE Architect after using the trial version for 30 days. I can't build anything, every time I go to build a project I get the error.
[DCC Fatal Error] MegaMainPrj.dpr(1): F1027 Unit not found: 'System.pas' or binary equivalents (.dcu)
A quick google said that the library paths were a problem and I compared what was given (in a previous stackoverflow question) with what I had in the registry, and it was identical.
What could be causing this?
EDIT: Immediatly after I get this error message the entire IDE crashes.
add this :
$(BDSLIB)\win32\release;
to your library path .
Make sure you have the environmental variables set properly (Tools->Options->Environmental Variables from the IDE's main menu):
BDS=D:\Embarcadero\RAD Studio\8.0
BDSCOMMONDIR=C:\Users\Public\Documents\RAD Studio\8.0
PLATFORM=Win32
These should all be set in the System Variables section, and should have been added by the installer. (Obviously, they should point to the installation location of your XE installation - mine is installed in D:\Embarcadero\RAD Studio\8.0, as you can see.)
EDIT: I see in your comment you installed in C:\Program Files - bad idea if you're running Windows Vista or Win7 or higher. You should try installing in a different location. You can also try running the IDE as Administrator (right-click shortcut in Start->All Programs->Embarcadero->RAD Studio XE->Delphi XE, choose "Run as Administrator" from context menu). Does this change anything?
Also, you can open a free support case at Embarcadero for installation-related issues. I'd first try reinstalling in another location (running the install as Administrator, putting it in another folder, and installing for all users); if that doesn't work, open a support case. You can also post to the Embarcadero Delphi Installation forums - you'll need to have already created a user account there first to log in.
C:\Embarcadero\RAD Studio\9.0\lib\win32\release
and
C:\Embarcadero\RAD Studio\9.0\lib\win32\debug
Both of these path have been to add in Delphi XE2 from IDE <<Tools->Options->Library->Library path>>
It's OK?
Goto Tools->Options->Library->Library path
and add $(BDSLIB)\win32\release
This worked in Delphi 10.2
When compiling using the command line compiler, so not from within the IDE, you can also get this error when the name of the build configuration is not "debug" and not "release".
It seems that, when using the command line compiler, it tries to find its dcus in a path under BDSLIB that it constructs using the configuration name.
I had this happening when using a configuration named ReleaseHA. Note: it was not a sub configuration under "release", but an extra configuration besides "debug" and "release".
Sometimes this error message occurs when we have duplicate libraries included.
Make sure that:
Tools->Options->Environmental Options->Library
and
Project->Options->Directories/Conditionals
Don't include the same paths...
Running as Administrator worked for me.

How to debug a DLL file built in VC++ with Delphi code?

I am a developer working on Delphi. In my project I have added a DLL file which is built in VC++. I need to debug the DLL file to fix some issues.
So what are the steps needed to follow in order to debug DLL file with Delphi code?
You cannot debug the DLL from inside of Delphi, unless you do not mind stepping through the DLL's raw x86 assembly instructions. Otherwise, you need to load the DLL's source code into VC++ and use VC++'s debugger, specifying your Delphi application as the executable to use for the debugging session.
Probably you can also use Windows debugging tools (WinDbg) if you don't want to use VC++, but Delphi can't debug VC++ code because it has no support for its symbol files format.

Delphi: how to exclude units from debugger?

Sometimes as I am debugging step-by-step, just before a FormCreate Event or just after the FromDestroy the debugger starts to open DevExpress units (cxContainer.pas, ...) and so before FormCreate my "F8" leads me to cxContainer instead of going into the next line of my code.
(this is just an example, it can happen of course with any 3rd party library)
How do I tell the debugger "debug only my units" (only the pas files listed in dpr file?)
Of course sometimes it is useful to debug libraries, but in most cases it isn't.
You'd better follow VCL convention for your third-party components:
Change DCU output path in all the third-party packages to a folder different than the folder you store the PAS files.
Compile each package once in Debug mode, and save the generated DCU files in a folder (e.g. Debug DCUs).
Compile each package once again, but this time in Release mode, and save the generated DCU files in a folder (e.g. Release DCUs).
Go to Delphi options and add path of release DCUs to "Library path".
In Delphi options, add path of source files to "Browsing path".
In Delphi options, add path of debug DCUs to "Debug DCU path".
This way, Delphi will only see release DCUs of that third-party component when you are compiling your project, so the debugger cannot step into the source code.
On the other hand, since source path is included in "Browsing path", you can still navigate to the source code inside IDE by Ctrl+Click on unit name, or anything defined in those units.
If you want to debug component, you can go to "Project | Options | Delphi Compiler | Compiling", and enable "Use debug .dcus". This will force compiler to use "Debug DCU path" instead of "Library path".
VCL works the same, generally you don't step into VCL source code when you are debugging your project, but if you enable "Use debug .dcus" you can debug VCL source code too.
JVCL also organizes its packages and source code the same way.
EDIT:
If you take this approach, and want to have code browsing (Ctrl+Click) working; please take note that when you compile release version of packages, you must set Symbol Reference Info in "Project | Options | Delphi Compiler | Compiling" to "Reference Info"; otherwise, Ctrl+Click won't work for those units. By default, Release build configuration sets Symbol Reference Info to None.
A quick and simple solution is disabling the DEBUG switch ({$D-}) for any libraries you're using. Many libraries (including DevExpress) use a global include file, usually at the top of each source file, or right above or below the "unit" statement (e.g. unit cxContainer; {$I cxVer.inc} interface ). Open that include file (click on it and press CTRL-Enter) and add {$D-} right at the top, and comment out any existing {$D+}.
There is only one way to tell the compiler not to debug a unit: compile it without debug information.
If you have the source to your libraries, you can rebuild their package after having turned off the "include debug info" compiler option for each package in the library. If you are lucky, your libraries will include an .inc file which specifies the compiler options they need and which they include in each unit. In that case all you have to do is edit this inc file and rebuild all packages.
If you don't have the source to your libraries, the library makers may have provided two sets of dcu's: one compiled with, the other without debug information. In that case, simply point your library path to the one you need.
Turn off debug info in units you don't want the debugger going into.

Using JVCL's debug DCUs with C++Builder

How do I debug JVCL code using C++Builder? I enabled building debug DCUs when I installed JVCL, I turned on "use debug DCUs" under my project's Delphi settings (there doesn't appear to be an analogous option under C++ settings), and I disabled building with packages. In spite of all of this, single step still skips over JVCL code, and if a JVCL function shows up in a stack trace, double-clicking on it only shows disassembly.
Debugging RTL and VCL code works fine; it's only JVCL code that I'm having problems with.
Any ideas?
Edit: I've also noticed that JVCL debug DCUs work fine for Delphi apps. I tried doing building my project while Process Monitor was running, and for a C++Builder app, it's not even trying to find the JVCL DCUs (so it's apparently not just a problem with my search path). However, it does look for and find DCUs for core VCL files. So apparently C++Builder is determining its dependencies differently than Delphi, and apparently JVCL dependencies are being treated differently than core VCL dependencies, but I don't know how or why.
Setting the "use debug DCUs" option adds the contents of the debug path option onto the front of the search path option so that next time your code is linked, the linker will use the debug files instead of the normal files.
When you've checked that box, make sure that the directory that contains the debug versions of the JVCL DCUs is on your search path. If it's not, then add the JVCL path to your debug path (right after $(BDS)\Lib\Debug) and toggle the "use debug DCUs" option to reset the search path.

Delphi: Why does "use debug DCUs" become ineffective if I'm using packages in my project?

I'm building a project that uses the JVCL plugin system, which relies on runtime Delphi packages, and ever since I added it to my project, debugging has become a nightmare because I'm no longer able to step-trace into the source of any VCL or RTL units. They're all marked as gray dots in the debugger, (when the relevant functions appear at all in the call stack; sometimes I get very strange results,) and it's driving me crazy. Does anyone know how to get my debug DCU functionality back? (Aside from the obvious: rip out all the plugin-related code. That would work, but it wouldn't really help.)
Edit: Just to be clear, I can trace anything else in my project. JVCL code. Other 3rd party libraries. My own code. All of it shows up just fine in the debugger. Just not the Delphi RTL and VCL code--the stuff that the compiler option "use debug DCUs" is supposed to grant you access to.
This is working as designed.
When you are building with packages, you are executing the package code, and not using any DCU's. Therefore, the DCU's are compiled in, and you don't get access to the Debug DCU's.
You can either turn off packages altogether, or don't compile with the specific packages you want to debug. You can choose what packages should be used or not used, and the ones that aren't used will be "debuggable" with the Debug DCU's.
Packages are just DLLs. You have to include the debug info into those to be able to debug them, which is what you want to do. So you would need to have DEBUG packages for the VCL and RTL, not debug dcus. The debug dcus are not even needed anymore when you use prebuilt packages.
It could be the DCU's you have are out of date, so the debugger doesn't step into the code.
Usually deleting all the DCU's then doing a Build All will fix this.
You may need to delete DCU's in the search path too, just to be sure. Make a backup first of course...

Resources