Share via


Sample Implementation of Locals

Here is an overview of how Visual Studio obtains the locals for a method from the expression evaluator (EE):

  1. Visual Studio calls the debug engine's (DE) IDebugStackFrame2::GetDebugProperty to get an IDebugProperty2 object that represents all the properties of the stack frame, including the locals.

  2. IDebugStackFrame2::GetDebugProperty calls IDebugExpressionEvaluator::GetMethodProperty to obtain an object that describes the method within which the breakpoint occurred. The DE supplies a symbol provider (IDebugSymbolProvider), an address (IDebugAddress), and a binder (IDebugBinder).

  3. IDebugExpressionEvaluator::GetMethodProperty calls IDebugSymbolProvider::GetContainerField with the supplied IDebugAddress object to get an IDebugContainerField representing the method containing the specified address.

  4. The IDebugContainerField interface is queried for the IDebugMethodField interface. It is this interface that gives access to the method's locals.

  5. IDebugExpressionEvaluator::GetMethodProperty instantiates a class (called CFieldProperty in the sample) that implements the IDebugProperty2 interface to represent the method's locals. The IDebugMethodField object is placed in this CFieldProperty object along with the IDebugSymbolProvider, IDebugAddress and IDebugBinder objects.

  6. When the CFieldProperty object is initialized, IDebugField::GetInfo is called on the IDebugMethodField object to obtain a FIELD_INFO structure that contains all displayable information about the method itself.

  7. IDebugExpressionEvaluator::GetMethodProperty returns the CFieldProperty object as an IDebugProperty2 object.

  8. Visual Studio calls IDebugProperty2::EnumChildren on the returned IDebugProperty2 object with the filter guidFilterLocalsPlusArgs. This returns an IEnumDebugPropertyInfo2 object containing the method's locals. This enumeration is filled in by calls to IDebugMethodField::EnumLocals and IDebugMethodField::EnumArguments.

  9. Visual Studio calls IEnumDebugPropertyInfo2::Next to obtain a DEBUG_PROPERTY_INFO structure for each local. This structure contains a pointer to an IDebugProperty2 interface for a local.

  10. Visual Studio calls IDebugProperty2::GetPropertyInfo for each local to obtain the local's name, value, and type. This is the information that is displayed in the Locals window.

In This Section

  • Evaluation Context
    Provides the arguments that are passed when the DE calls the expression evaluator (EE).

  • MyCEE Sample
    Demonstrates one implementation approach to creating an expression evaluator for the MyC language.

See Also

Other Resources

Displaying Locals