Sending Debug Engine and Program Creation Events
When the debug engine is started, it needs to send an event (represented by the IDebugEngineCreateEvent2 interface) to tell the session debug manager (SDM) that the debug engine has been started and is ready to go to work.
When a program to be debugged is started, the debug engine needs to send an event (represented by the IDebugProgramCreateEvent2 interface) to tell the SDM that a program object has been created.
The following procedures show how TextInterpreter sends these two events.
To send the debug engine and program creation events
In Class View, right-click the CProgram class, select Add Variable, and add a variable with the Variable name m_spCallback, the Variable type CComPtr<IDebugEventCallback2>, and an Access type of protected.
Open the Program.cpp file and add the following bold line:
#include "Program.h #include "EventBase.h"
Also in the Program.cpp file, find CProgram::EngineAttach and replace the line //TODO: ADD CREATE EVENT NOTIFICATIONS with the following:
m_spCallback = pCallback; CEngineCreateEvent *pDECE = new CEngineCreateEvent(m_spEngine); pDECE->SendEvent(pCallback, m_spEngine, NULL, NULL); CProgramCreateEvent *pDPCE = new CProgramCreateEvent; pDPCE->SendEvent(pCallback, m_spEngine, this, NULL);
Build the project to make sure there are no errors.