Skip to content

Expression Evaluators Overview

Gregg Miskelly edited this page Jan 21, 2022 · 7 revisions

Expression Evaluators (EEs) are components which are typically implemented by compiler vendors. They allow users to debug in the same language as the code was written. They do this by flavoring various debugger windows, such as the Watch, Call stack, and Function breakpoints to the language of the code. Generally, expression evaluators and selected based on the language of the call stack frame being inspected.

Tasks performed by an Expression Evaluator

An EE is responsible for performing the following tasks, which are broken down by the user scenarios in which these tasks get invoked. Interface method names are provided in parenthesis, and discussed in other sections of the wiki.

Callstack window:

Given a stack frame and a set of flags that indicate the user’s options (whether to display the parameter types, values, etc.), compute a display string for the frame (IDkmLanguageInstructionDecoder.GetFrameName).

Breakpoints Window:

Given the instruction address for a piece of code, obtain the formatted name for the function located at that address, in other words, the function column of the breakpoints window (IDkmLanguageInstructionDecoder.GetMethodName).

Locals Window

Given a stack frame, obtain the list of local variables and their values for display in the Locals window (IDkmLanguageExpressionEvaluator.GetFrameLocals for languages that compile to native code or IDkmClrExpressionCompiler.GetClrLocalVariableQuery for .NET languages).

All EE windows (Watch, Quick Watch, Locals, Immediate, and DataTips)

  • Given a string of text that contains an expression to evaluate, evaluate the expression and obtain display strings for the value and type of the expression (IDkmLanguageExpressionEvaluator.EvaluateExpression for languages that compile to native code or IDkmClrExpressionCompiler.CompileExpression for .NET languages).
  • For .NET languages, format the raw result into a value string (IDkmClrFormatter.GetValueString) and a type name string (IDkmClrFormatter.GetTypeName).
  • Given a value, obtain a list of optional flags and attributes, such as whether the value is editable, represents a class, etc. Such attributes are used in the UI to display various special icons associated with the attributes.
  • Given a value, obtain an “editable value” string. When you double-click on the value column to edit, this is the default text that appears.
  • Assign a value to the result of another expression when the user types something in the value column and hits enter
  • Given a value, obtain the list of child values to show when the value gets expanded (for native lanugages, IDkmLanguageExpressionEvaluator.GetChildren).

Breakpoint Binding

When binding a function breakpoint, parse the location text and obtain the code location that the user is referring to (IDkmRuntimeFunctionResolver.EnableResolution)

Debugger Automation (DTE)

Stack frame return types (IDkmLanguageInstructionDecoder.GetReturnType) and arguments (for native languages, IDkmLanguageExpressionEvaluator.GetFrameArguments).

Writing an Expression Evaluator

If you have written a compiler and you want it to work seamlessly with the Visual Studio Debugger, you'll want to write an EE. If your compiler compiles down to native/machine code, look at the section Native Expression Evaluators. If your compiler targets .NET look at the section .NET Expression Evaluators.

Clone this wiki locally