Share via


Implementing CBoundBreakpoint

In TextInterpreter, the IDebugBoundBreakpoint2 interface is implemented on the CBoundBreakpoint class. This class is very straightforward, as each method on the IDebugBoundBreakpoint2 interface returns values saved when the class was created and initialized in the implementation of IDebugPendingBreakpoint2::Bind (or, to be more specific, in TextInterpreter: CPendingBreakpoint::Bind).

The CPendingBreakpoint::Bind method creates an instance of CBoundBreakpoint and then calls CBoundBreakpoint::Initialize to establish the values to be returned by the methods on the IDebugBoundBreakpoint2 interface.

To implement CBoundBreakpoint

  1. In Class View, right-click the CBoundBreakpoint class, select Add Variable, and add a variable with the Variable name m_spPendingBP, a Variable type of CComPtr<IDebugPendingBreakpoint2>, and an Access type of protected.

  2. Add another variable to the CBoundBreakpoint class with the Variable name m_spBPRes, a Variable type of CComPtr<IDebugBreakpointResolution2>, and an Access type of protected.

  3. In Class View, right-click the CBoundBreakpoint class and click Add Function to add a function with the Function name Initialize, a Return type of HRESULT, and the following parameters (in the order given, selecting the Add button between each one):

    Parameter type

    Parameter name

    IDebugPendingBreakpoint2 *

    pPending

    IDebugBreakpointResolution2 *

    pBPRes

  4. Open the Breakpoint.cpp file, find CBoundBreakpoint::Initialize, and replace the line return E_NOTIMPL; with the following:

        m_spPendingBP = pPending;  
        m_spBPRes = pBPRes;  
        return S_OK;  
    
  5. In CBoundBreakpoint::GetPendingBreakpoint, replace the line //TODO: RETURN PENDING BREAKPOINT as well as the following return statement with the following:

        *ppPendingBreakpoint = m_spPendingBP;  
        (*ppPendingBreakpoint)->AddRef(); 
        return S_OK;  
    
  6. In CBoundBreakpoint::GetBreakpointResolution, replace the line //TODO: RETURN BREAKPOINT RESOLUTION as well as the following return statement with the following:

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

See Also

Concepts

Creating a Bound Breakpoint