Show Table of Contents
7.7. Displaying Current Values
The
gdb utility allows you to display the value of almost anything that is relevant to the program, from a variable of any complexity to a valid expression or even a library function. However, the most common task is to display the value of a variable.
To display the current value of a certain variable, run the following command:
print variable_nameExample 7.9. Displaying the Current Values of Variables
Assuming that you have followed the instructions in Example 7.8, “Executing the fibonacci Binary File” and the execution of the
fibonacci binary stopped after reaching the breakpoint at line 10, you can display the current values of variables a and b as follows:
(gdb)print a$1 = 0 (gdb)print b$2 = 1

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.