Debugging Tips for ATL Objects

The debugging tips included in this article are:

See Also Debugging Tips in “ATL Services”

Using DebugBreak

You can have your program call the DebugBreak Win32 function at the point in your code that you want debugging to start. Calling this function causes the program to display a dialog box as if it had crashed. Click Cancel to start the debugger and continue on in debug mode.

Back to Top

Enabling QueryInterface Debugging

ATL has built-in support for debugging QueryInterface calls. You enable this support using the following two-step process.

To enable QueryInterface debugging:

  1. Run the FINDGUID program which comes with ATL and specify -insert as the command line parameter:
  2. findguid -insert
  3. This ensures all the common IIDs are in the interfaces section of your registry. You need to only do this once.
  4. Add the following line before including atlcom.h:
  5. #define _ATL_DEBUG_QI

Once you've enabled QueryInterface debugging, the debug output window of Developer Studio will display the name of each interface that is queried for on your object.

Back to Top

Enabling Reference Count Debugging

ATL has built-in support for debugging AddRef and Release calls. You enable this support using the following process.

To enable reference count debugging:

With reference count debugging enabled, the debug output window of Developer Studio will display the corresponding interface name and its current reference count every time AddRef or Release is called on one of your interfaces.

Back to Top