Display locals

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. 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, 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

Write a CLR expression evaluator