Export (0) Print
Expand All

Context Operator (C/C++ Language Expressions)

This information pertains to debugging native C++ programs only. The context operator is an additional operator provided by the native debugger. When debugging native code, you can use the context operator to qualify a breakpoint location, variable name, or expression:

  • {[function],[source],[module] } location
  • {[function],[source],[ module] } variable_name
  • {[function],[source],[ module] } expression

The braces can contain any combination of function name, source file pathname, and module (executable or DLL) pathname. The context operator is useful for purposes such as specifying a name from an outer scope that is otherwise hidden by a local name.

Example

To set a breakpoint at line 301 of EXAMPLE.CPP:

{,EXAMPLE.CPP,}@301

If you omit either function or module, the two commas cannot be omitted. As a result, the following syntax is illegal:

{File.c, File.exe} @143 // Illegal syntax

If you omit both source and module, however, you can omit the commas. The following syntax is legal:

{Fun} @143

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

{,"a long, long, name.c", } .143

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. Current module.
  5. Global symbols.
  6. Other modules.
  7. Public symbols in the program.

With the context operator, you specify the starting point of the search and bypass the current location. You cannot specify a class, but you can specify a member function of the class and let the expression evaluator search outward.

See Also

Expressions in C/C++

Show:
© 2014 Microsoft