Share via


Attaching and Detaching to a Program

Attaching the debugger requires sending the correct sequence of methods and events with the proper attributes.

Sequence of Methods and Events

  1. The session debug manager (SDM) calls the IDebugProgramNodeAttach2::OnAttach method.

    Based on the debug engine (DE) process model, the IDebugProgramNodeAttach2::OnAttach method returns one of the following methods, which determines what happens next.

    If S_FALSE is returned, the debug engine has successfully been attached to the program. Otherwise, the IDebugEngine2::Attach method is called to complete the attach process.

    If S_OK is returned, the DE is to be loaded in the same process as the SDM. The SDM performs the following tasks:

    1. Calls IDebugProgramNode2::GetEngineInfo to get the engine information of the DE.

    2. Co-creates the DE.

    3. Calls IDebugEngine2::Attach.

  2. The DE sends an IDebugEngineCreateEvent2 to the SDM with an EVENT_SYNC attribute.

  3. The DE sends an IDebugProgramCreateEvent2 to the SDM with an EVENT_SYNC attribute.

  4. The DE sends an IDebugLoadCompleteEvent2 to the SDM with an EVENT_SYNC_STOP attribute.

Detaching from a program is a simple, two-step process, as follows:

  1. The SDM calls IDebugProgram2::Detach.

  2. The DE sends an IDebugProgramDestroyEvent2.

See Also

Concepts

Calling Debugger Events