
Examining Data
Motorola
GNU Debugger (GDB)
For More Information On This Product,
Go to: www.freescale.com
D-33
.
Because the ‘directory’ command adds to the end of the source path, it does not affect any
file that GDB has already found. If the source path contains directories that you do not
want, and these directories contain misleading files with names matching your source
files, the way to correct the situation is as follows:
1. Choose the directory you want at the beginning of the source path. Use the ‘cd’
command to make that the current working directory.
2. Use ‘directory’ with no argument to reset the source path to just that directory.
3. Use ‘directory’ with suitable arguments to add any other directories you want in the
source path.
D.9 Examining Data
The usual way to examine data in your program is with the ‘print’ command (abbreviated
‘p’). It evaluates and prints the value of any valid expression of the language the program
is written in (for now, C). You type
print exp
where exp is any valid expression, and the value of exp is printed in a format appropriate
to its data type.
A more low-level way of examining data is with the ‘x’ command. It examines data in
memory at a specified address and prints it in a specified format.
D.9.1 Expressions
Many different GDB commands accept an expression and compute its value. Any kind of
constant, variable or operator defined by the programming language you are using is legal
in an expression in GDB. This includes conditional expressions, function calls, casts and
Table D-14. Directory Commands
Command
Description
directory dirnames...
Add directory dirname to the end of the source path. Several directory names may
be given to this command, separated by whitespace or ‘:’.
directory
Reset the source path to just the current working directory of GDB.
This requires confirmation.Since this command deletes directories from the search
path, it may change the directory in which a previously read source file will be
discovered. To make this work correctly, this command also clears out the tables
GDB maintains about the source files it has already found.
info directories
Print the source path: show which directories it contains.
F
Freescale Semiconductor, Inc.
n
.