Share via


Implementing CPendingBreakpoint

The session debug manager (SDM) calls the IDebugEngine2::CreatePendingBreakpoint method and passes it an IDebugBreakpointRequest2 interface.

When the breakpoint is bound to application code, the IDebugPendingBreakpoint2::Bind method, implemented by the CPendingBreakpoint class, sends a breakpoint bound event to the SDM. In order to send an event, the CPendingBreakpoint class needs access to both the event callback function and the debug engine. The CPendingBreakpoint::Initialize method saves pointers to both of these in member variables.

To implement the CPendingBreakpoint class

  1. In Class View, right-click the CPendingBreakpoint class, click Add Variable, and add a variable with the Variable name m_spCallback, a Variable type of CComPtr<IDebugEventCallback2>, and an Access type of protected.

  2. Add another variable to the CPendingBreakpoint class with the Variable name m_spEngine, a Variable type of CComPtr<IDebugEngine2>, and an Access type of protected.

  3. Add a third variable to the CPendingBreakpoint class with the Variable name m_spBPRequest, a Variable type of CComPtr<IDebugBreakpointRequest2>, and an Access type of protected.

  4. In Class View, right-click the CPendingBreakpoint class and click Add Function to add a function with the Function name Initialize, a Return type of void, an Access type of public, and the following parameters in the order given (click Add between each one):

    Parameter type

    Parameter name

    IDebugBreakpointRequest2 *

    pBPRequest

    IDebugEventCallback2 *

    pCallback

    IDebugEngine2 *

    pEngine

  5. Open the Breakpoint.cpp file, find CPendingBreakpoint::Initialize, and add the following bold lines:

    void CPendingBreakpoint::Initialize(IDebugBreakpointRequest2 * pBPRequest,
                                        IDebugEventCallback2 * pCallback,
                                        IDebugEngine2 * pEngine)
    {
        m_spCallback  = pCallback; 
        m_spEngine    = pEngine; 
        m_spBPRequest = pBPRequest; 
    }
    
  6. Also in the Breakpoint.cpp file, find CPendingBreakpoint::GetBreakpointRequest and replace the line //TODO: RETURN BREAKPOINT REQUEST as well as the following return statement with the following:

        *ppBPRequest = m_spBPRequest; 
        (*ppBPRequest)->AddRef(); 
    
        return S_OK; 
    
  7. Build the project to make sure there are no errors.

See Also

Concepts

Creating a Pending Breakpoint