tags:

views:

2031

answers:

3

Hi,

I am a developer working on vc, 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 must to generate a dll in debug and then start debugging in delphi?

Thanks.

+14  A: 

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.

Chapel
@Chapel. Are you sure Attach to process can be used to debug the DLL?
Lieven
I have done the same thing but the break point is not hitting. i think the match between the code and debugger is not establishing. Wont be there the concept of PDB (present in vc 6) will be there.
coolcake
remote debug symbols should not be necessary
dummzeuch
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.
coolcake
Don't manually move your DLL. You need to tell Delphi to put the compiled DLL in the desired location or it won't debug correctly.
Jim McKeeth
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)
Paul-Jan
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!!!!
coolcake
+1 for the "Include remote debug symbols" tip - I was tearing my hair out
Blorgbeard
+3  A: 

We use this quite often (using Delphi .

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

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

It even works when dll's are dynamically linked (if they are unloaded the blue dots disapear).

Gamecat
A: 

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 1 form that can directly exercise the code that would normally be used in a DLL.

X-Ray