Examining Annotated Source

The Annotated Source View of a Defect Log displays the code that is a subject of a PREfast for Drivers warning in context. The Annotated Source View can display the single line of code that triggered the warning, the function in which the code is located, and the entire source file in which the code originates.

The following screen shot shows the annotated source view of the PREfast Defect Log.

Screen shot showing the annotated source view of the PREfast Defect Log

This view is so useful that many users examine their PREfast for Drivers warnings from this view, rather than browsing the Message List. As such, the Annotated Source View includes buttons for navigating through the warning list.

Typically, users focus on the PREfast for Drivers warning and on the line of code in red just above the warning. Note that although the first line of the offending statement always appears in red, the warning might have been triggered by code in a subsequent line of the statement. This code appears in grey, below the pink warning box.

To open Annotated Source View:

  1. Use a PREfast View command to open a Defect Log.

  2. In the Message List, double-click a warning.

Features of Annotated Source View

The following are features of the Annotated Source view.

  • Warning details appear at the top of the page. To open context-sensitive Help for that specific warning, click the warning number (in blue).

  • The function that triggered the warning is displayed below the details.

  • The path through the function is preceded by a blue bar that says PREfast analysis path begins and followed by a pink bar that displays the warning details. Click the warning number (in blue) to open context-sensitive Help.

  • The first line of code in the statement that triggered the warning appears in red.

  • Source code statements that are executed in the path to the error are displayed in black text. Unexecuted statements are displayed in grey text.

  • Statements that are executed more than once in the path are displayed on a light yellow background. When the source code statement that triggers the warning is executed more than once, it is displayed in red on a light yellow background and each instance of that statement's line number in the list of statements is also displayed on a light yellow background.

You can use the features of the Annotated Source View to assist you in your analysis of the results.

For example, when a light yellow background appears in the viewer, it is very likely that the warning was generated on the second or later pass through a loop. The list of line numbers in the path list can indicate how PREfast discovered the problem.

Also, although the first line of the offending statement always appears in red, the warning might have been triggered by code in a subsequent line of the statement. This code appears in black or grey below the pink warning box.

Actions in Annotated Source View

The buttons at the top of the page let you navigate though the warning list while remaining in Annotated Source View.

  • To display the previous warning, click Prev.

  • To display the next warning, click Next.

  • To display context-sensitive Help, click the warning number.

  • To return to the Message List, click Msg List.

The buttons on the side of the page display the current warning in different contexts.

  • To display the file in which the code appears, click Show Entire File.

  • To display only the function in which the code appears, click Show Only Function.

  • To go to the beginning of the function, click Start of Function.

  • To go to the beginning of the PREfast analysis path, click Start of Path.

  • To go to the line that triggered the warning, click Warning Line.

To close Annotated Source View:

  • In Annotated Source View, click the Msg List button.

 

 

Send comments about this topic to Microsoft

Build date: 5/3/2011