Compartir a través de


Creating CPendingBreakpoint

A pending breakpoint is a formal description of where and when the user wants execution to be stopped in the program being debugged. When the program to be debugged has finished loading, the session debug manager (SDM) converts all the user-specified breakpoints into objects that implement the IDebugPendingBreakpoint2 interface. These pending breakpoint objects are actually created by the debug engine when the SDM calls IDebugEngine2::CreatePendingBreakpoint.

In a typical implementation, the pending breakpoint is implemented as a separate object. In TextInterpreter, this object is represented by the class CPendingBreakpoint and is created in CProgram::CreatePendingBreakpoint.

To create the CPendingBreakpoint class

  1. In Solution Explorer, right-click the TextInterpreter project and click Add Class.

  2. Click the ATL category, click an ATL Simple Object, and click Add.

  3. For the Short name, type PendingBreakpoint.

  4. Modify the .h file to be Breakpoint.h and the .cpp file to be Breakpoint.cpp.

  5. Clear the Attributed option.

  6. Change the Interface to IDebugPendingBreakpoint2.

  7. Click Next or click the Options link on the left.

  8. Change the Interface from Dual to Custom.

  9. Click Finish to add the ATL object to the project.

  10. Open the TextInterpreter.idl file and remove the declaration for the interface IDebugPendingBreakpoint2 (which looks similar to the following):

    [
        object,
        uuid(5E9D040C-700A-42A9-87FA-667B3B6D26E5),
        helpstring("IDebugPendingBreakpoint2 Interface"),
        pointer_default(unique)
    ]
    interface IDebugPendingBreakpoint2 : IUnknown{
    };
    
  11. Open the Breakpoint.h file and add the following bold lines to the CPendingBreakpoint class. These are the declarations for the methods on the IDebugPendingBreakpoint2 interface.

    END_COM_MAP()
    
        //////////////////////////////////////////////////////////// 
        // IDebugPendingBreakpoint2 
        STDMETHOD(CanBind)(IEnumDebugErrorBreakpoints2** ppErrorEnum); 
        STDMETHOD(Bind)(void); 
        STDMETHOD(GetState)(PENDING_BP_STATE_INFO* pState); 
        STDMETHOD(GetBreakpointRequest)(IDebugBreakpointRequest2** ppBPRequest); 
        STDMETHOD(Virtualize)(BOOL fVirtualize); 
        STDMETHOD(Enable)(BOOL fEnable); 
        STDMETHOD(SetCondition)(BP_CONDITION bpCondition); 
        STDMETHOD(SetPassCount)(BP_PASSCOUNT bpPassCount); 
        STDMETHOD(EnumBoundBreakpoints)(IEnumDebugBoundBreakpoints2** ppEnum); 
        STDMETHOD(EnumErrorBreakpoints)( 
            BP_ERROR_TYPE bpErrorType, 
            IEnumDebugErrorBreakpoints2** ppEnum); 
        STDMETHOD(Delete)(void); 
    
  12. Open the Breakpoint.cpp file and add the following bold lines at the end of the file. These are the definitions for the methods on the IDebugPendingBreakpoint2 interface (most of which return E_NOTIMPL for now).

    // CPendingBreakpoint
    
    ////////////////////////////////////////////////////////////////////////////// 
    // IDebugPendingBreakpoint2 
    HRESULT CPendingBreakpoint::CanBind(IEnumDebugErrorBreakpoints2** ppErrorEnum) 
    { return E_NOTIMPL; } 
    HRESULT CPendingBreakpoint::GetState(PENDING_BP_STATE_INFO* pState) 
    { return E_NOTIMPL; } 
    HRESULT CPendingBreakpoint::Virtualize(BOOL fVirtualize) 
    { return S_OK; } 
    HRESULT CPendingBreakpoint::Enable(BOOL fEnable) 
    { return S_OK; } 
    HRESULT CPendingBreakpoint::SetCondition(BP_CONDITION bpCondition) 
    { return E_NOTIMPL; } 
    HRESULT CPendingBreakpoint::SetPassCount(BP_PASSCOUNT bpPassCount) 
    { return E_NOTIMPL; } 
    HRESULT CPendingBreakpoint::EnumBoundBreakpoints(IEnumDebugBoundBreakpoints2** ppEnum) 
    { return E_NOTIMPL; } 
    HRESULT CPendingBreakpoint::EnumErrorBreakpoints(BP_ERROR_TYPE bpErrorType, 
                                                     IEnumDebugErrorBreakpoints2** ppEnum) 
    { return E_NOTIMPL; } 
    HRESULT CPendingBreakpoint::Delete(void) 
    { return E_NOTIMPL; } 
    
    HRESULT CPendingBreakpoint::GetBreakpointRequest(IDebugBreakpointRequest2** ppBPRequest) 
    { 
        //TODO: RETURN BREAKPOINT REQUEST 
        return E_NOTIMPL; 
    } 
    
    HRESULT CPendingBreakpoint::Bind(void) 
    { 
        //TODO: IMPLEMENT BIND 
        return E_NOTIMPL; 
    } 
    
  13. Build the project to make sure there are no errors.

See Also

Concepts

Creating a Pending Breakpoint