Using the WDB GUI · Using the Watch View Home and Help Icons Keyword Index Home Using Help
Line Graphic
Line Graphic

Contents

Keyword Index

Using the WDB GUI
Starting and Exiting the WDB GUI
Loading a Program and Changing Program Settings
Opening Source Files
Changing the Working Directory
Saving and Restoring Debug Sessions
Setting Source Paths
Setting Object Paths
Viewing Your Code
Browsing Functions
Setting Signal Handling
Finding Specific Text in Your Code
Using the Command View
{short description of image} Using the Watch View
Using Quick Watch
Using the Local Variables View
Using the Call Stack View
Using the Threads View
Using the Registers View
Examining Memory Use
Using the Program Console
Using Breakpoints
Advancing Through Your Program
Fixing Code from within the Debugger
Starting and Stopping the Debug Process
Setting Debugger Preferences
Customizing Colors and Fonts

Reference Information

Troubleshooting

Using Help



Bullet Overview
Bullet Watching Variables
Bullet Adding and Deleting Watch Variables
Bullet Changing the Value of a Variable
Bullet Tips
Bullet See Also

Line Graphic

Overview

The Watch view displays the names and values of variables or expressions. It is similar to the Local Variables view, but the Watch view allows you to specify the variables that are displayed. You can watch global variables, local variables, or variables not in the current stack.

Line Graphic

Watching Variables

You can display specified global or local variables in the Watch view when your program is paused. It is useful to watch specific variable values to verify that your program is behaving as expected.

To view variables

  1. In the main window, click the Watch tab. The view displays the names and values of global and local variables you specified.
  2. To expand an expression, click the plus sign (+) to the left of its name or double-click the line. To collapse an expression, click the minus sign (-) or double-click the line.

To see the Watch view in a separate window

  • Click the right mouse button, then click Open Separate View. The separate window behaves the same as the tabbed Watch view.
  • To close the separate window, click the right mouse button, then click Close.

    See Tips for a shortcut to opening a separate window.
Line Graphic

Adding and Deleting Watch Variables

To add a variable to the Watch view

  1. In the Watch view, click in the Add text box. Type the name of a variable or expression.
  2. Press Enter. The Watch view evaluates the variable or expression immediately and displays its value.

To delete a variable from the Watch view

  1. In the Watch view, select a variable. You can only delete the highest level of a variable or expression; you cannot delete subvalues of an expanded expression.
  2. Press the Delete key, or right-click and select Delete Selected Line from the pop-up menu.
Line Graphic

Changing the Value of a Variable

When the program is paused at a breakpoint or between steps, you can change the value of any numeric or pointer variable. The modified value replaces the current value in the program. This lets you try changes and see their results in real time or recover from certain logic errors.

To change a variable value

  1. In the Watch view, double-click the value you want to edit. A cursor appears in the Value field.
  2. Edit the variable's value.
  3. Press Enter to update the program with the modified variable value.

    See Tips in the Watch View reference topic for keyboard shortcuts.

NOTES:
  • Press the Esc key to cancel the edit.
  • Character string pointers--You cannot change the content of the string, but you can change the address value to point to a string at a different memory address.
  • Character arrays -- You can edit the content of a character array, but there is no safeguard to prevent you from writing past the allocated array size. Also, the value must be entered inside double quotes.
Line Graphic

Tips

  • The value of a variable is highlighted in red if it has changed in the current context since the last break in program execution.
  • Click the Watch toolbar button to open and close the Watch view in a separate window.
  • Click the right mouse button to display a pop-up menu that contains commands to delete a line and open or close a separate window.
  • On the View menu, click Watch to quickly bring the Watch view to the top.
  • Keyboard shortcuts are available for moving in the Watch view and editing a value. See Tips in the Watch View reference topic.
Line Graphic

See Also

Line Graphic

Return to Top