Partager via


IDebugExpressionEvaluator

This interface represents the expression evaluator.

IDebugExpressionEvaluator : IUnknown

Notes for Implementers

The expression evaluator must implement this interface.

Notes for Callers

To obtain this interface, instantiate the expression evaluator through the CoCreateInstance method by using the class ID (CLSID) of the evaluator. See the Example.

Methods in Vtable Order

The following table shows the methods of IDebugExpressionEvaluator.

Method

Description

IDebugExpressionEvaluator::Parse

Converts an expression string to a parsed expression.

IDebugExpressionEvaluator::GetMethodProperty

Gets the local variables, arguments, and other properties of a method.

IDebugExpressionEvaluator::GetMethodLocationProperty

Converts a method location and offset into a memory address.

IDebugExpressionEvaluator::SetLocale

Determines which language to use to create printable results.

IDebugExpressionEvaluator::SetRegistryRoot

Sets the registry root. Used for side-by-side debugging.

Remarks

In a typical situation, the debug engine (DE) instantiates the expression evaluator (EE) as a result of a call to IDebugExpressionContext2::ParseText. Because the DE knows the language and vendor of the EE it wants to use, the DE gets the EE's CLSID from the registry (the SDK Helpers for Debugging function, GetEEMetric, helps with this retrieval).

After the EE is instantiated, the DE calls IDebugExpressionEvaluator::Parse to parse the expression and store it in an IDebugParsedExpression object. Later, a call to IDebugParsedExpression::EvaluateSync evaluates the expression.

Requirements

Header: ee.h

Namespace: Microsoft.VisualStudio.Debugger.Interop

Assembly: Microsoft.VisualStudio.Debugger.Interop.dll

Example

This example shows how to instantiate the expression evaluator given a symbol provider and an address in the source code. This example uses a function, GetEEMetric, from the SDK Helpers for Debugging library, dbgmetric.lib.

IDebugExpressionEvaluator GetExpressionEvaluator(IDebugSymbolProvider pSymbolProvider,
                                                 IDebugAddress *pSourceAddress)
{
    // This is typically defined globally but is specified here just
    // for this example.
    static const WCHAR strRegistrationRoot[] = L"Software\\Microsoft\\VisualStudio\\8.0Exp";

    IDebugExpressionEvaluator *pEE = NULL;
    if (pSymbolProvider != NULL && pSourceAddress != NULL) {
        HRESULT hr         = S_OK;
        GUID  languageGuid = { 0 };
        GUID  vendorGuid   = { 0 };

        hr = pSymbolProvider->GetLanguage(pSourceAddress,
                                          &languageGuid,
                                          &vendorGuid);
        if (SUCCEEDED(hr)) {
            CLSID clsidEE      = { 0 };
            CComPtr<IDebugExpressionEvaluator> spExpressionEvaluator;
            // Get the expression evaluator's CLSID from the registry.
            ::GetEEMetric(languageGuid,
                          vendorGuid,
                          metricCLSID,
                          &clsidEE,
                          strRegistrationRoot);
            if (!IsEqualGUID(clsidEE,GUID_NULL)) {
                // Instantiate the expression evaluator.
                spExpressionEvaluator.CoCreateInstance(clsidEE);
            }
            if (spExpressionEvaluator != NULL) {
                pEE = spExpressionEvaluator.Detach();
            }
        }
    }
    return pEE;
}

See Also

Reference

IDebugExpressionContext2::ParseText

IDebugParsedExpression

IDebugParsedExpression::EvaluateSync

SDK Helpers for Debugging

Concepts

Expression Evaluation Interfaces