User`s guide
20
Chapter 4: Controlling dbx
The commands described in this section apply only to the manipulations of
dbx variables, not program variables. “Displaying and Changing Program
Variables” on page 39 describes how to manipulate program variables.
Setting
dbx
Variables
Theset command sets a dbx variable to a given value, defining the variable if
it does not exist:
set var = exp Define (or redefine) the specified dbx variable, setting its
value to that of the expression you provide.
You can display the value of a variable with the print command. For
example:
(dbx) set $k = 1
(dbx) print $k
1
(dbx) set $k = $k +23
(dbx) print $k
24
(dbx) print $k / 11
2
In the above example, dbx performs an integer division because both the
variable $k and the constant 11 are integers. If you assign a floating point
value to $k and evaluate the expression again,dbx performs a floating point
division:
(dbx) set $k = 24.0
(dbx) print $k
24.0
(dbx) print $k / 11
2.1818181818181817
Note: We recommend that you begin a dbx variable with a $ to avoid
confusion with a program variable. Adbx variable without a leading $ hides
any program variable that has the same name. The only way to see the
program variable is to remove the dbx variable with an unset command.