Chapter Contents

Previous

Next
Window Directory

Watch Window

Watch Window

[IMAGE]

DESCRIPTION
The Watch window tracks values of expressions or areas of memory. It acts as an automatic print or dump command, displaying the expression or area of memory each time control is transferred to the debugger. As shown in Watch Window, the Watch window contains several fields that are used to control the window, as well as two areas that are used to display the expressions or areas of memory being watched.

Selecting a watch You can select as many as 40 expressions or areas of memory to be watched. The watches are completely independent of each other and the debugger does not check for duplicates. Each watch is updated as the value of the expression or the contents of the memory location change. The following fields are used to select an expression or area of memory to be watched:

Expr:
specifies an expression to be watched. Any expression that is valid as an argument to the print or dump command can be issued, provided that it can be evaluated at the time that the watch is entered. When the ENTER key is pressed, the expression is displayed in the watch name field, and its value is displayed in the expression value area.

N:
specifies the number of bytes to be watched. The maximum value for this field is 64, which dumps 64 bytes of memory starting at the address that is indicated by the expression in the Expr: field. The N: field be used can only when you are typing an expression that points to an area of memory.

Format:
specifies a display format to be used to format the value that is displayed in the expression value area. You can specify a format when you are watching the value of an expression; however, you cannot use a format when you are watching an area of memory.

Display area After a watch is selected, it is displayed in the following areas:

prefix area
drops a watch from the Watch window. The prefix area is one column wide and is located immediately before the watch name area. By typing a d in the prefix area and pressing ENTER you can drop any of the watches that are displayed in the window.

watch name area
describes the expression to be watched. In the Watch window in Watch Window, the expression c is displayed in the first two watch name areas. The first watch for c uses the default format, the second watch for c is formatted by %c.

If an expression that you are watching belongs to a function that is different from that of the command scope, the expression that is displayed in the watch name area is prefixed with the name of the function to which it belongs. For example, if you were to step through the program that is shown in the Watch window in Watch Window, each of the expressions that are being watched would be prefixed with MAIN: in the event that you stepped into another function. The reason for this is that the command scope would no longer be the same as the scope of the expressions that are being watched.

If the expression that you are watching is longer than the width of the watch name area, the expression is clipped on the right. Resizing the window by increasing its width displays more of the expression.

expression value area
displays the value of the expression that you are watching. As shown by the Watch window that is illustrated in Watch Window, the format of the information that is displayed in the expression value area depends on the type of expression and how it was typed. Conversion specifiers that were typed in the Format: field affect the format of information that is in the same way as they do when they are used with the print command. Typing a number in the N: field causes the information to be formatted in a manner similar to the output from the dump command.

For print style watches, if no format is specified, scalars are displayed by using the same default format as would be used if the expression were displayed by the print command.

Unions, structures, and arrays are displayed as a list of values separated by commas and enclosed by braces. If a format is specified, it is used to display the value of all items of the aggregate; if no format is specified, %d is used for signed integral items, %u is used for unsigned integral items, %g for floating-point items, and 0p%08x for pointers. If there is not sufficient space in the expression value area, the list is ended with an ellipsis (...).

Single-dimensional character arrays are formatted in dump style if no format is specified; a maximum of 64 bytes can be displayed using this format. If a format is specified for a single-dimensional character array, the information that is contained in memory is displayed in a list that is similar to that used for other arrays.

For dump style watches, the address is displayed and it is followed by the contents of memory. A hexadecimal and character representation of the information in memory is displayed in a format similar to the output from the dump command.

The prefix, watch name, and expression value areas can be scrolled up or down. You can also scroll right and left through the expression value area.

Calling sequence You can watch an expression that is anywhere within the calling sequence for your program. However, when you set the watch it must be located inside your command scope. You cannot use the FUNCTION-NAME:IDENTIFIER format to specify an expression that is outside the command scope; you must change your command scope before you type the watch. This format is described in Specifying Identifiers Outside the Current Function. The scope command can be used to change your command scope to any function that is in your calling sequence.

Thus, each watch has a function that is associated with it. The scope of this function is set each time the debugger evaluates the watch expression, which occurs each time that control is transferred from your program to the debugger. Watches that are based on variables of the extern or static storage class can always be evaluated; watches that are based on an automatic variable or parameter can be evaluated only if the function is in the calling sequence. As soon as the function ends, the automatic variable or parameter-based watch is deactivated; the next time the function is typed, the watch is reactivated. This also applies to watches that are based on automatic variables or parameters in a recursive function. Since the watch is reactivated only if inactive, recursive invocations of the function do not set additional watches.

Syntactically invalid input If an invalid input is detected at the time a watch is set, a Popup window is automatically opened and you can correct the mistake. The error does not affect the debugging session in any way.

ADDITIONAL DISCUSSION
Using the Watch Window

SEE ALSO
The dump, print, and watch commands for the following:


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.