Edit

Share via


Context Operator in the Visual Studio Debugger (C++)

You can use the context operator in C++ to qualify a breakpoint ___location, variable name, or expression. The context operator is useful for specifying a name from an outer scope that is otherwise hidden by a local name.

Syntax

There are two ways of specifying context:

  1. {,,[module] } expression

    The braces must contain two commas and the module (executable or DLL) name or full path.

    For example, to set a breakpoint at the SomeFunction function of EXAMPLE.dll:

    {,,EXAMPLE.dll}SomeFunction
    
  2. module!expression

    EXAMPLE.dll!SomeFunction
    
  • module is the name of a module. You can use a full path to disambiguate between modules with the same name.

    If the module path includes a comma, an embedded space, or a brace, you must use quotation marks around the path so that the context parser can properly recognize the string. Single quotation marks are considered part of a Windows file name, so you must use double quotation marks. For example,

    {,,"a long, long, library name.dll"} g_Var
    
  • expression is any valid C++ expression that resolves to a valid target, such as a function name, variable name, or pointer address in module.

    When the expression evaluator encounters a symbol in an expression, it searches for the symbol in the following order:

  1. Lexical scope outward, starting with the current block, series of statements enclosed in braces, and continuing outward with the enclosing block. The current block is the code containing the current ___location, instruction pointer address.

  2. Function scope. The current function.

  3. Class scope, if the current ___location is inside a C++ member function. Class scope includes all base classes. The expression evaluator uses the normal dominance rules.

  4. Global symbols in the current module.

  5. Public symbols in the current program.