1<html lang="en"> 2<head> 3<title>Selection - Debugging with GDB</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Debugging with GDB"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Stack.html#Stack" title="Stack"> 9<link rel="prev" href="Backtrace.html#Backtrace" title="Backtrace"> 10<link rel="next" href="Frame-Info.html#Frame-Info" title="Frame Info"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<!-- 13Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 141998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 15Free Software Foundation, Inc. 16 17Permission is granted to copy, distribute and/or modify this document 18under the terms of the GNU Free Documentation License, Version 1.3 or 19any later version published by the Free Software Foundation; with the 20Invariant Sections being ``Free Software'' and ``Free Software Needs 21Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,'' 22and with the Back-Cover Texts as in (a) below. 23 24(a) The FSF's Back-Cover Text is: ``You are free to copy and modify 25this GNU Manual. Buying copies from GNU Press supports the FSF in 26developing GNU and promoting software freedom.''--> 27<meta http-equiv="Content-Style-Type" content="text/css"> 28<style type="text/css"><!-- 29 pre.display { font-family:inherit } 30 pre.format { font-family:inherit } 31 pre.smalldisplay { font-family:inherit; font-size:smaller } 32 pre.smallformat { font-family:inherit; font-size:smaller } 33 pre.smallexample { font-size:smaller } 34 pre.smalllisp { font-size:smaller } 35 span.sc { font-variant:small-caps } 36 span.roman { font-family:serif; font-weight:normal; } 37 span.sansserif { font-family:sans-serif; font-weight:normal; } 38--></style> 39<link rel="stylesheet" type="text/css" href="../cs.css"> 40</head> 41<body> 42<div class="node"> 43<a name="Selection"></a> 44<p> 45Next: <a rel="next" accesskey="n" href="Frame-Info.html#Frame-Info">Frame Info</a>, 46Previous: <a rel="previous" accesskey="p" href="Backtrace.html#Backtrace">Backtrace</a>, 47Up: <a rel="up" accesskey="u" href="Stack.html#Stack">Stack</a> 48<hr> 49</div> 50 51<h3 class="section">8.3 Selecting a Frame</h3> 52 53<p>Most commands for examining the stack and other data in your program work on 54whichever stack frame is selected at the moment. Here are the commands for 55selecting a stack frame; all of them finish by printing a brief description 56of the stack frame just selected. 57 58 59<a name="index-frame_0040r_007b_002c-selecting_007d-425"></a> 60<a name="index-f-_0040r_007b_0028_0040code_007bframe_007d_0029_007d-426"></a> 61<dl><dt><code>frame </code><var>n</var><dt><code>f </code><var>n</var><dd>Select frame number <var>n</var>. Recall that frame zero is the innermost 62(currently executing) frame, frame one is the frame that called the 63innermost one, and so on. The highest-numbered frame is the one for 64<code>main</code>. 65 66 <br><dt><code>frame </code><var>addr</var><dt><code>f </code><var>addr</var><dd>Select the frame at address <var>addr</var>. This is useful mainly if the 67chaining of stack frames has been damaged by a bug, making it 68impossible for <span class="sc">gdb</span> to assign numbers properly to all frames. In 69addition, this can be useful when your program has multiple stacks and 70switches between them. 71 72 <p>On the MIPS and Alpha architectures, <code>frame</code> needs two addresses to 73select an arbitrary frame: a stack pointer and a program counter. 74 75 <p><a name="index-up-427"></a><br><dt><code>up </code><var>n</var><dd>Move <var>n</var> frames up the stack. For positive numbers <var>n</var>, this 76advances toward the outermost frame, to higher frame numbers, to frames 77that have existed longer. <var>n</var> defaults to one. 78 79 <p><a name="index-down-428"></a><a name="index-do-_0040r_007b_0028_0040code_007bdown_007d_0029_007d-429"></a><br><dt><code>down </code><var>n</var><dd>Move <var>n</var> frames down the stack. For positive numbers <var>n</var>, this 80advances toward the innermost frame, to lower frame numbers, to frames 81that were created more recently. <var>n</var> defaults to one. You may 82abbreviate <code>down</code> as <code>do</code>. 83</dl> 84 85 <p>All of these commands end by printing two lines of output describing the 86frame. The first line shows the frame number, the function name, the 87arguments, and the source file and line number of execution in that 88frame. The second line shows the text of that source line. 89 90 <p>For example: 91 92<pre class="smallexample"> (gdb) up 93 #1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc) 94 at env.c:10 95 10 read_input_file (argv[i]); 96</pre> 97 <p>After such a printout, the <code>list</code> command with no arguments 98prints ten lines centered on the point of execution in the frame. 99You can also edit the program at the point of execution with your favorite 100editing program by typing <code>edit</code>. 101See <a href="List.html#List">Printing Source Lines</a>, 102for details. 103 104 105<a name="index-down_002dsilently-430"></a> 106<a name="index-up_002dsilently-431"></a> 107<dl><dt><code>up-silently </code><var>n</var><dt><code>down-silently </code><var>n</var><dd>These two commands are variants of <code>up</code> and <code>down</code>, 108respectively; they differ in that they do their work silently, without 109causing display of the new frame. They are intended primarily for use 110in <span class="sc">gdb</span> command scripts, where the output might be unnecessary and 111distracting. 112</dl> 113 114 </body></html> 115 116