Partager via


Implementing IDebugPendingBreakpoint2::Bind

The session debug manager (SDM) calls IDebugPendingBreakpoint2::Bind to bind the breakpoint to the program. If the bind operation is successful, the debug engine sends back to the SDM an IDebugBreakpointBoundEvent2 interface; if the bind was unsuccessful (for example, if the user tried to set a breakpoint on a comment), the debug engine sends back an IDebugBreakpointErrorEvent2 interface.

Note

In TextInterpreter, all breakpoints can be bound successfully, so an IDebugBreakpointErrorEvent2 event is never needed and is not implemented.

The SDM calls IDebugBreakpointBoundEvent2::EnumBoundBreakpoints to retrieve a list of all bound breakpoints associated with the pending breakpoint (although it is possible for a pending breakpoint to have multiple bound breakpoints, in TextInterpreter only a single bound breakpoint will be created for each pending breakpoint).

From each bound breakpoint, the SDM extracts the context in which the bound breakpoint will stop the program. This context information is used to represent the breakpoint to the user in the IDE. It is also used when the bound breakpoint is encountered during execution of the program.

Process

In TextInterpreter, CPendingBreakpoint::Bind (which implements IDebugPendingBreakpoint2::Bind) does the following:

  1. Calls IDebugBreakpointRequest2::GetRequestInfo to obtain the desired breakpoint location. The IDebugBreakpointRequest2 was supplied when IDebugEngine2::CreatePendingBreakpoint was called.

  2. Creates a context for the bound breakpoint, represented by an instance of CDebugContext (which implements the IDebugCodeContext2 and IDebugDocumentContext2 interfaces).

  3. Creates an instance of a CBreakpointResolution class (which implements the IDebugBreakpointResolution2 interface) and initializes it.

  4. Creates and initializes a new instance of CBoundBreakpoint (which implements the IDebugBoundBreakpoint2 interface), using the newly created instance of the CBreakpointResolution class.

  5. Calls CPendingBreakpoint::SendBoundEvent, which adds the object to a newly created CEnumDebugBoundBreakpoints object (which in turn implements the IEnumDebugBoundBreakpoints2 interface). The CPendingBreakpoint::SendBoundEvent method sends the CEnumDebugBoundBreakpoints object wrapped in a CBreakpointBoundEvent class (which implements the IDebugBreakpointBoundEvent2 interface) to the SDM.

  6. Saves a copy of the breakpoint in a global variable after returning from CPendingBreakpoint::SendBoundEvent. This saved breakpoint represents the last breakpoint bound and is the breakpoint that is “encountered” during the text program “execution.”

Implementing the CPendingBreakpoint::Bind method consists of the following steps:

  1. Implementing CEnumDebugBoundBreakpoints.

  2. Implementing SendBoundEvent, a helper function.

  3. Implementing and Calling Bind itself.

See Also

Concepts

Binding the Breakpoint