neingeist
/
arduinisten
Archived
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

610 lines
25 KiB
HTML

<HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- Created on March, 27 2008 by texi2html 1.64 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
-->
<HEAD>
<TITLE>Debugging with GDB: Stack</TITLE>
<META NAME="description" CONTENT="Debugging with GDB: Stack">
<META NAME="keywords" CONTENT="Debugging with GDB: Stack">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="texi2html 1.64">
</HEAD>
<BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<A NAME="SEC46"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_6.html#SEC45"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC47"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_8.html#SEC51"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_8.html#SEC51"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H1> 6. Examining the Stack </H1>
<!--docid::SEC46::-->
<P>
When your program has stopped, the first thing you need to know is where it
stopped and how it got there.
</P><P>
<A NAME="IDX283"></A>
Each time your program performs a function call, information about the call
is generated.
That information includes the location of the call in your program,
the arguments of the call,
and the local variables of the function being called.
The information is saved in a block of data called a <EM>stack frame</EM>.
The stack frames are allocated in a region of memory called the <EM>call
stack</EM>.
</P><P>
When your program stops, the GDB commands for examining the
stack allow you to see all of this information.
</P><P>
<A NAME="IDX284"></A>
One of the stack frames is <EM>selected</EM> by GDB and many
GDB commands refer implicitly to the selected frame. In
particular, whenever you ask GDB for the value of a variable in
your program, the value is found in the selected frame. There are
special GDB commands to select whichever frame you are
interested in. See section <A HREF="gdb_7.html#SEC49">Selecting a Frame</A>.
</P><P>
When your program stops, GDB automatically selects the
currently executing frame and describes it briefly, similar to the
<CODE>frame</CODE> command (see section <A HREF="gdb_7.html#SEC50">Information about a Frame</A>).
</P><P>
<BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_7.html#SEC47">6.1 Stack Frames</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Stack frames</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_7.html#SEC48">6.2 Backtraces</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP"></TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_7.html#SEC49">6.3 Selecting a Frame</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Selecting a frame</TD></TR>
<TR><TD ALIGN="left" VALIGN="TOP"><A HREF="gdb_7.html#SEC50">6.4 Information About a Frame</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Information on a frame</TD></TR>
</TABLE>
<br>
</BLOCKQUOTE>
<P>
<A NAME="Frames"></A>
<HR SIZE="6">
<A NAME="SEC47"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC46"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC48"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC46"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC46"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_8.html#SEC51"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 6.1 Stack Frames </H2>
<!--docid::SEC47::-->
<P>
<A NAME="IDX285"></A>
<A NAME="IDX286"></A>
The call stack is divided up into contiguous pieces called <EM>stack
frames</EM>, or <EM>frames</EM> for short; each frame is the data associated
with one call to one function. The frame contains the arguments given
to the function, the function's local variables, and the address at
which the function is executing.
</P><P>
<A NAME="IDX287"></A>
<A NAME="IDX288"></A>
<A NAME="IDX289"></A>
When your program is started, the stack has only one frame, that of the
function <CODE>main</CODE>. This is called the <EM>initial</EM> frame or the
<EM>outermost</EM> frame. Each time a function is called, a new frame is
made. Each time a function returns, the frame for that function invocation
is eliminated. If a function is recursive, there can be many frames for
the same function. The frame for the function in which execution is
actually occurring is called the <EM>innermost</EM> frame. This is the most
recently created of all the stack frames that still exist.
</P><P>
<A NAME="IDX290"></A>
Inside your program, stack frames are identified by their addresses. A
stack frame consists of many bytes, each of which has its own address; each
kind of computer has a convention for choosing one byte whose
address serves as the address of the frame. Usually this address is kept
in a register called the <EM>frame pointer register</EM>
(see section <A HREF="gdb_9.html#SEC69">$fp</A>) while execution is going on in that frame.
</P><P>
<A NAME="IDX291"></A>
GDB assigns numbers to all existing stack frames, starting with
zero for the innermost frame, one for the frame that called it,
and so on upward. These numbers do not really exist in your program;
they are assigned by GDB to give you a way of designating stack
frames in GDB commands.
</P><P>
<A NAME="IDX292"></A>
Some compilers provide a way to compile functions so that they operate
without stack frames. (For example, the GCC option
<TABLE><tr><td>&nbsp;</td><td class=smallexample><FONT SIZE=-1><pre><SAMP>`-fomit-frame-pointer'</SAMP>
</FONT></pre></td></tr></table>generates functions without a frame.)
This is occasionally done with heavily used library functions to save
the frame setup time. GDB has limited facilities for dealing
with these function invocations. If the innermost function invocation
has no stack frame, GDB nevertheless regards it as though
it had a separate frame, which is numbered zero as usual, allowing
correct tracing of the function call chain. However, GDB has
no provision for frameless functions elsewhere in the stack.
</P><P>
<DL COMPACT>
<A NAME="IDX293"></A>
<A NAME="IDX294"></A>
<DT><CODE>frame <VAR>args</VAR></CODE>
<DD>The <CODE>frame</CODE> command allows you to move from one stack frame to another,
and to print the stack frame you select. <VAR>args</VAR> may be either the
address of the frame or the stack frame number. Without an argument,
<CODE>frame</CODE> prints the current stack frame.
<P>
<A NAME="IDX295"></A>
<A NAME="IDX296"></A>
<DT><CODE>select-frame</CODE>
<DD>The <CODE>select-frame</CODE> command allows you to move from one stack frame
to another without printing the frame. This is the silent version of
<CODE>frame</CODE>.
</DL>
<P>
<A NAME="Backtrace"></A>
<HR SIZE="6">
<A NAME="SEC48"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC47"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC49"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC49"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC46"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_8.html#SEC51"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 6.2 Backtraces </H2>
<!--docid::SEC48::-->
<P>
<A NAME="IDX297"></A>
<A NAME="IDX298"></A>
A backtrace is a summary of how your program got where it is. It shows one
line per frame, for many frames, starting with the currently executing
frame (frame zero), followed by its caller (frame one), and on up the
stack.
</P><P>
<DL COMPACT>
<A NAME="IDX299"></A>
<A NAME="IDX300"></A>
<DT><CODE>backtrace</CODE>
<DD><DT><CODE>bt</CODE>
<DD>Print a backtrace of the entire stack: one line per frame for all
frames in the stack.
<P>
You can stop the backtrace at any time by typing the system interrupt
character, normally <KBD>Ctrl-c</KBD>.
</P><P>
<DT><CODE>backtrace <VAR>n</VAR></CODE>
<DD><DT><CODE>bt <VAR>n</VAR></CODE>
<DD>Similar, but print only the innermost <VAR>n</VAR> frames.
<P>
<DT><CODE>backtrace -<VAR>n</VAR></CODE>
<DD><DT><CODE>bt -<VAR>n</VAR></CODE>
<DD>Similar, but print only the outermost <VAR>n</VAR> frames.
<P>
<DT><CODE>backtrace full</CODE>
<DD><DT><CODE>bt full</CODE>
<DD><DT><CODE>bt full <VAR>n</VAR></CODE>
<DD><DT><CODE>bt full -<VAR>n</VAR></CODE>
<DD>Print the values of the local variables also. <VAR>n</VAR> specifies the
number of frames to print, as described above.
</DL>
<P>
<A NAME="IDX301"></A>
<A NAME="IDX302"></A>
The names <CODE>where</CODE> and <CODE>info stack</CODE> (abbreviated <CODE>info s</CODE>)
are additional aliases for <CODE>backtrace</CODE>.
</P><P>
<A NAME="IDX303"></A>
In a multi-threaded program, GDB by default shows the
backtrace only for the current thread. To display the backtrace for
several or all of the threads, use the command <CODE>thread apply</CODE>
(see section <A HREF="gdb_5.html#SEC27">thread apply</A>). For example, if you type <KBD>thread
apply all backtrace</KBD>, GDB will display the backtrace for all
the threads; this is handy when you debug a core dump of a
multi-threaded program.
</P><P>
Each line in the backtrace shows the frame number and the function name.
The program counter value is also shown--unless you use <CODE>set
print address off</CODE>. The backtrace also shows the source file name and
line number, as well as the arguments to the function. The program
counter value is omitted if it is at the beginning of the code for that
line number.
</P><P>
Here is an example of a backtrace. It was made with the command
<SAMP>`bt 3'</SAMP>, so it shows the innermost three frames.
</P><P>
<TABLE><tr><td>&nbsp;</td><td class=smallexample><FONT SIZE=-1><pre>#0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
at builtin.c:993
#1 0x6e38 in expand_macro (sym=0x2b600) at macro.c:242
#2 0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08)
at macro.c:71
(More stack frames follow...)
</FONT></pre></td></tr></table></P><P>
The display for frame zero does not begin with a program counter
value, indicating that your program has stopped at the beginning of the
code for line <CODE>993</CODE> of <CODE>builtin.c</CODE>.
</P><P>
<A NAME="IDX304"></A>
<A NAME="IDX305"></A>
If your program was compiled with optimizations, some compilers will
optimize away arguments passed to functions if those arguments are
never used after the call. Such optimizations generate code that
passes arguments through registers, but doesn't store those arguments
in the stack frame. GDB has no way of displaying such
arguments in stack frames other than the innermost one. Here's what
such a backtrace might look like:
</P><P>
<TABLE><tr><td>&nbsp;</td><td class=smallexample><FONT SIZE=-1><pre>#0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
at builtin.c:993
#1 0x6e38 in expand_macro (sym=&#60;value optimized out&#62;) at macro.c:242
#2 0x6840 in expand_token (obs=0x0, t=&#60;value optimized out&#62;, td=0xf7fffb08)
at macro.c:71
(More stack frames follow...)
</FONT></pre></td></tr></table></P><P>
The values of arguments that were not saved in their stack frames are
shown as <SAMP>`&#60;value optimized out&#62;'</SAMP>.
</P><P>
If you need to display the values of such optimized-out arguments,
either deduce that from other variables whose values depend on the one
you are interested in, or recompile without optimizations.
</P><P>
<A NAME="IDX306"></A>
<A NAME="IDX307"></A>
<A NAME="IDX308"></A>
Most programs have a standard user entry point--a place where system
libraries and startup code transition into user code. For C this is
<CODE>main</CODE><A NAME="DOCF3" HREF="gdb_fot.html#FOOT3">(3)</A>.
When GDB finds the entry function in a backtrace
it will terminate the backtrace, to avoid tracing into highly
system-specific (and generally uninteresting) code.
</P><P>
If you need to examine the startup code, or limit the number of levels
in a backtrace, you can change this behavior:
</P><P>
<DL COMPACT>
<DT><CODE>set backtrace past-main</CODE>
<DD><DT><CODE>set backtrace past-main on</CODE>
<DD><A NAME="IDX309"></A>
Backtraces will continue past the user entry point.
<P>
<DT><CODE>set backtrace past-main off</CODE>
<DD>Backtraces will stop when they encounter the user entry point. This is the
default.
<P>
<DT><CODE>show backtrace past-main</CODE>
<DD><A NAME="IDX310"></A>
Display the current user entry point backtrace policy.
<P>
<DT><CODE>set backtrace past-entry</CODE>
<DD><DT><CODE>set backtrace past-entry on</CODE>
<DD>Backtraces will continue past the internal entry point of an application.
This entry point is encoded by the linker when the application is built,
and is likely before the user entry point <CODE>main</CODE> (or equivalent) is called.
<P>
<DT><CODE>set backtrace past-entry off</CODE>
<DD>Backtraces will stop when they encounter the internal entry point of an
application. This is the default.
<P>
<DT><CODE>show backtrace past-entry</CODE>
<DD>Display the current internal entry point backtrace policy.
<P>
<DT><CODE>set backtrace limit <VAR>n</VAR></CODE>
<DD><DT><CODE>set backtrace limit 0</CODE>
<DD><A NAME="IDX311"></A>
Limit the backtrace to <VAR>n</VAR> levels. A value of zero means
unlimited.
<P>
<DT><CODE>show backtrace limit</CODE>
<DD>Display the current limit on backtrace levels.
</DL>
<P>
<A NAME="Selection"></A>
<HR SIZE="6">
<A NAME="SEC49"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC48"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC50"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC50"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC46"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_8.html#SEC51"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 6.3 Selecting a Frame </H2>
<!--docid::SEC49::-->
<P>
Most commands for examining the stack and other data in your program work on
whichever stack frame is selected at the moment. Here are the commands for
selecting a stack frame; all of them finish by printing a brief description
of the stack frame just selected.
</P><P>
<DL COMPACT>
<A NAME="IDX312"></A>
<A NAME="IDX313"></A>
<DT><CODE>frame <VAR>n</VAR></CODE>
<DD><DT><CODE>f <VAR>n</VAR></CODE>
<DD>Select frame number <VAR>n</VAR>. Recall that frame zero is the innermost
(currently executing) frame, frame one is the frame that called the
innermost one, and so on. The highest-numbered frame is the one for
<CODE>main</CODE>.
<P>
<DT><CODE>frame <VAR>addr</VAR></CODE>
<DD><DT><CODE>f <VAR>addr</VAR></CODE>
<DD>Select the frame at address <VAR>addr</VAR>. This is useful mainly if the
chaining of stack frames has been damaged by a bug, making it
impossible for GDB to assign numbers properly to all frames. In
addition, this can be useful when your program has multiple stacks and
switches between them.
<P>
On the SPARC architecture, <CODE>frame</CODE> needs two addresses to
select an arbitrary frame: a frame pointer and a stack pointer.
</P><P>
On the MIPS and Alpha architecture, it needs two addresses: a stack
pointer and a program counter.
</P><P>
On the 29k architecture, it needs three addresses: a register stack
pointer, a program counter, and a memory stack pointer.
</P><P>
<A NAME="IDX314"></A>
<DT><CODE>up <VAR>n</VAR></CODE>
<DD>Move <VAR>n</VAR> frames up the stack. For positive numbers <VAR>n</VAR>, this
advances toward the outermost frame, to higher frame numbers, to frames
that have existed longer. <VAR>n</VAR> defaults to one.
<P>
<A NAME="IDX315"></A>
<A NAME="IDX316"></A>
<DT><CODE>down <VAR>n</VAR></CODE>
<DD>Move <VAR>n</VAR> frames down the stack. For positive numbers <VAR>n</VAR>, this
advances toward the innermost frame, to lower frame numbers, to frames
that were created more recently. <VAR>n</VAR> defaults to one. You may
abbreviate <CODE>down</CODE> as <CODE>do</CODE>.
</DL>
<P>
All of these commands end by printing two lines of output describing the
frame. The first line shows the frame number, the function name, the
arguments, and the source file and line number of execution in that
frame. The second line shows the text of that source line.
</P><P>
For example:
</P><P>
<TABLE><tr><td>&nbsp;</td><td class=smallexample><FONT SIZE=-1><pre>(gdb) up
#1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc)
at env.c:10
10 read_input_file (argv[i]);
</FONT></pre></td></tr></table></P><P>
After such a printout, the <CODE>list</CODE> command with no arguments
prints ten lines centered on the point of execution in the frame.
You can also edit the program at the point of execution with your favorite
editing program by typing <CODE>edit</CODE>.
See section <A HREF="gdb_8.html#SEC52">Printing Source Lines</A>,
for details.
</P><P>
<DL COMPACT>
<A NAME="IDX317"></A>
<A NAME="IDX318"></A>
<DT><CODE>up-silently <VAR>n</VAR></CODE>
<DD><DT><CODE>down-silently <VAR>n</VAR></CODE>
<DD>These two commands are variants of <CODE>up</CODE> and <CODE>down</CODE>,
respectively; they differ in that they do their work silently, without
causing display of the new frame. They are intended primarily for use
in GDB command scripts, where the output might be unnecessary and
distracting.
</DL>
<P>
<A NAME="Frame Info"></A>
<HR SIZE="6">
<A NAME="SEC50"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC49"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_8.html#SEC51"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC46"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC46"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_8.html#SEC51"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 6.4 Information About a Frame </H2>
<!--docid::SEC50::-->
<P>
There are several other commands to print information about the selected
stack frame.
</P><P>
<DL COMPACT>
<DT><CODE>frame</CODE>
<DD><DT><CODE>f</CODE>
<DD>When used without any argument, this command does not change which
frame is selected, but prints a brief description of the currently
selected stack frame. It can be abbreviated <CODE>f</CODE>. With an
argument, this command is used to select a stack frame.
See section <A HREF="gdb_7.html#SEC49">Selecting a Frame</A>.
<P>
<A NAME="IDX319"></A>
<A NAME="IDX320"></A>
<DT><CODE>info frame</CODE>
<DD><DT><CODE>info f</CODE>
<DD>This command prints a verbose description of the selected stack frame,
including:
<P>
<UL>
<LI>
the address of the frame
<LI>
the address of the next frame down (called by this frame)
<LI>
the address of the next frame up (caller of this frame)
<LI>
the language in which the source code corresponding to this frame is written
<LI>
the address of the frame's arguments
<LI>
the address of the frame's local variables
<LI>
the program counter saved in it (the address of execution in the caller frame)
<LI>
which registers were saved in the frame
</UL>
<P>
The verbose description is useful when
something has gone wrong that has made the stack format fail to fit
the usual conventions.
</P><P>
<DT><CODE>info frame <VAR>addr</VAR></CODE>
<DD><DT><CODE>info f <VAR>addr</VAR></CODE>
<DD>Print a verbose description of the frame at address <VAR>addr</VAR>, without
selecting that frame. The selected frame remains unchanged by this
command. This requires the same kind of address (more than one for some
architectures) that you specify in the <CODE>frame</CODE> command.
See section <A HREF="gdb_7.html#SEC49">Selecting a Frame</A>.
<P>
<A NAME="IDX321"></A>
<DT><CODE>info args</CODE>
<DD>Print the arguments of the selected frame, each on a separate line.
<P>
<DT><CODE>info locals</CODE>
<DD><A NAME="IDX322"></A>
Print the local variables of the selected frame, each on a separate
line. These are all variables (declared either static or automatic)
accessible at the point of execution of the selected frame.
<P>
<A NAME="IDX323"></A>
<A NAME="IDX324"></A>
<A NAME="IDX325"></A>
<DT><CODE>info catch</CODE>
<DD>Print a list of all the exception handlers that are active in the
current stack frame at the current point of execution. To see other
exception handlers, visit the associated frame (using the <CODE>up</CODE>,
<CODE>down</CODE>, or <CODE>frame</CODE> commands); then type <CODE>info catch</CODE>.
See section <A HREF="gdb_6.html#SEC35">Setting Catchpoints</A>.
<P>
</DL>
<P>
<A NAME="Source"></A>
<HR SIZE="6">
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_7.html#SEC46"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_8.html#SEC51"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_38.html#SEC764">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="gdb_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<BR>
<FONT SIZE="-1">
<address>
<p>Please send FSF &amp; GNU inquiries &amp; questions to <a
href="mailto:gnu@gnu.org">gnu@gnu.org</a>. There are also <a
href="http://www.gnu.org/home.html#ContactInfo">other ways to
contact</a> the FSF.</p>
<p>These pages are maintained by <a
href="http://www.gnu.org/software/gdb/">the GDB developers</a>.</p>
<p>Copyright Free Software Foundation, Inc., 59 Temple Place - Suite
330, Boston, MA 02111, USA.</p>
<p>Verbatim copying and distribution of this entire article is
permitted in any medium, provided this notice is preserved.</p>
</address>
This document was generated
by <I>GDB Administrator</I> on <I>March, 27 2008</I>
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
"><I>texi2html</I></A>
</BODY>
</HTML>