Work around MinGW mangling of "host:/path"
[msysgit/historical-msysgit.git] / mingw / info / gdb / GDB-MI-Stack-Manipulation.html
blob89d97dc594f9947656ff6d8b36cb7ebba82dadc1
1 <html lang="en">
2 <head>
3 <title>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.3">
7 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
8 </head>
9 <body>
10 <div class="node">
11 <p>
12 Node:<a name="GDB%2fMI%20Stack%20Manipulation">GDB/MI Stack Manipulation</a>,
13 Next:<a rel="next" accesskey="n" href="GDB-MI-Symbol-Query.html#GDB%2fMI%20Symbol%20Query">GDB/MI Symbol Query</a>,
14 Previous:<a rel="previous" accesskey="p" href="GDB-MI-Miscellaneous-Commands.html#GDB%2fMI%20Miscellaneous%20Commands">GDB/MI Miscellaneous Commands</a>,
15 Up:<a rel="up" accesskey="u" href="GDB-MI.html#GDB%2fMI">GDB/MI</a>
16 <hr><br>
17 </div>
19 <h3 class="section"><small>GDB/MI</small> Stack Manipulation Commands</h3>
21 <h4 class="subheading">The <code>-stack-info-frame</code> Command</h4>
23 <h5 class="subsubheading">Synopsis</h5>
25 <pre class="example"> -stack-info-frame
26 </pre>
28 <p>Get info on the current frame.
30 <h5 class="subsubheading">GDB Command</h5>
32 <p>The corresponding GDB command is <code>info frame</code> or <code>frame</code>
33 (without arguments).
35 <h5 class="subsubheading">Example</h5>
37 <p>N.A.
39 <h4 class="subheading">The <code>-stack-info-depth</code> Command</h4>
41 <h5 class="subsubheading">Synopsis</h5>
43 <pre class="example"> -stack-info-depth [ <var>max-depth</var> ]
44 </pre>
46 <p>Return the depth of the stack. If the integer argument <var>max-depth</var>
47 is specified, do not count beyond <var>max-depth</var> frames.
49 <h5 class="subsubheading">GDB Command</h5>
51 <p>There's no equivalent GDB command.
53 <h5 class="subsubheading">Example</h5>
55 <p>For a stack with frame levels 0 through 11:
57 <pre class="smallexample"> (gdb)
58 -stack-info-depth
59 ^done,depth="12"
60 (gdb)
61 -stack-info-depth 4
62 ^done,depth="4"
63 (gdb)
64 -stack-info-depth 12
65 ^done,depth="12"
66 (gdb)
67 -stack-info-depth 11
68 ^done,depth="11"
69 (gdb)
70 -stack-info-depth 13
71 ^done,depth="12"
72 (gdb)
73 </pre>
75 <h4 class="subheading">The <code>-stack-list-arguments</code> Command</h4>
77 <h5 class="subsubheading">Synopsis</h5>
79 <pre class="example"> -stack-list-arguments <var>show-values</var>
80 [ <var>low-frame</var> <var>high-frame</var> ]
81 </pre>
83 <p>Display a list of the arguments for the frames between <var>low-frame</var>
84 and <var>high-frame</var> (inclusive). If <var>low-frame</var> and
85 <var>high-frame</var> are not provided, list the arguments for the whole call
86 stack.
88 <p>The <var>show-values</var> argument must have a value of 0 or 1. A value of
89 0 means that only the names of the arguments are listed, a value of 1
90 means that both names and values of the arguments are printed.
92 <h5 class="subsubheading">GDB Command</h5>
94 GDB does not have an equivalent command. <code>gdbtk</code> has a
95 <code>gdb_get_args</code> command which partially overlaps with the
96 functionality of <code>-stack-list-arguments</code>.
98 <h5 class="subsubheading">Example</h5>
100 <pre class="smallexample"> (gdb)
101 -stack-list-frames
102 ^done,
103 stack=[
104 frame={level="0 ",addr="0x00010734",func="callee4",
105 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"},
106 frame={level="1 ",addr="0x0001076c",func="callee3",
107 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="17"},
108 frame={level="2 ",addr="0x0001078c",func="callee2",
109 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="22"},
110 frame={level="3 ",addr="0x000107b4",func="callee1",
111 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="27"},
112 frame={level="4 ",addr="0x000107e0",func="main",
113 file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="32"}]
114 (gdb)
115 -stack-list-arguments 0
116 ^done,
117 stack-args=[
118 frame={level="0",args=[]},
119 frame={level="1",args=[name="strarg"]},
120 frame={level="2",args=[name="intarg",name="strarg"]},
121 frame={level="3",args=[name="intarg",name="strarg",name="fltarg"]},
122 frame={level="4",args=[]}]
123 (gdb)
124 -stack-list-arguments 1
125 ^done,
126 stack-args=[
127 frame={level="0",args=[]},
128 frame={level="1",
129 args=[{name="strarg",value="0x11940 \"A string argument.\""}]},
130 frame={level="2",args=[
131 {name="intarg",value="2"},
132 {name="strarg",value="0x11940 \"A string argument.\""}]},
133 {frame={level="3",args=[
134 {name="intarg",value="2"},
135 {name="strarg",value="0x11940 \"A string argument.\""},
136 {name="fltarg",value="3.5"}]},
137 frame={level="4",args=[]}]
138 (gdb)
139 -stack-list-arguments 0 2 2
140 ^done,stack-args=[frame={level="2",args=[name="intarg",name="strarg"]}]
141 (gdb)
142 -stack-list-arguments 1 2 2
143 ^done,stack-args=[frame={level="2",
144 args=[{name="intarg",value="2"},
145 {name="strarg",value="0x11940 \"A string argument.\""}]}]
146 (gdb)
147 </pre>
149 <h4 class="subheading">The <code>-stack-list-frames</code> Command</h4>
151 <h5 class="subsubheading">Synopsis</h5>
153 <pre class="example"> -stack-list-frames [ <var>low-frame</var> <var>high-frame</var> ]
154 </pre>
156 <p>List the frames currently on the stack. For each frame it displays the
157 following info:
159 <dl>
160 <dt><code></code><var>level</var><code></code>
161 <dd>The frame number, 0 being the topmost frame, i.e. the innermost function.
162 <br><dt><code></code><var>addr</var><code></code>
163 <dd>The <code>$pc</code> value for that frame.
164 <br><dt><code></code><var>func</var><code></code>
165 <dd>Function name.
166 <br><dt><code></code><var>file</var><code></code>
167 <dd>File name of the source file where the function lives.
168 <br><dt><code></code><var>line</var><code></code>
169 <dd>Line number corresponding to the <code>$pc</code>.
170 </dl>
172 <p>If invoked without arguments, this command prints a backtrace for the
173 whole stack. If given two integer arguments, it shows the frames whose
174 levels are between the two arguments (inclusive). If the two arguments
175 are equal, it shows the single frame at the corresponding level.
177 <h5 class="subsubheading">GDB Command</h5>
179 <p>The corresponding GDB commands are <code>backtrace</code> and <code>where</code>.
181 <h5 class="subsubheading">Example</h5>
183 <p>Full stack backtrace:
185 <pre class="smallexample"> (gdb)
186 -stack-list-frames
187 ^done,stack=
188 [frame={level="0 ",addr="0x0001076c",func="foo",
189 file="recursive2.c",line="11"},
190 frame={level="1 ",addr="0x000107a4",func="foo",
191 file="recursive2.c",line="14"},
192 frame={level="2 ",addr="0x000107a4",func="foo",
193 file="recursive2.c",line="14"},
194 frame={level="3 ",addr="0x000107a4",func="foo",
195 file="recursive2.c",line="14"},
196 frame={level="4 ",addr="0x000107a4",func="foo",
197 file="recursive2.c",line="14"},
198 frame={level="5 ",addr="0x000107a4",func="foo",
199 file="recursive2.c",line="14"},
200 frame={level="6 ",addr="0x000107a4",func="foo",
201 file="recursive2.c",line="14"},
202 frame={level="7 ",addr="0x000107a4",func="foo",
203 file="recursive2.c",line="14"},
204 frame={level="8 ",addr="0x000107a4",func="foo",
205 file="recursive2.c",line="14"},
206 frame={level="9 ",addr="0x000107a4",func="foo",
207 file="recursive2.c",line="14"},
208 frame={level="10",addr="0x000107a4",func="foo",
209 file="recursive2.c",line="14"},
210 frame={level="11",addr="0x00010738",func="main",
211 file="recursive2.c",line="4"}]
212 (gdb)
213 </pre>
215 <p>Show frames between <var>low_frame</var> and <var>high_frame</var>:
217 <pre class="smallexample"> (gdb)
218 -stack-list-frames 3 5
219 ^done,stack=
220 [frame={level="3 ",addr="0x000107a4",func="foo",
221 file="recursive2.c",line="14"},
222 frame={level="4 ",addr="0x000107a4",func="foo",
223 file="recursive2.c",line="14"},
224 frame={level="5 ",addr="0x000107a4",func="foo",
225 file="recursive2.c",line="14"}]
226 (gdb)
227 </pre>
229 <p>Show a single frame:
231 <pre class="smallexample"> (gdb)
232 -stack-list-frames 3 3
233 ^done,stack=
234 [frame={level="3 ",addr="0x000107a4",func="foo",
235 file="recursive2.c",line="14"}]
236 (gdb)
237 </pre>
239 <h4 class="subheading">The <code>-stack-list-locals</code> Command</h4>
241 <h5 class="subsubheading">Synopsis</h5>
243 <pre class="example"> -stack-list-locals <var>print-values</var>
244 </pre>
246 <p>Display the local variable names for the current frame. With an
247 argument of 0 prints only the names of the variables, with argument of 1
248 prints also their values.
250 <h5 class="subsubheading">GDB Command</h5>
252 <p><code>info locals</code> in GDB, <code>gdb_get_locals</code> in <code>gdbtk</code>.
254 <h5 class="subsubheading">Example</h5>
256 <pre class="smallexample"> (gdb)
257 -stack-list-locals 0
258 ^done,locals=[name="A",name="B",name="C"]
259 (gdb)
260 -stack-list-locals 1
261 ^done,locals=[{name="A",value="1"},{name="B",value="2"},
262 {name="C",value="3"}]
263 (gdb)
264 </pre>
266 <h4 class="subheading">The <code>-stack-select-frame</code> Command</h4>
268 <h5 class="subsubheading">Synopsis</h5>
270 <pre class="example"> -stack-select-frame <var>framenum</var>
271 </pre>
273 <p>Change the current frame. Select a different frame <var>framenum</var> on
274 the stack.
276 <h5 class="subsubheading">GDB Command</h5>
278 <p>The corresponding GDB commands are <code>frame</code>, <code>up</code>,
279 <code>down</code>, <code>select-frame</code>, <code>up-silent</code>, and <code>down-silent</code>.
281 <h5 class="subsubheading">Example</h5>
283 <pre class="smallexample"> (gdb)
284 -stack-select-frame 2
285 ^done
286 (gdb)
287 </pre>
289 </body></html>