Chapter Contents

Previous

Next
The Windowing Interface

Looking at Variables, Memory, and Registers

Much of the power of a debugger comes from its enabling you to examine the values assigned to variables, dump the contents of memory, and look at registers. For example, as you step through a program you can examine the contents of an array to see whether it is initialized as you intended.

The SAS/C Debugger includes four windows that are especially useful when you need to take a closer look at your program and the values that it is manipulating. This section explains how to use the Print, Watch, Dump, and Register windows.


Using the Print Window

The Print window can be used to display the value of an expression. To use the Print window, you direct the output of the print command to the Print window as previously described in Directing Commands to a Window. For example, in The Print Window the string pointed to by an expression named ptr1 was displayed by issuing the following command:

> print ptr1 %s

Use the command prefix > to redirect output from the print command to a new Print window. You can use >> to redirect output to an existing Print window.

Also notice that you can specify format when directing the print command to the Print window. In the previous command, %s specifies that ptr1 should be formatted as a string. You can use any of the format specifiers that are valid with the sprintf function. See print for more information about using format specifiers with the print command.

The Print Window

[IMAGE]


Using the Watch Window

The Watch window is used to track the value of an expression or an area of memory during your debugging session. It acts like an automatic print or dump command, displaying the expression or area of memory each time control is transferred to the debugger. As shown in The Watch Window, you can specify several watches, each of which is displayed in the Watch window.

The Watch Window

[IMAGE]

The watch command can be used to specify a watch; however, the easiest way to specify a watch is to open the Watch window and then set your watches by using the Expr:, N:, and Format: fields. You can use a prefix field in order to drop watches. These fields are described in Watch Window.


Using the Dump Window

The Dump window is used inorder to display a dump of memory in both character and hexadecimal format. This window is useful when you need to examine a region of memory for possible address space conflicts. For example, it can help you determine why a portion of an array is being overwritten. It can also help isolate the cause of "garbage" information in your data structures.

Output from the dump command is directed to the Dump window in much the same way as output from the print command is directed to the Print window. The > and >> command prefixes are used with the dump command to direct the output from a memory dump to either a new or existing Dump window, as described earlier in Directing Commands to a Window. For example, the following command dumps 80 bytes of memory that is pointed to by an expression named str:

> dump str 80

The output from this dump command is directed to a Dump window as illustrated by The Dump Window.

The Dump Window

[IMAGE]

As shown in The Dump Window, the relative address is displayed on the left side of the Dump window, a hexadecimal representation of the contents of memory is displayed in the middle, and an EBCDIC character representation is displayed on the right side.


Using the Register Window

The Register window, shown in The Register Window, enables you to view the contents of the 16 general-purpose registers and the 4 floating-point registers. It also displays the current instruction address and the address mode.

The Register Window

[IMAGE]

The window open register command must be used to open the Register window. Issuing this command when the Register window is open updates the window. Pressing ENTER when the cursor is in the Register window also updates it.


Chapter Contents

Previous

Next

Top of Page

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