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