|Delphi Clinic||C++Builder Gate||Training & Consultancy||Delphi Notes Weblog||Dr.Bob's Webshop|
Ebony and Ivory
Remember them? Ebony and Ivory were the 'secret project' titles for Delphi and C++Builder. Let's get down to business. What's this lost+found about? It's about debugging C++Builder stuff used from a Delphi application. Or even debugging C++Builder stuff used from within Delphi itself.
Recently, TAS Advanced Technologies (the company we all worked for) faced a little challenge, when we were asked to audit a financial application written in C++Builder, which wasn't finished yet, but the deadline was just around the corner. After auditing the current state of the project, we agreed to redo it from scratch, this time using C++Builder (for the engine) and Delphi (for the GUI). Besides me, the team members are Arjan Jansen and Micha Somers with Bob Swart as walking on-line help.
The time we have for it is four weeks. As I am writing this, we spent two weeks. One of the major issues is that there is an extensive calculation library available for these kinds of calculations at hand and it is written in ….. yes! You guessed right, in C++.
The approach we took was to model the internals in C++, making use of the existing code for the calculations. We stuck that model and all calculations in a DLL (written in C++Builder). On the other side, we decided to use Delphi to create the user interface and that a set of Delphi components was the best way to access the model in the DLL. Since we want to access at least part of the model information at design time, the situation arises that the Delphi components and therefore Delphi itself are dependent on that particular DLL. What now if we need to debug the DLL if it is used from a component at design time? An what if we need to debug the DLL when it is used by the Delphi based application at runtime?
The solution is in the dialog that is displayed when you choose Run | Parameters. What you are able to do is to specify a host application for a DLL. If you want to debug your code at run time, specify the application that you created with Delphi at this spot. Set breakpoints and away you go. If you want to debug the C++ part at design time, specify Delphi itself at this specific spot! Then close the dialog and hit the Run button and watch what happens. Exactly! You see Delphi starting up. Once you tickle code that uses part of the C++ DLL where you have set a breakpoint, C++Builder will pop up!