Partager via


Implementing CBreakpointBoundEvent

After the session debug manager (SDM) calls IDebugPendingBreakpoint2::Bind, the debug engine responds by sending to the SDM either an IDebugBreakpointBoundEvent2 (if the pending breakpoint can be bound) or an IDebugBreakpointErrorEvent2 (if the pending breakpoint cannot be bound).

Since TextInterpreter always successfully binds all pending breakpoints, IDebugBreakpointErrorEvent2 is never needed and is not implemented.

In TextInterpreter, the CBreakpointBoundEvent class implements the IDebugBreakpointBoundEvent2 interface. This interface provides an enumeration of all bound breakpoints associated with the pending breakpoint. In TextInterpeter, this enumeration always returns only a single bound breakpoint. This enumeration will be implemented at a later time.

To create CBreakpointBoundEvent

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

  2. Add a Generic C++ Class with the Class name CBreakpointBoundEvent and set its Base class to IDebugBreakpointBoundEvent2. Set the .h file to EventBase.h and the .cpp file to EventBase.cpp. Make sure that Access is set to public. Click Finish. Answer Yes to the prompts that ask if you want to merge with the contents of the specified file.

  3. In Class View, right-click the new CBreakpointBoundEvent class, select Add Variable, and add a variable with the Variable name m_spEnum, a Variable type of CComPtr<IEnumDebugBoundBreakpoints2>, and an Access type of protected.

  4. Add another variable to the CBreakpointBoundEvent class with the Variable name m_spPending, a Variable type of CComPtr<IDebugPendingBreakpoint2>, and an Access type of protected.

  5. Open the EventBase.h file, find the declaration for the new class CBreakpointBoundEvent, and modify the class declaration to look like the following:

    class CBreakpointBoundEvent :
        public IDebugBreakpointBoundEvent2, 
        public CEventBase 
    {
    public:
    
  6. In EventBase.h, modify the CBreakpointBoundEvent constructor to take two parameters like this:

        CBreakpointBoundEvent(
            IEnumDebugBoundBreakpoints2 *pEnum, 
            IDebugPendingBreakpoint2 *pPending); 
    
  7. In EventBase.h, right after the declaration of the CBreakpointBoundEvent destructor, add the following bold lines. These are the declarations for the methods on the IUnknown and IDebugBreakpointBoundEvent2 interfaces.

        ~CBreakpointBoundEvent(void);
    
        //////////////////////////////////////////////////////////// 
        // IUnknown methods 
        DECLARE_IUNKNOWN 
    
        //////////////////////////////////////////////////////////// 
        //IDebugBreakpointBoundEvent2 methods 
        STDMETHOD(GetPendingBreakpoint)(IDebugPendingBreakpoint2** ppPendingBP); 
        STDMETHOD(EnumBoundBreakpoints)(IEnumDebugBoundBreakpoints2** ppEnum); 
    
  8. Open the EventBase.cpp file, find the CBreakpointBoundEvent class, and modify the constructor to look like the following:

    CBreakpointBoundEvent::CBreakpointBoundEvent(
        IEnumDebugBoundBreakpoints2 *pEnum, 
        IDebugPendingBreakpoint2 *pPending) 
    : CEventBase(IID_IDebugBreakpointBoundEvent2, EVENT_ASYNCHRONOUS) 
    {
        m_spEnum = pEnum; 
        m_spPending = pPending; 
    }
    
  9. After the CBreakpointBoundEvent class destructor, add the following bold lines. These are the definitions for the methods on the IUnknown and IDebugBreakpointBoundEvent2 interfaces.

    CBreakpointBoundEvent::~CBreakpointBoundEvent(void)
    {
    }
    
    ////////////////////////////////////////////////////////////////////////////// 
    // IUnknown 
    IMPLEMENT_IUNKNOWN(CBreakpointBoundEvent, IDebugBreakpointBoundEvent2) 
    
    ////////////////////////////////////////////////////////////////////////////// 
    // IDebugBreakpointBoundEvent2 
    HRESULT CBreakpointBoundEvent::GetPendingBreakpoint(IDebugPendingBreakpoint2** ppPendingBP) 
    { 
        // Get the pending breakpoint that was bound to the breakpoint 
       *ppPendingBP = m_spPending; 
       (*ppPendingBP)->AddRef(); 
       return S_OK; 
    } 
    
    HRESULT CBreakpointBoundEvent::EnumBoundBreakpoints(IEnumDebugBoundBreakpoints2** ppEnum) 
    { 
        // Get the list of breakpoints bound on this event 
       *ppEnum = m_spEnum; 
       (*ppEnum)->AddRef(); 
       return S_OK; 
    } 
    
  10. Build the project to make sure there are no errors.

See Also

Concepts

Binding the Breakpoint