Implementing SendBoundEvent
When a breakpoint is successfully bound to a location in a program, it is necessary to notify the session debug manager (SDM). This is done with the IDebugBreakpointBoundEvent2 interface, which supplies a list of all bound breakpoints associated with the pending breakpoint. In TextInterpreter, there will only ever be a single bound breakpoint, but an enumeration is still required. The helper method CPendingBreakpoint::SendBoundEvent hides the relative complexity of creating an enumeration, populating it, and sending it as part of an event object to the SDM.
To create SendBoundEvent
In Class View, right-click the CPendingBreakpoint class and click Add Function to add a function with the Function name SendBoundEvent, a Return type of void, and the following parameter (click Add before clicking Finish):
Parameter type
Parameter name
IDebugBoundBreakpoint2 *
pBoundBP
Open the Breakpoint.cpp file and insert the following bold line after the last #include:
#include "Breakpoint.h" #include "EventBase.h"
In Breakpoint.cpp, find CPendingBreakpoint::SendBoundEvent and add the following bold lines to the method:
void CPendingBreakpoint::SendBoundEvent(IDebugBoundBreakpoint2 * pBoundBP) { CComObject<CEnumDebugBoundBreakpoints>* pBoundEnum; CComObject<CEnumDebugBoundBreakpoints>::CreateInstance(&pBoundEnum); pBoundEnum->AddRef(); IDebugBoundBreakpoint2* rgpBoundBP[] = { pBoundBP }; pBoundEnum->Init(rgpBoundBP, &(rgpBoundBP[1]), NULL, AtlFlagCopy); CBreakpointBoundEvent* pBoundEvent = new CBreakpointBoundEvent(pBoundEnum, this); pBoundEvent->SendEvent(m_spCallback, m_spEngine, NULL, NULL); pBoundEnum->Release(); }
Build the project to make sure there are no errors.