Partager via


Displaying Locals

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Important

In Visual Studio 2015, this way of implementing expression evaluators is deprecated. For information about implementing CLR expression evaluators, please see CLR Expression Evaluators and Managed Expression Evaluator Sample.

Execution always takes place within the context of a method, also known as the containing method or current method. When execution pauses, Visual Studio calls the debug engine (DE) to get a list of local variables and arguments, collectively called the locals of the method. Visual Studio displays these locals and their values in the Locals window.

To display locals, the DE calls the GetMethodProperty method belonging to the EE and gives it an evaluation context, that is, a symbol provider (SP), the current execution address, and a binder object. For more information, see Evaluation Context. If the call succeeds, the IDebugExpressionEvaluator::GetMethodProperty method returns an IDebugProperty2 object, which represents the method that contains the current execution address.

The DE calls EnumChildren to get an IEnumDebugPropertyInfo2 object, which is filtered to return only locals and enumerated to produce a list of DEBUG_PROPERTY_INFO structures. Each structure contains the name, type, and value of a local. The type and value are stored as formatted strings, suitable for display. The name, type, and value are typically displayed together in one line of the Locals window.

Note

The QuickWatch and Watch windows also display variables with the same format of name, value, and type. However, those values are obtained by calling GetPropertyInfo instead of IDebugProperty2::EnumChildren.

In This Section

Sample Implementation of Locals
Uses examples to step through the process of implementing locals.

Evaluation Context
Explains that when the debug engine (DE) calls the expression evaluator (EE), it passes three arguments.

See Also

Writing a CLR Expression Evaluator