Expression evaluation (Visual Studio Debugging SDK)

During break mode, the IDE must evaluate simple expressions involving several program variables. To accomplish its evaluation, the debug engine (DE) must parse and evaluate an expression that's entered into one of the windows of the IDE.

Expressions are created with the IDebugExpressionContext2::ParseText method and represented by the resulting IDebugExpression2 interface.

The IDebugExpression2 interface is implemented by the DE and calls its EvalAsync method to return an IDebugProperty2 interface to the IDE, in order to display the results of the expression evaluation in the IDE. IDebugProperty2::GetPropertyInfo returns a structure that is used to put the value of an expression into a Watch window or into the Locals window.

The debug package or session debug manager (SDM) calls IDebugExpression2::EvaluateAsync or EvaluateSync to get an IDebugProperty2 interface that represents the result of the evaluation. IDebugProperty2 has methods that return the name, type, and value of the expression. This information appears in various debugger windows.

Using expression evaluation

To use expression evaluation, you must implement the IDebugExpressionContext2::ParseText method and all of the methods of the IDebugExpression2 interface, as shown in the following table.

Method Description
EvaluateAsync Evaluates an expression asynchronously.
Abort Ends asynchronous expression evaluation.
EvaluateSync Evaluates an expression synchronously.

Synchronous and asynchronous evaluation require implementing the IDebugProperty2::GetPropertyInfo method. Asynchronous expression evaluation requires the implementation of IDebugExpressionEvaluationCompleteEvent2.

See also