C and C++ SoftBench User's Guide

Using SoftBench Debugger
Examining and Changing Data in Your Program
Chapter 7182
For example, suppose you debug the following code fragment:
x=0; y=9;
while (y<1000) {
x=sqrt(y);
x++;
y=x*x;
}
Set a breakpoint on the "x=sqrt(y)" line, and run the program. When
the program stops at the breakpoint, the PC arrow is at that line. Enter
"x" in the "()" input box (or simply double-click on "x", and SoftBench
Debugger automatically enters it into the "()" input box) and select Print
( )
. SoftBench Debugger displays the value "0", because the assignment
has not been executed. Select Step Over, and the PC arrow moves to the
next line. Select Print ( ) to display the result of the assignment ("3").
Examining Data in Your Program
To print the value of a simple variable or expression:
1. Enter a variable name in the "()" input box. You can double-click or
highlight the variable name in the program source to copy it to the
"()" input box. If the Current Location points to the procedure
containing the variable, you can use the name of the variable without
any qualifiers. If not, specify it according to the rules defined in
“Specifying Variables” on page 178.
2. Select Print ( ). SoftBench Debugger displays the value of the variable
in the Debugger Output Area.
You can also evaluate expressions. For example, if n is a numeric variable
in the current querying scope, n/12.0 prints one-twelfth of n.
If you print an expression that contains a function call, the function
executes. Be aware that this invokes any side effects in the function.
To print the value of a variable referenced by a pointer:
1. Enter the pointer name in the "()" input box. If the pointer is defined
in the procedure referred to by the Current Location, you can use the
name of the pointer directly. If not, specify it according to the rules
defined in “Specifying Variables” on page 178.
2. Select Print* ( ). SoftBench Debugger displays the value of the variable
in the Debugger Output Area.