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