• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2011.09/share/doc/arm-arm-none-eabi/html/gdb/
1<html lang="en">
2<head>
3<title>Continuing and Stepping - 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="Stopping.html#Stopping" title="Stopping">
9<link rel="prev" href="Breakpoints.html#Breakpoints" title="Breakpoints">
10<link rel="next" href="Signals.html#Signals" title="Signals">
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="Continuing-and-Stepping"></a>
44<p>
45Next:&nbsp;<a rel="next" accesskey="n" href="Signals.html#Signals">Signals</a>,
46Previous:&nbsp;<a rel="previous" accesskey="p" href="Breakpoints.html#Breakpoints">Breakpoints</a>,
47Up:&nbsp;<a rel="up" accesskey="u" href="Stopping.html#Stopping">Stopping</a>
48<hr>
49</div>
50
51<h3 class="section">5.2 Continuing and Stepping</h3>
52
53<p><a name="index-stepping-284"></a><a name="index-continuing-285"></a><a name="index-resuming-execution-286"></a><dfn>Continuing</dfn> means resuming program execution until your program
54completes normally.  In contrast, <dfn>stepping</dfn> means executing just
55one more &ldquo;step&rdquo; of your program, where &ldquo;step&rdquo; may mean either one
56line of source code, or one machine instruction (depending on what
57particular command you use).  Either when continuing or when stepping,
58your program may stop even sooner, due to a breakpoint or a signal.  (If
59it stops due to a signal, you may want to use <code>handle</code>, or use
60&lsquo;<samp><span class="samp">signal 0</span></samp>&rsquo; to resume execution.  See <a href="Signals.html#Signals">Signals</a>.)
61
62     
63<a name="index-continue-287"></a>
64<a name="index-c-_0040r_007b_0028_0040code_007bcontinue_007d_0029_007d-288"></a>
65<a name="index-fg-_0040r_007b_0028resume-foreground-execution_0029_007d-289"></a>
66<dl><dt><code>continue </code><span class="roman">[</span><var>ignore-count</var><span class="roman">]</span><dt><code>c </code><span class="roman">[</span><var>ignore-count</var><span class="roman">]</span><dt><code>fg </code><span class="roman">[</span><var>ignore-count</var><span class="roman">]</span><dd>Resume program execution, at the address where your program last stopped;
67any breakpoints set at that address are bypassed.  The optional argument
68<var>ignore-count</var> allows you to specify a further number of times to
69ignore a breakpoint at this location; its effect is like that of
70<code>ignore</code> (see <a href="Conditions.html#Conditions">Break Conditions</a>).
71
72     <p>The argument <var>ignore-count</var> is meaningful only when your program
73stopped due to a breakpoint.  At other times, the argument to
74<code>continue</code> is ignored.
75
76     <p>The synonyms <code>c</code> and <code>fg</code> (for <dfn>foreground</dfn>, as the
77debugged program is deemed to be the foreground program) are provided
78purely for convenience, and have exactly the same behavior as
79<code>continue</code>. 
80</dl>
81
82   <p>To resume execution at a different place, you can use <code>return</code>
83(see <a href="Returning.html#Returning">Returning from a Function</a>) to go back to the
84calling function; or <code>jump</code> (see <a href="Jumping.html#Jumping">Continuing at a Different Address</a>) to go to an arbitrary location in your program.
85
86   <p>A typical technique for using stepping is to set a breakpoint
87(see <a href="Breakpoints.html#Breakpoints">Breakpoints; Watchpoints; and Catchpoints</a>) at the
88beginning of the function or the section of your program where a problem
89is believed to lie, run your program until it stops at that breakpoint,
90and then step through the suspect area, examining the variables that are
91interesting, until you see the problem happen.
92
93     
94<a name="index-step-290"></a>
95<a name="index-s-_0040r_007b_0028_0040code_007bstep_007d_0029_007d-291"></a>
96<dl><dt><code>step</code><dd>Continue running your program until control reaches a different source
97line, then stop it and return control to <span class="sc">gdb</span>.  This command is
98abbreviated <code>s</code>.
99
100     <blockquote>
101<!-- "without debugging information" is imprecise; actually "without line -->
102<!-- numbers in the debugging information".  (gcc -g1 has debugging info but -->
103<!-- not line numbers).  But it seems complex to try to make that -->
104<!-- distinction here. -->
105<em>Warning:</em> If you use the <code>step</code> command while control is
106within a function that was compiled without debugging information,
107execution proceeds until control reaches a function that does have
108debugging information.  Likewise, it will not step into a function which
109is compiled without debugging information.  To step through functions
110without debugging information, use the <code>stepi</code> command, described
111below. 
112</blockquote>
113
114     <p>The <code>step</code> command only stops at the first instruction of a source
115line.  This prevents the multiple stops that could otherwise occur in
116<code>switch</code> statements, <code>for</code> loops, etc.  <code>step</code> continues
117to stop if a function that has debugging information is called within
118the line.  In other words, <code>step</code> <em>steps inside</em> any functions
119called within the line.
120
121     <p>Also, the <code>step</code> command only enters a function if there is line
122number information for the function.  Otherwise it acts like the
123<code>next</code> command.  This avoids problems when using <code>cc -gl</code>
124on MIPS machines.  Previously, <code>step</code> entered subroutines if there
125was any debugging information about the routine.
126
127     <br><dt><code>step </code><var>count</var><dd>Continue running as in <code>step</code>, but do so <var>count</var> times.  If a
128breakpoint is reached, or a signal not related to stepping occurs before
129<var>count</var> steps, stepping stops right away.
130
131     <p><a name="index-next-292"></a><a name="index-n-_0040r_007b_0028_0040code_007bnext_007d_0029_007d-293"></a><br><dt><code>next </code><span class="roman">[</span><var>count</var><span class="roman">]</span><dd>Continue to the next source line in the current (innermost) stack frame. 
132This is similar to <code>step</code>, but function calls that appear within
133the line of code are executed without stopping.  Execution stops when
134control reaches a different line of code at the original stack level
135that was executing when you gave the <code>next</code> command.  This command
136is abbreviated <code>n</code>.
137
138     <p>An argument <var>count</var> is a repeat count, as for <code>step</code>.
139
140     <!-- FIX ME!!  Do we delete this, or is there a way it fits in with -->
141     <!-- the following paragraph?   -  Vctoria -->
142     <!-- @code{next} within a function that lacks debugging information acts like -->
143     <!-- @code{step}, but any function calls appearing within the code of the -->
144     <!-- function are executed without stopping. -->
145     <p>The <code>next</code> command only stops at the first instruction of a
146source line.  This prevents multiple stops that could otherwise occur in
147<code>switch</code> statements, <code>for</code> loops, etc.
148
149     <p><a name="index-set-step_002dmode-294"></a><br><dt><code>set step-mode</code><dd><a name="index-functions-without-line-info_002c-and-stepping-295"></a><a name="index-stepping-into-functions-with-no-line-info-296"></a><dt><code>set step-mode on</code><dd>The <code>set step-mode on</code> command causes the <code>step</code> command to
150stop at the first instruction of a function which contains no debug line
151information rather than stepping over it.
152
153     <p>This is useful in cases where you may be interested in inspecting the
154machine instructions of a function which has no symbolic info and do not
155want <span class="sc">gdb</span> to automatically skip over this function.
156
157     <br><dt><code>set step-mode off</code><dd>Causes the <code>step</code> command to step over any functions which contains no
158debug information.  This is the default.
159
160     <br><dt><code>show step-mode</code><dd>Show whether <span class="sc">gdb</span> will stop in or step over functions without
161source line debug information.
162
163     <p><a name="index-finish-297"></a><a name="index-fin-_0040r_007b_0028_0040code_007bfinish_007d_0029_007d-298"></a><br><dt><code>finish</code><dd>Continue running until just after function in the selected stack frame
164returns.  Print the returned value (if any).  This command can be
165abbreviated as <code>fin</code>.
166
167     <p>Contrast this with the <code>return</code> command (see <a href="Returning.html#Returning">Returning from a Function</a>).
168
169     <p><a name="index-until-299"></a><a name="index-u-_0040r_007b_0028_0040code_007buntil_007d_0029_007d-300"></a><a name="index-run-until-specified-location-301"></a><br><dt><code>until</code><dt><code>u</code><dd>Continue running until a source line past the current line, in the
170current stack frame, is reached.  This command is used to avoid single
171stepping through a loop more than once.  It is like the <code>next</code>
172command, except that when <code>until</code> encounters a jump, it
173automatically continues execution until the program counter is greater
174than the address of the jump.
175
176     <p>This means that when you reach the end of a loop after single stepping
177though it, <code>until</code> makes your program continue execution until it
178exits the loop.  In contrast, a <code>next</code> command at the end of a loop
179simply steps back to the beginning of the loop, which forces you to step
180through the next iteration.
181
182     <p><code>until</code> always stops your program if it attempts to exit the current
183stack frame.
184
185     <p><code>until</code> may produce somewhat counterintuitive results if the order
186of machine code does not match the order of the source lines.  For
187example, in the following excerpt from a debugging session, the <code>f</code>
188(<code>frame</code>) command shows that execution is stopped at line
189<code>206</code>; yet when we use <code>until</code>, we get to line <code>195</code>:
190
191     <pre class="smallexample">          (gdb) f
192          #0  main (argc=4, argv=0xf7fffae8) at m4.c:206
193          206                 expand_input();
194          (gdb) until
195          195             for ( ; argc &gt; 0; NEXTARG) {
196</pre>
197     <p>This happened because, for execution efficiency, the compiler had
198generated code for the loop closure test at the end, rather than the
199start, of the loop&mdash;even though the test in a C <code>for</code>-loop is
200written before the body of the loop.  The <code>until</code> command appeared
201to step back to the beginning of the loop when it advanced to this
202expression; however, it has not really gone to an earlier
203statement&mdash;not in terms of the actual machine code.
204
205     <p><code>until</code> with no argument works by means of single
206instruction stepping, and hence is slower than <code>until</code> with an
207argument.
208
209     <br><dt><code>until </code><var>location</var><dt><code>u </code><var>location</var><dd>Continue running your program until either the specified location is
210reached, or the current stack frame returns.  <var>location</var> is any of
211the forms described in <a href="Specify-Location.html#Specify-Location">Specify Location</a>. 
212This form of the command uses temporary breakpoints, and
213hence is quicker than <code>until</code> without an argument.  The specified
214location is actually reached only if it is in the current frame.  This
215implies that <code>until</code> can be used to skip over recursive function
216invocations.  For instance in the code below, if the current location is
217line <code>96</code>, issuing <code>until 99</code> will execute the program up to
218line <code>99</code> in the same invocation of factorial, i.e., after the inner
219invocations have returned.
220
221     <pre class="smallexample">          94	int factorial (int value)
222          95	{
223          96	    if (value &gt; 1) {
224          97            value *= factorial (value - 1);
225          98	    }
226          99	    return (value);
227          100     }
228</pre>
229     <p><a name="index-advance-_0040var_007blocation_007d-302"></a><dt><code>advance </code><var>location</var><dd>Continue running the program up to the given <var>location</var>.  An argument is
230required, which should be of one of the forms described in
231<a href="Specify-Location.html#Specify-Location">Specify Location</a>. 
232Execution will also stop upon exit from the current stack
233frame.  This command is similar to <code>until</code>, but <code>advance</code> will
234not skip over recursive function calls, and the target location doesn't
235have to be in the same frame as the current one.
236
237     <p><a name="index-stepi-303"></a><a name="index-si-_0040r_007b_0028_0040code_007bstepi_007d_0029_007d-304"></a><br><dt><code>stepi</code><dt><code>stepi </code><var>arg</var><dt><code>si</code><dd>Execute one machine instruction, then stop and return to the debugger.
238
239     <p>It is often useful to do &lsquo;<samp><span class="samp">display/i $pc</span></samp>&rsquo; when stepping by machine
240instructions.  This makes <span class="sc">gdb</span> automatically display the next
241instruction to be executed, each time your program stops.  See <a href="Auto-Display.html#Auto-Display">Automatic Display</a>.
242
243     <p>An argument is a repeat count, as in <code>step</code>.
244
245     <p><a name="index-nexti-305"></a><a name="index-ni-_0040r_007b_0028_0040code_007bnexti_007d_0029_007d-306"></a><br><dt><code>nexti</code><dt><code>nexti </code><var>arg</var><dt><code>ni</code><dd>Execute one machine instruction, but if it is a function call,
246proceed until the function returns.
247
248     <p>An argument is a repeat count, as in <code>next</code>. 
249</dl>
250
251   </body></html>
252
253