Previous: Using GNAT COM objects as Distributed COM objects [Contents][Index]

## 6 Debugging COM objects with gdb

Depending on the type of COM object and the client type there are different techniques used to debug a COM object.

The easiest form of COM object to debug is the Local Server (EXE) type. The COM object is compiled with the -g option to gnatmake and run in gdb as any other application. Break points can then be set and when the client compiled with gdb compatible debugging information or not is run the break points will be hit in the local server. It is also possible to use the gdb command `attach` to connect to an already running local server. The program ID that is used with the `attach` command can be located using the task manager.

Since Inproc Server COM objects are DLLs, they run in the same address space as the executable using them. If the client of the COM object is compiled with gdb debug information it is possible to debug normally and step through the client directly in to the COM object. Break points though can not be set in the COM object until after the object is created in the client code.

If the client does not contain gdb debug information (such as when the client is a Microsoft Visual C++ or Visual Basic client), an alternate techniques must used. The executable of the client can either be run with in gdb or attached to using the gdb attach command. Since it is not possible to set a break point in the client code it may not be possible to easily determine when the COM object has been created in order to stop execution of the client application and to set break points. One technique to assist in determining this point is to place a MessageBox or similar blocking function in the objects creation code. Once the message box displays a ctrl-c sequence can be sent to gdb to pause execution of the application and break points can then be set in to COM object. A `continue` statement can then be sent to gdb and the dialog box’s OK button can be pushed to continue program execution and debugging.

Previous: Using GNAT COM objects as Distributed COM objects [Contents][Index]