다음을 통해 공유


Evaluating Expressions

Expressions are created from strings passed down from the Autos, Watch, QuickWatch, or Immediate windows. When an expression is evaluated, it generates a printable string that contains the name and type of variable or argument and its value. This string is displayed in the corresponding IDE window.

Implementation

Expressions are evaluated when a program has stopped at a breakpoint. The expression itself is represented by an IDebugExpression2 interface, which represents a parsed expression that is ready for binding and evaluation within the given expression evaluation context. The stack frame determines the expression evaluation context, which the debug engine (DE) supplies by implementing the IDebugExpressionContext2 interface.

Given a user string and an IDebugExpressionContext2 interface, a debug engine (DE) can obtain an IDebugExpression2 interface by passing the user string to the IDebugExpressionContext2::ParseText method. The IDebugExpression2 interface returned contains the parsed expression ready for evaluation.

With the IDebugExpression2 interface, the DE can get the value of the expression through synchronous or asynchronous expression evaluation, using IDebugExpression2::EvaluateSync or IDebugExpression2::EvaluateAsync. This value, along with the name and type of the variable or argument, is sent to the IDE for display. The value, name, and type are represented by an IDebugProperty2 interface.

To enable expression evaluation, a DE must implement the IDebugExpression2 and IDebugExpressionContext2 interfaces. Both synchronous and asynchronous evaluation require the implementation of the IDebugProperty2::GetPropertyInfo method.

See Also

Concepts

Stack Frames

Expression Evaluation Context

Debugging Tasks