BrkPntMgr: Uses Automation to List and Control Breakpoints

Click to open or copy the BrkPntMgr project files.

BrkPntMgr is a breakpoint manager. It will save and load breakpoints from files. You can add comments to make your breakpoints more understandable. This is useful in working on many bugs at one time, or over time.

BrkPntMgr was created with the ATL COM AppWizard. Support MFC was checked in the wizard and then an Add-in object was added to the project with the ATL Object Wizard. The code that was added is mostly in BrkPnts.cpp. There is code for loading, saving, and closing, and a function that will get a pointer to an IGenericDocument interface for a given file.

To build the sample

  1. Click the link at the beginning of this topic to download the sample files.

  2. In Visual C++, open the project file BrkPntMgr.dsp.

  3. Choose an appropriate configuration (Win32 Release is best if you plan to use this add-in).

  4. Click Rebuild All from the Build menu.

To run the add-in

  1. From the Tools menu, click Customize.

  2. Click the Add-ins and Macro Files tab.

  3. Select the BrkPntMgr.dll file or browse for it. See Tips for Using Add-ins.

    Visual C++ will load the add-in. When you close the Customize dialog box, BrkPntMgr’s toolbar will appear.

  4. Run the BrkPntMgr add-in by clicking the toolbar button. BrkPntMgr puts up a single button in a toolbar. Clicking this button opens a dialog box. This dialog box has a check box for Save Only Enabled, an edit box File:, a Browse button, another edit box labeled Comment, and four more buttons labeled Clear, Save, Load, and To Output Wnd. The text at the top of the dialog box reports how many breakpoints are set and enabled.

If you put a file name in the File: edit box (or browse for one), you can either load or save breakpoints. If the Save Only Enabled check box is enabled, you will not save any disabled breakpoints. When you save, you can add a comment, such as "This set of breakpoints are for finding a memory leak in the bipartite graph program."

When you load a file, all files with breakpoints set will be opened and then all the breakpoints will be set.

Click Clear to clear all of the breakpoints.

If you click To Output Wnd, the breakpoints will be printed to the output window, which is under the Macro tab. You might want to clear the window first using the context menu (right-click in the output window). This is useful as you can then navigate to your breakpoints easily, much as you do for errors in compilation.

One caveat: if you edit code heavily, the breakpoint may not be on the correct line. In this case, remove the wrong breakpoints and reset them.

This sample demonstrates the following keywords:

IApplication, CComPtr, CComQIPtr, ITextDocument::get_FullName; CStringArray::Add; CStringArray::GetAt; CComBSTR; CComVariant; IDocuments::get__NewEnum; IEnumVARIANT::Next; CComVariant; ITextSelection::GoToLine; IDebugger::AddBreakpointAtLine; IApplication::put_Active; IDebugger::RemoveBreakpointAtLine; IDebugger::get_Count; IDebugger::get_Breakpoints IBreakPoint::get_Enabled; IBreakPoint::get_File; IBreakPoint::get_Type; IBreakPoint::get_Function; IBreakPoint::get_Executable IBreakPoint::get_Location; IBreakPoints::Item; IApplication::PrintToOutputWindow; debugger; breakpoint; addin; customize; CregKey; IapplicationEvents; IdebuggerEvents; Carchive; ITextSelection, CStringArray; IBreakpoint; IGenericDocument; ITextDocument