Displaying Variables151
•The
info frame
command shows more information about the current frame,
including some register values. It also shows the stack pointer for the previous frame.
These values are taken from the stack.
•The
info args
command displays arguments passed to this frame. This is also taken
from the stack.
•The
info locals
command displays the values of local variables. These variable
have a scope limited to the current frame.
•The
info reg
command displays values of register values.
•The
info all-reg
command displays register values, including math registers.
•The
up
command takes you one level up in the stack. This means if you are inside a
function call, the up command will take you to the function that called the current
function. The
down
command is opposite to the
up
command.
•You can use
backtrace
,
up
and
down
commands to move around in different
frames. These commands are useful for looking into stack data.
A combination of all of these commands used with other execution control command can
be used to display a lot of information. If you want to effectively use
GNU
debugger, knowledge
of commands related to stack is a must.
5.5Displaying Variables
Using the GNU debugger, you can display environment variables as well as your program vari-
ables during the program execution. You can control display of some variables so that the value
of these variables is displayed with each command. Using this feature you can easily track
changes taking place to these variables when you step through the program. You can also modify
the program as well as environment variables. This section shows examples of how to carry out
these tasks.
5.5.1Displaying Program Variables
The following session uses the
sum.c
program that you already used earlier in this chap-
ter. Go through the following
gdb
session and then see the discussion at the end of this session
about actions taking place.
[rr@conformix 5]$ gdb sum
GNU gdb 5.0rh-5 Red Hat Linux 7.1
Copyright 2001 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public
License, and you are
welcome to change it and/or distribute copies of it under
certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty"
for details.
Next Page >>
<< Previous Page
Back to the Table of Contents