How-to: Enable Debugger Autos Window Support

A debugger's Autos window automatically shows the values of relevant expressions during debugging. Relevant expressions are typically identifiers (for example, parameters and variables that have recently changed) or pointer indirections around the source line that is currently being debugged.

To have debugger support for your language, you either need to implement your own debug engine or target the Common Language Runtime (CLR), which includes a default debug engine for intermediate language (IL) code. Typically, you also need to write an expression evaluator before the Locals window and Watch window for it to work correctly. For more information about debug engines and expression evaluators, see the Visual Studio Debugger Extensibility. Even with a debugger and expression evaluator, the Autos window cannot work until it can locate relevant expressions from the source file.

Babel provides support for the Autos window. Babel sends identifiers that are added through the startName and qualifyName methods to the list of relevant expressions. It is even possible to send arbitrary expressions to the Autos window for subsequent evaluation. The standard service provides the following method for adding Autos window expressions:

void autoExpression( in const Location& expr ) const;

注意

You must provide your own lex/yacc-compatible tools; these tools are not included in the VS SDK and the language service project will not build without them. To build the language service using the sample grammar and parser for the sample My C Package, you must use version 1.24 or later of Bison and version 2.5.4a or later of Flex. Place the Bison and Flex executables in the Babel Tools folder, for example, <InstallPath>\VisualStudioIntegration\Babel\Tools. These version numbers are specific to the My C sample.

To modify the My C sample to send numbers and parenthesized expressions to the Autos windows, in addition to the identifiers that are automatically sent, the following modifications to the grammar rules are required:

Factor
    : Identifier ParenArguments 
    | Identifier
    | NUMBER          { g_service->autoExpression( $1 ); }
    | ParenExpr       { g_service->autoExpression( $1 ); }

Code Spans

The debug engine validates breakpoints that you set. For example, a breakpoint set in the middle of comments or a type definition is not valid. The Babel package checks for comments and other lexical structures, but it does not recognize which regions constitute executable code. The global service exposes the codeSpan method for providing this information, as follows:

void codeSpan( in const Location& start, in const Location& end ) const;

Call this method for each region that consists of executable code, typically procedures or methods. The following example from the My C sample shows how to call this method for each statement block:

Example of Determining which Regions Constitute Executable Code in My C

Block
  :'{' BlockContent1 '}'
      { $$ = g_service->range($1,$3);
        g_service->codeSpan($1,$3);
        g_service->matchPair($1,$3);
        g_service->addScopeText( $1, $3, 
                                 ScopeBlock, AccessPublic, StorageOther);  
      }
  ...

See Also

Concepts

Language Service How-to Topics