The Context Operator

The context operator ({ }) is unique to CodeView. It is not part of the C or C++ languages. You use it to specify the exact context of an expression or line number that appears in more than one place in your source code. For example, you might use this operator to specify a symbol defined in an include file when the file is included more than once or to specify a name in an outer scope that is otherwise hidden by a local name.

When you use a symbol in a CodeView expression, the C and C++ expression evaluators search for that symbol in the following order:

1.Lexical scope outward. The expression evaluator searches for the symbol starting with the current block (a series of statements enclosed in curly braces) and continuing with the enclosing block. The current block is the code containing the current location (CS:IP address).

2.Function scope. The expression evaluator searches for the symbol in the current function.

3.Class scope. If debugging C++ and within the scope of a member function, the expression evaluator searches symbols of that member function's class and all its base classes. The C++ expression evaluator uses the normal dominance rules.

4.Current module. The expression evaluator searches all symbols in the current module.

5.Global symbols. The expression evaluator searches all global symbols in the program.

6.Other modules. The expression evaluator searches the global symbols in all other modules in the program.

7.Public symbols in the program.

If the name is not found in any of these places, and the name is not the name of a register, CodeView displays an error message.

The context operator lets you specify the starting point of the search and bypass the current location. Note that you cannot specify a block because a block has no name. You cannot specify a class, but you can specify a member function of the class and let the expression evaluator search outward.

Syntax

{[[function]],[[module]],[[dllexe]]}[[object]]

function

The name of a function in the program.

module

The name of a source file. You must specify a source file if the function is outside the current scope. If the file is not in the current directory, you must specify the path.

dllexe

The path of a program's DLL or .EXE file.

object

A line number or symbol.

The context operator has the same precedence and associativity as the type-cast operator. You can omit function, module, or dllexe, but you must specify all leading commas. You can omit trailing commas. If a name contains a comma, you must enclose the name in parentheses.

Example

The following example displays the value of the variable Pos, which is local to the function make_box, which is defined in the source file DRAWBOX.C. Assuming that there is more than one source file called DRAWBOX.C, the third parameter specifies that the source file containing the function make_box is the one used by DISPTXT.DLL.

? {make_box,C:\TREE1\DRAWBOX.C,C:\TREE2\DISPTXT.DLL}Pos