Sending the Entry Point Event

Once all the pending breakpoints are bound, the session debug manager (SDM) calls either IDebugProgram2::Execute or IDebugProgram2::Step (based on the user's choice). In TextInterpreter, the implementation of these methods posts a WM_CONTINUE message to the main thread so that TextInterpreter's main message pump will be told to call CProgram::Go to start the program's "execution."

The CProgram::Go method sends the entry-point event to the SDM indicating that the program has started.

注意

In TextInterpreter, CProgram::Go is a simple state machine, sending the entry-point event and then firing the breakpoint event when the program is continued. In a more typical situation, CProgram::Go would actually start the program being debugged, and the debug engine would then monitor it for breakpoint hits.

To send the entry point event

  1. In Class View, right-click the CProgram class, click Add Variable, and add a variable with the Variable name bAttached, the Variable type of bool, and an Access type of protected.

  2. Open the Program.cpp file, find CProgram::Go, and add the following bold lines:

    void CProgram::Go(void)
    {
        // Wait for load complete event. 
        if (!bAttached) 
        { 
            bAttached = true; 
    
            // At this point, all pending breakpoints are bound. 
            // Fire entry point event. 
            CEntryPointEvent *pDEPE = new CEntryPointEvent; 
            pDEPE->SendEvent(m_spCallback, m_spEngine, this, this); 
            return; 
        } 
    }
    
  3. Build the project to make sure there are no errors.

See Also

Concepts

Firing the Breakpoint Event