Creating a Bound Breakpoint

A bound breakpoint implements the where and when of breaking into a program at a desired point. After the bound breakpoint is created with a call to IDebugPendingBreakpoint2::Bind and is encountered during execution, the session debug manager (SDM) finds the exact bound location of the breakpoint so that the IDE can be updated to show the breakpoint in context.

Process

The following describes how the bound breakpoint is used by the SDM:

  1. The SDM calls IDebugBoundBreakpoint2::GetBreakpointResolution to obtain an IDebugBreakpointResolution2 interface (which TextInterpreter implements in the CBreakpointResolution class).

  2. The SDM then calls IDebugBreakpointResolution2::GetResolutionInfo to obtain a BP_RESOLUTION_INFO structure.

  3. From this structure, the SDM extracts either the BP_RESOLUTION_CODE or BP_RESOLUTION_DATA structure (stored as a union, the interpretation of which is determined by the BP_TYPE code returned by a call to IDebugBreakpointResolution2::GetBreakpointType).

  4. If the breakpoint type is code (as will be the case in TextInterpreter), the SDM extracts the IDebugCodeContext2 interface from the BP_RESOLUTION_CODE structure.

    注意

    The BP_RESOLUTION_DATA structure describes an expression that was bound to and its location. The BP_RESOLUTION_DATA structure is not used in TextInterpreter.

  5. The SDM obtains an IDebugDocumentContext2 interface from the code context with a call to IDebugCodeContext2::GetDocumentContext.

  6. The SDM then obtains the document name with a call to IDebugDocumentContext2::GetName and the breakpoint location within the document with a call to IDebugDocumentContext2::GetSourceRange.

In TextInterpreter, the document and code contexts are considered the same; that is, each line of text is considered a code context. As a result, the IDebugDocumentContext2 and IDebugCodeContext2 interfaces will be implemented on the same class, CDebugContext. In a more typical situation, these contexts would be implemented as separate objects.

Creating and implementing the CBoundBreakpoint class consists of the following steps:

  1. Creating CBoundBreakpoint.

  2. Implementing CBoundBreakpoint.

  3. Creating CDebugContext.

  4. Implementing CDebugContext.

  5. Creating CBreakpointResolution.

  6. Implementing CBreakpointResolution.

See Also

Concepts

Binding the Breakpoint