9

I am a developer working on Visual C++, but in my project there are some Delphi components. I need to debug the Delphi components to fix some issues.

What are the things that are a must to generate a DLL file in debug and then start debugging in Delphi?

3 Answers 3

22

In Delphi 7 you would do this:

Project | Options | Compiler | Debugging | Debug information (check)

Then go to Run | Parameters | Host Application and enter the name of your exe.

Add some breakpoints in your DLL code and then click run. Your exe will be loaded and you can debug the DLL parts in the Delphi IDE.

If your exe is already running, click Run | Attach to process

-- I've tested this and found that I also needed to check the "Include remote debug symbols" on the Linker page of project options in Delphi 7.

I was able to get a breakpoint to hit using the Run | Parameters as well as Run | Attach to process methods. The test DLL I had created had a single stdcall function and was dynamically loaded by a Visual C++ console application.

Sign up to request clarification or add additional context in comments.

9 Comments

remote debug symbols should not be necessary
I am using delphi 5.0, once the dll is built, i am placing that dll in a separate folder where the other dlls reside. When i put the break point in the binary code, by going to show loadedModules and going to my dll, clicking on my exported method, its breaking, but when i do show code, not working.
With Delphi 5 and a recent OS (XP+), you'll also need to have your current IDE directory set to the folder where your DLL is located before you fire up the host application (that, or reload the symbols from the Modules window)
Thanks Paul-Jan with your tip i was able to break at the breakpoint. I need to do even a small tweak to break, i selected break at loading the dll, then the break points got enabled. Thanks alot!!!!
Remote debug symbol should not be necessary, but I found that often Delphi fails to load debug symbols for DLLs but when Remote Debug Symbol is enabed. Maybe it should documented, maybe it is a bug, but enabling it helps and cause no harm.
|
4

We use this quite often (using Delphi).

Be sure to:

  1. Enable all debug options on all projects (DLL file(s)). And disable optimization.
  2. Be sure to set the host application to the right EXE file.
  3. Build DLL file(s).

You can now put breakpoints in both dll and exe. And run the DLL file from the IDE. It starts the EXE file and stops at the requested breakpoints.

It even works when DLL files are dynamically linked (if they are unloaded the blue dots disapear).

Comments

0

The method Gamecat suggested is something I've used before.

Another way is: I have the DLL project, but I also make a "test bench" project. The "test bench" project has one form that can directly exercise the code that would normally be used in a DLL.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.