3.8.4. Using the Watch window

The Watch window allows you to set watches on variables and expressions. The Watch window provides similar functionality to the debugger Local and Global windows. In addition, it provides a C++ interpretation of the data being displayed.

Note

The Watch window is not used to set watchpoints. Select Set or Edit Watchpoint... from the Execute menu to set watchpoints. Refer to Simple watchpoints and Complex watchpoints for more information.

Evaluation of function pointers and member functions is not available in this version of ADW or ADU.

You can specify the contents and format of the Watch window using the Watch window menu. The following sections describe how to:

Viewing the Watch window

Follow these steps to view the Watch window:

  1. Select Show Watch Window from the C++ menu or click on the Show Watches button in the toolbar. The Watch window displays a list of watched variables and expressions. Figure 3.24 shows an example.

    Figure 3.24. The Watch window

    The Watch window

    Expressions that return a scalar value are displayed as an expression-value pair. Non-scalar values, such as structures and classes, are displayed as a tree of member variables. If a class is derived, the base classes are represented by ::<base class> member variables of the class.

Note

You can also open the Watch window from the Evaluate Expression window. Refer to Evaluating expressions and adding watches for more information.

Displaying the Watch window menu

The Watch window menu enables you to add and delete watches, to change the display format of watches, and to change the contents of watched variables. Follow these steps to display the Watch window menu:

  1. Display the Watch window.

  2. Click the right mouse button in the Watch window. The Watch window menu is displayed. This menu is context sensitive. The menu items that it contains will depend on:

    • whether or not you have clicked on an existing watch item

    • the type of watch item you have clicked on.

    For example, Figure 3.25 shows the Watch window menu that is displayed when the right mouse button is clicked on the character array buf.

    Figure 3.25. The Watch window menu

    The Watch window menu

Deleting a watch item

Follow these steps to delete a watch item from the Watch window:

  1. Display the Watch window.

  2. Either:

    • click the right mouse button on the item you want to delete and select Delete Item from the Watch window menu

    • click on the item you want to delete and press the Delete key.

    The watch item is deleted from the Watch window.

Adding a watch item

Follow these steps to add a watch item to the Watch window:

  1. Display the Watch window.

  2. Either:

    • click the right mouse button in the Watch window to display the Watch window menu and select Add Item from the Watch window menu

    • press the Insert key.

    A Watch Control window is displayed (Figure 3.26).

    Figure 3.26. The Watch Control window

    The Watch Control window
  3. Enter an expression to add to the Watch window and click OK. Refer to Evaluating expressions and adding watches for more information on the types of expression you can add to the Watch window.

Note

You can also add an expression to the Watch window directly from the Evaluate Expression window. Refer to Evaluating expressions and adding watches for more information.

Formatting watch items

Follow these steps to change the formatting of values displayed in the Watch window:

  1. Display the Watch window.

  2. Click the right mouse button in the Watch window to display the Watch window menu.

  3. Select Format Window to format all items in the window. The Display Format window is displayed (Figure 3.27).

    Figure 3.27. The Display Format window

    The Display Format window
  4. Enter a format string for the item, or items in the window. You can enter any single print conversion specifier that is acceptable as an argument to ANSI C sprintf() as a format string, except that * cannot be used as a precision. For example, enter %x to format values in hexadecimal, or %f to format values as a character string.

  5. Click OK to apply the format change.

Changing the contents of watched items

Follow these steps to change the contents of items in the Watch window:

  1. Display the Watch window.

  2. Click the right mouse button in the Watch window to display the Watch window menu.

  3. Select Edit value from the Watch window menu. The Modify Item window is displayed (Figure 3.28).

    Figure 3.28. The Modify Item window

    The Modify Item window
  4. Enter a new value for the variable.

  5. Click OK to change the contents of the variable.

Recalculating watches

Select Recalculate Watches from the C++ menu or click on the Recalculate Watches button in the toolbar to reinitialize the Watch window to its original state, with all structures and classes expanded by one level. This menu item can be used if the value of any variable may have been changed by external hardware while the debugger is not stepping through code.

Copyright © 1997, 1998 ARM Limited. All rights reserved.ARM DUI 0040D
Non-Confidential