]>
Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Print and select stack frames for GDB, the GNU debugger. |
8926118c AC |
2 | |
3 | Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, | |
1a111ce3 AC |
4 | 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free |
5 | Software Foundation, Inc. | |
c906108c | 6 | |
c5aa993b | 7 | This file is part of GDB. |
c906108c | 8 | |
c5aa993b JM |
9 | This program is free software; you can redistribute it and/or modify |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 2 of the License, or | |
12 | (at your option) any later version. | |
c906108c | 13 | |
c5aa993b JM |
14 | This program is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
c906108c | 18 | |
c5aa993b JM |
19 | You should have received a copy of the GNU General Public License |
20 | along with this program; if not, write to the Free Software | |
21 | Foundation, Inc., 59 Temple Place - Suite 330, | |
22 | Boston, MA 02111-1307, USA. */ | |
c906108c SS |
23 | |
24 | #include <ctype.h> | |
25 | #include "defs.h" | |
26 | #include "gdb_string.h" | |
27 | #include "value.h" | |
28 | #include "symtab.h" | |
29 | #include "gdbtypes.h" | |
30 | #include "expression.h" | |
31 | #include "language.h" | |
32 | #include "frame.h" | |
33 | #include "gdbcmd.h" | |
34 | #include "gdbcore.h" | |
35 | #include "target.h" | |
0378c332 | 36 | #include "source.h" |
c906108c SS |
37 | #include "breakpoint.h" |
38 | #include "demangle.h" | |
39 | #include "inferior.h" | |
40 | #include "annotate.h" | |
8b93c638 | 41 | #include "ui-out.h" |
fe898f56 | 42 | #include "block.h" |
b9362cc7 | 43 | #include "stack.h" |
8d3b0994 | 44 | #include "gdb_assert.h" |
de4f826b | 45 | #include "dictionary.h" |
898c62f5 | 46 | #include "reggroups.h" |
fc70c2a0 | 47 | #include "regcache.h" |
c906108c SS |
48 | |
49 | /* Prototypes for exported functions. */ | |
50 | ||
a14ed312 | 51 | void args_info (char *, int); |
c906108c | 52 | |
a14ed312 | 53 | void locals_info (char *, int); |
c906108c | 54 | |
9a4105ab | 55 | void (*deprecated_selected_frame_level_changed_hook) (int); |
c906108c | 56 | |
a14ed312 | 57 | void _initialize_stack (void); |
c906108c | 58 | |
a58dd373 | 59 | /* Prototypes for local functions. */ |
c906108c | 60 | |
a14ed312 | 61 | static void down_command (char *, int); |
c906108c | 62 | |
a14ed312 | 63 | static void down_silently_base (char *); |
c906108c | 64 | |
a14ed312 | 65 | static void down_silently_command (char *, int); |
c906108c | 66 | |
a14ed312 | 67 | static void up_command (char *, int); |
c906108c | 68 | |
a14ed312 | 69 | static void up_silently_base (char *); |
c906108c | 70 | |
a14ed312 | 71 | static void up_silently_command (char *, int); |
c906108c | 72 | |
a14ed312 | 73 | void frame_command (char *, int); |
c906108c | 74 | |
a14ed312 | 75 | static void current_frame_command (char *, int); |
7a292a7a | 76 | |
d9fcf2fb | 77 | static void print_frame_arg_vars (struct frame_info *, struct ui_file *); |
c906108c | 78 | |
a14ed312 | 79 | static void catch_info (char *, int); |
c906108c | 80 | |
a14ed312 | 81 | static void args_plus_locals_info (char *, int); |
c906108c | 82 | |
d9fcf2fb JM |
83 | static void print_frame_label_vars (struct frame_info *, int, |
84 | struct ui_file *); | |
c906108c | 85 | |
d9fcf2fb JM |
86 | static void print_frame_local_vars (struct frame_info *, int, |
87 | struct ui_file *); | |
c906108c | 88 | |
d9fcf2fb JM |
89 | static int print_block_frame_labels (struct block *, int *, |
90 | struct ui_file *); | |
c906108c | 91 | |
d9fcf2fb JM |
92 | static int print_block_frame_locals (struct block *, |
93 | struct frame_info *, | |
94 | int, | |
95 | struct ui_file *); | |
c906108c | 96 | |
c5394b80 | 97 | static void print_frame (struct frame_info *fi, |
0faf0076 AC |
98 | int print_level, |
99 | enum print_what print_what, | |
100 | int print_args, | |
c5394b80 JM |
101 | struct symtab_and_line sal); |
102 | ||
a14ed312 | 103 | static void backtrace_command (char *, int); |
c906108c | 104 | |
a14ed312 | 105 | static void frame_info (char *, int); |
c906108c SS |
106 | |
107 | extern int addressprint; /* Print addresses, or stay symbolic only? */ | |
c906108c | 108 | |
c906108c SS |
109 | /* Zero means do things normally; we are interacting directly with the |
110 | user. One means print the full filename and linenumber when a | |
111 | frame is printed, and do so in a format emacs18/emacs19.22 can | |
112 | parse. Two means print similar annotations, but in many more | |
113 | cases and in a slightly different syntax. */ | |
114 | ||
115 | int annotation_level = 0; | |
c906108c | 116 | \f |
c5aa993b JM |
117 | |
118 | struct print_stack_frame_args | |
119 | { | |
120 | struct frame_info *fi; | |
0faf0076 AC |
121 | int print_level; |
122 | enum print_what print_what; | |
123 | int print_args; | |
c5aa993b | 124 | }; |
c906108c | 125 | |
c906108c SS |
126 | /* Show or print the frame arguments. |
127 | Pass the args the way catch_errors wants them. */ | |
128 | static int | |
fba45db2 | 129 | print_stack_frame_stub (void *args) |
c906108c | 130 | { |
c5aa993b | 131 | struct print_stack_frame_args *p = (struct print_stack_frame_args *) args; |
c906108c | 132 | |
0faf0076 | 133 | print_frame_info (p->fi, p->print_level, p->print_what, p->print_args); |
c906108c SS |
134 | return 0; |
135 | } | |
136 | ||
d762c46a AC |
137 | /* Show or print a stack frame FI briefly. The output is format |
138 | according to PRINT_LEVEL and PRINT_WHAT printing the frame's | |
139 | relative level, function name, argument list, and file name and | |
140 | line number. If the frame's PC is not at the beginning of the | |
141 | source line, the actual PC is printed at the beginning. */ | |
c906108c SS |
142 | |
143 | void | |
0faf0076 AC |
144 | print_stack_frame (struct frame_info *fi, int print_level, |
145 | enum print_what print_what) | |
c906108c SS |
146 | { |
147 | struct print_stack_frame_args args; | |
148 | ||
149 | args.fi = fi; | |
0faf0076 AC |
150 | args.print_level = print_level; |
151 | args.print_what = print_what; | |
152 | args.print_args = 1; | |
c906108c | 153 | |
c5aa993b | 154 | catch_errors (print_stack_frame_stub, (char *) &args, "", RETURN_MASK_ALL); |
7789c6f5 | 155 | } |
c906108c | 156 | |
c5aa993b JM |
157 | struct print_args_args |
158 | { | |
c906108c SS |
159 | struct symbol *func; |
160 | struct frame_info *fi; | |
d9fcf2fb | 161 | struct ui_file *stream; |
c906108c SS |
162 | }; |
163 | ||
4efb68b1 | 164 | static int print_args_stub (void *); |
c906108c | 165 | |
8d3b0994 AC |
166 | /* Print nameless args on STREAM. |
167 | FI is the frameinfo for this frame, START is the offset | |
168 | of the first nameless arg, and NUM is the number of nameless args to | |
169 | print. FIRST is nonzero if this is the first argument (not just | |
170 | the first nameless arg). */ | |
171 | ||
172 | static void | |
173 | print_frame_nameless_args (struct frame_info *fi, long start, int num, | |
174 | int first, struct ui_file *stream) | |
175 | { | |
176 | int i; | |
177 | CORE_ADDR argsaddr; | |
178 | long arg_value; | |
179 | ||
180 | for (i = 0; i < num; i++) | |
181 | { | |
182 | QUIT; | |
183 | argsaddr = get_frame_args_address (fi); | |
184 | if (!argsaddr) | |
185 | return; | |
186 | arg_value = read_memory_integer (argsaddr + start, sizeof (int)); | |
187 | if (!first) | |
188 | fprintf_filtered (stream, ", "); | |
189 | fprintf_filtered (stream, "%ld", arg_value); | |
190 | first = 0; | |
191 | start += sizeof (int); | |
192 | } | |
193 | } | |
194 | ||
195 | /* Print the arguments of a stack frame, given the function FUNC | |
196 | running in that frame (as a symbol), the info on the frame, | |
197 | and the number of args according to the stack frame (or -1 if unknown). */ | |
198 | ||
199 | /* References here and elsewhere to "number of args according to the | |
200 | stack frame" appear in all cases to refer to "number of ints of args | |
201 | according to the stack frame". At least for VAX, i386, isi. */ | |
202 | ||
203 | static void | |
204 | print_frame_args (struct symbol *func, struct frame_info *fi, int num, | |
205 | struct ui_file *stream) | |
206 | { | |
207 | struct block *b = NULL; | |
208 | int first = 1; | |
de4f826b | 209 | struct dict_iterator iter; |
52f0bd74 | 210 | struct symbol *sym; |
8d3b0994 AC |
211 | struct value *val; |
212 | /* Offset of next stack argument beyond the one we have seen that is | |
213 | at the highest offset. | |
214 | -1 if we haven't come to a stack argument yet. */ | |
215 | long highest_offset = -1; | |
216 | int arg_size; | |
217 | /* Number of ints of arguments that we have printed so far. */ | |
218 | int args_printed = 0; | |
219 | struct cleanup *old_chain, *list_chain; | |
220 | struct ui_stream *stb; | |
221 | ||
222 | stb = ui_out_stream_new (uiout); | |
223 | old_chain = make_cleanup_ui_out_stream_delete (stb); | |
224 | ||
225 | if (func) | |
226 | { | |
227 | b = SYMBOL_BLOCK_VALUE (func); | |
8d3b0994 | 228 | |
de4f826b | 229 | ALL_BLOCK_SYMBOLS (b, iter, sym) |
8d3b0994 AC |
230 | { |
231 | QUIT; | |
232 | ||
233 | /* Keep track of the highest stack argument offset seen, and | |
234 | skip over any kinds of symbols we don't care about. */ | |
235 | ||
236 | switch (SYMBOL_CLASS (sym)) | |
237 | { | |
238 | case LOC_ARG: | |
239 | case LOC_REF_ARG: | |
240 | { | |
241 | long current_offset = SYMBOL_VALUE (sym); | |
242 | arg_size = TYPE_LENGTH (SYMBOL_TYPE (sym)); | |
243 | ||
244 | /* Compute address of next argument by adding the size of | |
245 | this argument and rounding to an int boundary. */ | |
246 | current_offset = | |
247 | ((current_offset + arg_size + sizeof (int) - 1) | |
248 | & ~(sizeof (int) - 1)); | |
249 | ||
250 | /* If this is the highest offset seen yet, set highest_offset. */ | |
251 | if (highest_offset == -1 | |
252 | || (current_offset > highest_offset)) | |
253 | highest_offset = current_offset; | |
254 | ||
255 | /* Add the number of ints we're about to print to args_printed. */ | |
256 | args_printed += (arg_size + sizeof (int) - 1) / sizeof (int); | |
257 | } | |
258 | ||
259 | /* We care about types of symbols, but don't need to keep track of | |
260 | stack offsets in them. */ | |
261 | case LOC_REGPARM: | |
262 | case LOC_REGPARM_ADDR: | |
263 | case LOC_LOCAL_ARG: | |
264 | case LOC_BASEREG_ARG: | |
265 | case LOC_COMPUTED_ARG: | |
266 | break; | |
267 | ||
268 | /* Other types of symbols we just skip over. */ | |
269 | default: | |
270 | continue; | |
271 | } | |
272 | ||
273 | /* We have to look up the symbol because arguments can have | |
274 | two entries (one a parameter, one a local) and the one we | |
275 | want is the local, which lookup_symbol will find for us. | |
276 | This includes gcc1 (not gcc2) on the sparc when passing a | |
277 | small structure and gcc2 when the argument type is float | |
278 | and it is passed as a double and converted to float by | |
279 | the prologue (in the latter case the type of the LOC_ARG | |
280 | symbol is double and the type of the LOC_LOCAL symbol is | |
281 | float). */ | |
282 | /* But if the parameter name is null, don't try it. | |
283 | Null parameter names occur on the RS/6000, for traceback tables. | |
284 | FIXME, should we even print them? */ | |
285 | ||
286 | if (*DEPRECATED_SYMBOL_NAME (sym)) | |
287 | { | |
288 | struct symbol *nsym; | |
289 | nsym = lookup_symbol | |
290 | (DEPRECATED_SYMBOL_NAME (sym), | |
291 | b, VAR_DOMAIN, (int *) NULL, (struct symtab **) NULL); | |
292 | if (SYMBOL_CLASS (nsym) == LOC_REGISTER) | |
293 | { | |
294 | /* There is a LOC_ARG/LOC_REGISTER pair. This means that | |
295 | it was passed on the stack and loaded into a register, | |
296 | or passed in a register and stored in a stack slot. | |
297 | GDB 3.x used the LOC_ARG; GDB 4.0-4.11 used the LOC_REGISTER. | |
298 | ||
299 | Reasons for using the LOC_ARG: | |
300 | (1) because find_saved_registers may be slow for remote | |
301 | debugging, | |
302 | (2) because registers are often re-used and stack slots | |
303 | rarely (never?) are. Therefore using the stack slot is | |
304 | much less likely to print garbage. | |
305 | ||
306 | Reasons why we might want to use the LOC_REGISTER: | |
307 | (1) So that the backtrace prints the same value as | |
308 | "print foo". I see no compelling reason why this needs | |
309 | to be the case; having the backtrace print the value which | |
310 | was passed in, and "print foo" print the value as modified | |
311 | within the called function, makes perfect sense to me. | |
312 | ||
313 | Additional note: It might be nice if "info args" displayed | |
314 | both values. | |
315 | One more note: There is a case with sparc structure passing | |
316 | where we need to use the LOC_REGISTER, but this is dealt with | |
317 | by creating a single LOC_REGPARM in symbol reading. */ | |
318 | ||
319 | /* Leave sym (the LOC_ARG) alone. */ | |
320 | ; | |
321 | } | |
322 | else | |
323 | sym = nsym; | |
324 | } | |
325 | ||
326 | /* Print the current arg. */ | |
327 | if (!first) | |
328 | ui_out_text (uiout, ", "); | |
329 | ui_out_wrap_hint (uiout, " "); | |
330 | ||
331 | annotate_arg_begin (); | |
332 | ||
333 | list_chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); | |
334 | fprintf_symbol_filtered (stb->stream, SYMBOL_PRINT_NAME (sym), | |
335 | SYMBOL_LANGUAGE (sym), DMGL_PARAMS | DMGL_ANSI); | |
336 | ui_out_field_stream (uiout, "name", stb); | |
337 | annotate_arg_name_end (); | |
338 | ui_out_text (uiout, "="); | |
339 | ||
340 | /* Avoid value_print because it will deref ref parameters. We just | |
341 | want to print their addresses. Print ??? for args whose address | |
342 | we do not know. We pass 2 as "recurse" to val_print because our | |
343 | standard indentation here is 4 spaces, and val_print indents | |
344 | 2 for each recurse. */ | |
345 | val = read_var_value (sym, fi); | |
346 | ||
347 | annotate_arg_value (val == NULL ? NULL : VALUE_TYPE (val)); | |
348 | ||
349 | if (val) | |
350 | { | |
351 | val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), 0, | |
352 | VALUE_ADDRESS (val), | |
353 | stb->stream, 0, 0, 2, Val_no_prettyprint); | |
354 | ui_out_field_stream (uiout, "value", stb); | |
355 | } | |
356 | else | |
357 | ui_out_text (uiout, "???"); | |
358 | ||
359 | /* Invoke ui_out_tuple_end. */ | |
360 | do_cleanups (list_chain); | |
361 | ||
362 | annotate_arg_end (); | |
363 | ||
364 | first = 0; | |
365 | } | |
366 | } | |
367 | ||
368 | /* Don't print nameless args in situations where we don't know | |
369 | enough about the stack to find them. */ | |
370 | if (num != -1) | |
371 | { | |
372 | long start; | |
373 | ||
374 | if (highest_offset == -1) | |
375 | start = FRAME_ARGS_SKIP; | |
376 | else | |
377 | start = highest_offset; | |
378 | ||
379 | print_frame_nameless_args (fi, start, num - args_printed, | |
380 | first, stream); | |
381 | } | |
382 | do_cleanups (old_chain); | |
383 | } | |
384 | ||
c906108c SS |
385 | /* Pass the args the way catch_errors wants them. */ |
386 | ||
387 | static int | |
4efb68b1 | 388 | print_args_stub (void *args) |
c906108c SS |
389 | { |
390 | int numargs; | |
c5aa993b | 391 | struct print_args_args *p = (struct print_args_args *) args; |
c906108c | 392 | |
983a287a AC |
393 | if (FRAME_NUM_ARGS_P ()) |
394 | { | |
395 | numargs = FRAME_NUM_ARGS (p->fi); | |
396 | gdb_assert (numargs >= 0); | |
397 | } | |
398 | else | |
399 | numargs = -1; | |
ac9a91a7 | 400 | print_frame_args (p->func, p->fi, numargs, p->stream); |
c906108c SS |
401 | return 0; |
402 | } | |
403 | ||
404 | /* Print information about a frame for frame "fi" at level "level". | |
c5394b80 JM |
405 | Used in "where" output, also used to emit breakpoint or step |
406 | messages. | |
407 | LEVEL is the level of the frame, or -1 if it is the | |
408 | innermost frame but we don't want to print the level. | |
409 | The meaning of the SOURCE argument is: | |
410 | SRC_LINE: Print only source line | |
411 | LOCATION: Print only location | |
412 | LOC_AND_SRC: Print location and source line. */ | |
c906108c | 413 | |
7789c6f5 | 414 | void |
0faf0076 AC |
415 | print_frame_info (struct frame_info *fi, int print_level, |
416 | enum print_what print_what, int print_args) | |
c906108c SS |
417 | { |
418 | struct symtab_and_line sal; | |
c5394b80 JM |
419 | int source_print; |
420 | int location_print; | |
c906108c | 421 | |
075559bc AC |
422 | if (get_frame_type (fi) == DUMMY_FRAME |
423 | || get_frame_type (fi) == SIGTRAMP_FRAME) | |
c906108c | 424 | { |
075559bc AC |
425 | struct cleanup *uiout_cleanup |
426 | = make_cleanup_ui_out_tuple_begin_end (uiout, "frame"); | |
c906108c | 427 | |
0faf0076 AC |
428 | annotate_frame_begin (print_level ? frame_relative_level (fi) : 0, |
429 | get_frame_pc (fi)); | |
6a3fe0a4 | 430 | |
c906108c | 431 | /* Do this regardless of SOURCE because we don't have any source |
c5aa993b | 432 | to list for this frame. */ |
0faf0076 | 433 | if (print_level) |
52c6a6ac JJ |
434 | { |
435 | ui_out_text (uiout, "#"); | |
0faf0076 AC |
436 | ui_out_field_fmt_int (uiout, 2, ui_left, "level", |
437 | frame_relative_level (fi)); | |
52c6a6ac | 438 | } |
075559bc | 439 | if (ui_out_is_mi_like_p (uiout)) |
52c6a6ac | 440 | { |
075559bc | 441 | annotate_frame_address (); |
6fba5002 | 442 | ui_out_field_core_addr (uiout, "addr", get_frame_pc (fi)); |
075559bc | 443 | annotate_frame_address_end (); |
52c6a6ac | 444 | } |
6a3fe0a4 | 445 | |
075559bc AC |
446 | if (get_frame_type (fi) == DUMMY_FRAME) |
447 | { | |
448 | annotate_function_call (); | |
449 | ui_out_field_string (uiout, "func", "<function called from gdb>"); | |
450 | } | |
451 | else if (get_frame_type (fi) == SIGTRAMP_FRAME) | |
452 | { | |
453 | annotate_signal_handler_caller (); | |
454 | ui_out_field_string (uiout, "func", "<signal handler called>"); | |
455 | } | |
456 | ui_out_text (uiout, "\n"); | |
c906108c | 457 | annotate_frame_end (); |
075559bc AC |
458 | |
459 | do_cleanups (uiout_cleanup); | |
c906108c SS |
460 | return; |
461 | } | |
462 | ||
463 | /* If fi is not the innermost frame, that normally means that fi->pc | |
5a203e44 AC |
464 | points to *after* the call instruction, and we want to get the |
465 | line containing the call, never the next line. But if the next | |
466 | frame is a SIGTRAMP_FRAME or a DUMMY_FRAME, then the next frame | |
467 | was not entered as the result of a call, and we want to get the | |
468 | line containing fi->pc. */ | |
1058bca7 | 469 | find_frame_sal (fi, &sal); |
c906108c | 470 | |
0faf0076 AC |
471 | location_print = (print_what == LOCATION |
472 | || print_what == LOC_AND_ADDRESS | |
473 | || print_what == SRC_AND_LOC); | |
c5394b80 JM |
474 | |
475 | if (location_print || !sal.symtab) | |
0faf0076 | 476 | print_frame (fi, print_level, print_what, print_args, sal); |
c5394b80 | 477 | |
0faf0076 | 478 | source_print = (print_what == SRC_LINE || print_what == SRC_AND_LOC); |
0378c332 | 479 | |
66609862 | 480 | if (sal.symtab) |
0378c332 | 481 | set_current_source_symtab_and_line (&sal); |
c5394b80 JM |
482 | |
483 | if (source_print && sal.symtab) | |
484 | { | |
0378c332 | 485 | struct symtab_and_line cursal; |
c5394b80 | 486 | int done = 0; |
0faf0076 AC |
487 | int mid_statement = ((print_what == SRC_LINE) |
488 | && (get_frame_pc (fi) != sal.pc)); | |
c5394b80 JM |
489 | |
490 | if (annotation_level) | |
491 | done = identify_source_line (sal.symtab, sal.line, mid_statement, | |
bdd78e62 | 492 | get_frame_pc (fi)); |
c5394b80 JM |
493 | if (!done) |
494 | { | |
9a4105ab AC |
495 | if (deprecated_print_frame_info_listing_hook) |
496 | deprecated_print_frame_info_listing_hook (sal.symtab, sal.line, sal.line + 1, 0); | |
ba4bbdcb | 497 | else |
c5394b80 | 498 | { |
ba4bbdcb KS |
499 | /* We used to do this earlier, but that is clearly |
500 | wrong. This function is used by many different | |
501 | parts of gdb, including normal_stop in infrun.c, | |
502 | which uses this to print out the current PC | |
503 | when we stepi/nexti into the middle of a source | |
504 | line. Only the command line really wants this | |
505 | behavior. Other UIs probably would like the | |
506 | ability to decide for themselves if it is desired. */ | |
507 | if (addressprint && mid_statement) | |
508 | { | |
bdd78e62 | 509 | ui_out_field_core_addr (uiout, "addr", get_frame_pc (fi)); |
ba4bbdcb | 510 | ui_out_text (uiout, "\t"); |
ba4bbdcb KS |
511 | } |
512 | ||
513 | print_source_lines (sal.symtab, sal.line, sal.line + 1, 0); | |
c5394b80 | 514 | } |
c5394b80 | 515 | } |
53cb0458 FN |
516 | /* Make sure we have at least a default source file */ |
517 | set_default_source_symtab_and_line (); | |
518 | cursal = get_current_source_symtab_and_line (); | |
0378c332 FN |
519 | cursal.line = max (sal.line - get_lines_to_list () / 2, 1); |
520 | set_current_source_symtab_and_line (&cursal); | |
c5394b80 JM |
521 | } |
522 | ||
0faf0076 | 523 | if (print_what != LOCATION) |
bdd78e62 | 524 | set_default_breakpoint (1, get_frame_pc (fi), sal.symtab, sal.line); |
c5394b80 JM |
525 | |
526 | annotate_frame_end (); | |
527 | ||
528 | gdb_flush (gdb_stdout); | |
529 | } | |
530 | ||
531 | static void | |
532 | print_frame (struct frame_info *fi, | |
0faf0076 AC |
533 | int print_level, |
534 | enum print_what print_what, | |
535 | int print_args, | |
c5394b80 JM |
536 | struct symtab_and_line sal) |
537 | { | |
538 | struct symbol *func; | |
52f0bd74 | 539 | char *funname = 0; |
c5394b80 | 540 | enum language funlang = language_unknown; |
8b93c638 JM |
541 | struct ui_stream *stb; |
542 | struct cleanup *old_chain; | |
e6e0bfab | 543 | struct cleanup *list_chain; |
8b93c638 JM |
544 | |
545 | stb = ui_out_stream_new (uiout); | |
b02eeafb | 546 | old_chain = make_cleanup_ui_out_stream_delete (stb); |
c5394b80 | 547 | |
c4a09524 | 548 | func = find_pc_function (get_frame_address_in_block (fi)); |
c906108c SS |
549 | if (func) |
550 | { | |
551 | /* In certain pathological cases, the symtabs give the wrong | |
c5aa993b JM |
552 | function (when we are in the first function in a file which |
553 | is compiled without debugging symbols, the previous function | |
554 | is compiled with debugging symbols, and the "foo.o" symbol | |
555 | that is supposed to tell us where the file with debugging symbols | |
556 | ends has been truncated by ar because it is longer than 15 | |
557 | characters). This also occurs if the user uses asm() to create | |
558 | a function but not stabs for it (in a file compiled -g). | |
559 | ||
560 | So look in the minimal symbol tables as well, and if it comes | |
561 | up with a larger address for the function use that instead. | |
562 | I don't think this can ever cause any problems; there shouldn't | |
563 | be any minimal symbols in the middle of a function; if this is | |
564 | ever changed many parts of GDB will need to be changed (and we'll | |
565 | create a find_pc_minimal_function or some such). */ | |
c906108c | 566 | |
c4a09524 | 567 | struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (get_frame_address_in_block (fi)); |
c906108c | 568 | if (msymbol != NULL |
c5aa993b | 569 | && (SYMBOL_VALUE_ADDRESS (msymbol) |
c906108c SS |
570 | > BLOCK_START (SYMBOL_BLOCK_VALUE (func)))) |
571 | { | |
c906108c SS |
572 | /* We also don't know anything about the function besides |
573 | its address and name. */ | |
574 | func = 0; | |
22abf04a | 575 | funname = DEPRECATED_SYMBOL_NAME (msymbol); |
c906108c SS |
576 | funlang = SYMBOL_LANGUAGE (msymbol); |
577 | } | |
578 | else | |
579 | { | |
de5ad195 | 580 | /* I'd like to use SYMBOL_PRINT_NAME() here, to display the |
c5394b80 JM |
581 | demangled name that we already have stored in the symbol |
582 | table, but we stored a version with DMGL_PARAMS turned | |
583 | on, and here we don't want to display parameters. So call | |
584 | the demangler again, with DMGL_ANSI only. (Yes, I know | |
585 | that printf_symbol_filtered() will again try to demangle | |
586 | the name on the fly, but the issue is that if | |
587 | cplus_demangle() fails here, it'll fail there too. So we | |
588 | want to catch the failure ("demangled==NULL" case below) | |
589 | here, while we still have our hands on the function | |
590 | symbol.) */ | |
c5aa993b | 591 | char *demangled; |
22abf04a | 592 | funname = DEPRECATED_SYMBOL_NAME (func); |
c906108c | 593 | funlang = SYMBOL_LANGUAGE (func); |
c5aa993b JM |
594 | if (funlang == language_cplus) |
595 | { | |
596 | demangled = cplus_demangle (funname, DMGL_ANSI); | |
597 | if (demangled == NULL) | |
c5394b80 JM |
598 | /* If the demangler fails, try the demangled name from |
599 | the symbol table. This'll have parameters, but | |
600 | that's preferable to diplaying a mangled name. */ | |
de5ad195 | 601 | funname = SYMBOL_PRINT_NAME (func); |
c5aa993b | 602 | } |
c906108c SS |
603 | } |
604 | } | |
605 | else | |
606 | { | |
c4a09524 | 607 | struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (get_frame_address_in_block (fi)); |
c906108c SS |
608 | if (msymbol != NULL) |
609 | { | |
22abf04a | 610 | funname = DEPRECATED_SYMBOL_NAME (msymbol); |
c906108c SS |
611 | funlang = SYMBOL_LANGUAGE (msymbol); |
612 | } | |
613 | } | |
614 | ||
0faf0076 AC |
615 | annotate_frame_begin (print_level ? frame_relative_level (fi) : 0, |
616 | get_frame_pc (fi)); | |
c5394b80 | 617 | |
666547aa | 618 | list_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "frame"); |
c5394b80 | 619 | |
0faf0076 | 620 | if (print_level) |
8b93c638 | 621 | { |
8b93c638 | 622 | ui_out_text (uiout, "#"); |
0faf0076 AC |
623 | ui_out_field_fmt_int (uiout, 2, ui_left, "level", |
624 | frame_relative_level (fi)); | |
8b93c638 | 625 | } |
c5394b80 | 626 | if (addressprint) |
bdd78e62 AC |
627 | if (get_frame_pc (fi) != sal.pc |
628 | || !sal.symtab | |
0faf0076 | 629 | || print_what == LOC_AND_ADDRESS) |
c5394b80 JM |
630 | { |
631 | annotate_frame_address (); | |
bdd78e62 | 632 | ui_out_field_core_addr (uiout, "addr", get_frame_pc (fi)); |
8b93c638 JM |
633 | annotate_frame_address_end (); |
634 | ui_out_text (uiout, " in "); | |
c5394b80 JM |
635 | } |
636 | annotate_frame_function_name (); | |
8b93c638 JM |
637 | fprintf_symbol_filtered (stb->stream, funname ? funname : "??", funlang, |
638 | DMGL_ANSI); | |
639 | ui_out_field_stream (uiout, "func", stb); | |
640 | ui_out_wrap_hint (uiout, " "); | |
c5394b80 JM |
641 | annotate_frame_args (); |
642 | ||
8b93c638 | 643 | ui_out_text (uiout, " ("); |
0faf0076 | 644 | if (print_args) |
c906108c | 645 | { |
c5394b80 | 646 | struct print_args_args args; |
d493eb33 | 647 | struct cleanup *args_list_chain; |
c5394b80 JM |
648 | args.fi = fi; |
649 | args.func = func; | |
650 | args.stream = gdb_stdout; | |
68c81b54 | 651 | args_list_chain = make_cleanup_ui_out_list_begin_end (uiout, "args"); |
c5394b80 | 652 | catch_errors (print_args_stub, &args, "", RETURN_MASK_ALL); |
8b93c638 JM |
653 | /* FIXME: args must be a list. If one argument is a string it will |
654 | have " that will not be properly escaped. */ | |
666547aa | 655 | /* Invoke ui_out_tuple_end. */ |
d493eb33 | 656 | do_cleanups (args_list_chain); |
c5394b80 JM |
657 | QUIT; |
658 | } | |
8b93c638 | 659 | ui_out_text (uiout, ")"); |
c5394b80 JM |
660 | if (sal.symtab && sal.symtab->filename) |
661 | { | |
662 | annotate_frame_source_begin (); | |
8b93c638 JM |
663 | ui_out_wrap_hint (uiout, " "); |
664 | ui_out_text (uiout, " at "); | |
665 | annotate_frame_source_file (); | |
666 | ui_out_field_string (uiout, "file", sal.symtab->filename); | |
667 | annotate_frame_source_file_end (); | |
668 | ui_out_text (uiout, ":"); | |
669 | annotate_frame_source_line (); | |
670 | ui_out_field_int (uiout, "line", sal.line); | |
c5394b80 JM |
671 | annotate_frame_source_end (); |
672 | } | |
c906108c | 673 | |
c5394b80 JM |
674 | #ifdef PC_SOLIB |
675 | if (!funname || (!sal.symtab || !sal.symtab->filename)) | |
c906108c | 676 | { |
bdd78e62 | 677 | char *lib = PC_SOLIB (get_frame_pc (fi)); |
c5394b80 | 678 | if (lib) |
c906108c | 679 | { |
c5394b80 | 680 | annotate_frame_where (); |
8b93c638 JM |
681 | ui_out_wrap_hint (uiout, " "); |
682 | ui_out_text (uiout, " from "); | |
683 | ui_out_field_string (uiout, "from", lib); | |
c906108c | 684 | } |
c906108c | 685 | } |
c5394b80 | 686 | #endif /* PC_SOLIB */ |
e514a9d6 | 687 | |
666547aa | 688 | /* do_cleanups will call ui_out_tuple_end() for us. */ |
e6e0bfab | 689 | do_cleanups (list_chain); |
8b93c638 JM |
690 | ui_out_text (uiout, "\n"); |
691 | do_cleanups (old_chain); | |
c906108c SS |
692 | } |
693 | \f | |
c906108c SS |
694 | /* Show the frame info. If this is the tui, it will be shown in |
695 | the source display otherwise, nothing is done */ | |
696 | void | |
fba45db2 | 697 | show_stack_frame (struct frame_info *fi) |
c906108c | 698 | { |
c906108c | 699 | } |
c906108c | 700 | \f |
c5aa993b | 701 | |
c906108c | 702 | /* Read a frame specification in whatever the appropriate format is. |
1c8831c5 AC |
703 | Call error() if the specification is in any way invalid (i.e. this |
704 | function never returns NULL). When SEPECTED_P is non-NULL set it's | |
705 | target to indicate that the default selected frame was used. */ | |
c906108c | 706 | |
1c8831c5 AC |
707 | static struct frame_info * |
708 | parse_frame_specification_1 (const char *frame_exp, const char *message, | |
709 | int *selected_frame_p) | |
c906108c | 710 | { |
1c8831c5 AC |
711 | int numargs; |
712 | struct value *args[4]; | |
713 | CORE_ADDR addrs[ARRAY_SIZE (args)]; | |
c5aa993b | 714 | |
1c8831c5 AC |
715 | if (frame_exp == NULL) |
716 | numargs = 0; | |
717 | else | |
c906108c | 718 | { |
1c8831c5 | 719 | char *addr_string; |
c906108c SS |
720 | struct cleanup *tmp_cleanup; |
721 | ||
1c8831c5 AC |
722 | numargs = 0; |
723 | while (1) | |
c906108c | 724 | { |
1c8831c5 AC |
725 | char *addr_string; |
726 | struct cleanup *cleanup; | |
727 | const char *p; | |
728 | ||
729 | /* Skip leading white space, bail of EOL. */ | |
730 | while (isspace (*frame_exp)) | |
731 | frame_exp++; | |
732 | if (!*frame_exp) | |
733 | break; | |
c906108c | 734 | |
1c8831c5 AC |
735 | /* Parse the argument, extract it, save it. */ |
736 | for (p = frame_exp; | |
737 | *p && !isspace (*p); | |
738 | p++); | |
739 | addr_string = savestring (frame_exp, p - frame_exp); | |
c906108c | 740 | frame_exp = p; |
1c8831c5 AC |
741 | cleanup = make_cleanup (xfree, addr_string); |
742 | ||
743 | /* NOTE: Parse and evaluate expression, but do not use | |
744 | functions such as parse_and_eval_long or | |
745 | parse_and_eval_address to also extract the value. | |
746 | Instead value_as_long and value_as_address are used. | |
747 | This avoids problems with expressions that contain | |
748 | side-effects. */ | |
749 | if (numargs >= ARRAY_SIZE (args)) | |
750 | error ("Too many args in frame specification"); | |
751 | args[numargs++] = parse_and_eval (addr_string); | |
752 | ||
753 | do_cleanups (cleanup); | |
c906108c SS |
754 | } |
755 | } | |
756 | ||
1c8831c5 AC |
757 | /* If no args, default to the selected frame. */ |
758 | if (numargs == 0) | |
c906108c | 759 | { |
1c8831c5 AC |
760 | if (selected_frame_p != NULL) |
761 | (*selected_frame_p) = 1; | |
762 | return get_selected_frame (message); | |
763 | } | |
c906108c | 764 | |
1c8831c5 AC |
765 | /* None of the remaining use the selected frame. */ |
766 | if (selected_frame_p != NULL) | |
767 | (*selected_frame_p) = 1; | |
c906108c | 768 | |
1c8831c5 AC |
769 | /* Assume the single arg[0] is an integer, and try using that to |
770 | select a frame relative to current. */ | |
771 | if (numargs == 1) | |
772 | { | |
773 | struct frame_info *fid; | |
774 | int level = value_as_long (args[0]); | |
775 | fid = find_relative_frame (get_current_frame (), &level); | |
776 | if (level == 0) | |
777 | /* find_relative_frame was successful */ | |
778 | return fid; | |
779 | } | |
c906108c | 780 | |
1c8831c5 AC |
781 | /* Convert each value into a corresponding address. */ |
782 | { | |
783 | int i; | |
784 | for (i = 0; i < numargs; i++) | |
785 | addrs[i] = value_as_address (args[0]); | |
786 | } | |
c5aa993b | 787 | |
1c8831c5 AC |
788 | /* Assume that the single arg[0] is an address, use that to identify |
789 | a frame with a matching ID. Should this also accept stack/pc or | |
790 | stack/pc/special. */ | |
791 | if (numargs == 1) | |
792 | { | |
793 | struct frame_id id = frame_id_build_wild (addrs[0]); | |
794 | struct frame_info *fid; | |
795 | ||
796 | /* If SETUP_ARBITRARY_FRAME is defined, then frame | |
797 | specifications take at least 2 addresses. It is important to | |
798 | detect this case here so that "frame 100" does not give a | |
799 | confusing error message like "frame specification requires | |
800 | two addresses". This of course does not solve the "frame | |
801 | 100" problem for machines on which a frame specification can | |
802 | be made with one address. To solve that, we need a new | |
803 | syntax for a specifying a frame by address. I think the | |
804 | cleanest syntax is $frame(0x45) ($frame(0x23,0x45) for two | |
805 | args, etc.), but people might think that is too much typing, | |
806 | so I guess *0x23,0x45 would be a possible alternative (commas | |
807 | really should be used instead of spaces to delimit; using | |
808 | spaces normally works in an expression). */ | |
809 | #ifdef SETUP_ARBITRARY_FRAME | |
810 | error ("No frame %s", paddr_d (addrs[0])); | |
811 | #endif | |
812 | /* If (s)he specifies the frame with an address, he deserves | |
813 | what (s)he gets. Still, give the highest one that matches. | |
814 | (NOTE: cagney/2004-10-29: Why highest, or outer-most, I don't | |
815 | know). */ | |
816 | for (fid = get_current_frame (); | |
817 | fid != NULL; | |
818 | fid = get_prev_frame (fid)) | |
819 | { | |
820 | if (frame_id_eq (id, get_frame_id (fid))) | |
821 | { | |
822 | while (frame_id_eq (id, frame_unwind_id (fid))) | |
823 | fid = get_prev_frame (fid); | |
824 | return fid; | |
825 | } | |
826 | } | |
c906108c SS |
827 | } |
828 | ||
1c8831c5 AC |
829 | /* We couldn't identify the frame as an existing frame, but |
830 | perhaps we can create one with a single argument. */ | |
1c8831c5 AC |
831 | if (numargs == 1) |
832 | return create_new_frame (addrs[0], 0); | |
cd65c8f6 AC |
833 | else if (numargs == 2) |
834 | return create_new_frame (addrs[0], addrs[1]); | |
835 | else | |
836 | error ("Too many args in frame specification"); | |
1c8831c5 AC |
837 | } |
838 | ||
839 | struct frame_info * | |
840 | parse_frame_specification (char *frame_exp) | |
841 | { | |
842 | return parse_frame_specification_1 (frame_exp, NULL, NULL); | |
c906108c SS |
843 | } |
844 | ||
c906108c SS |
845 | /* Print verbosely the selected frame or the frame at address ADDR. |
846 | This means absolutely all information in the frame is printed. */ | |
847 | ||
848 | static void | |
fba45db2 | 849 | frame_info (char *addr_exp, int from_tty) |
c906108c SS |
850 | { |
851 | struct frame_info *fi; | |
852 | struct symtab_and_line sal; | |
853 | struct symbol *func; | |
854 | struct symtab *s; | |
855 | struct frame_info *calling_frame_info; | |
856 | int i, count, numregs; | |
857 | char *funname = 0; | |
858 | enum language funlang = language_unknown; | |
82de1e5b | 859 | const char *pc_regname; |
1c8831c5 | 860 | int selected_frame_p; |
c906108c | 861 | |
1c8831c5 | 862 | fi = parse_frame_specification_1 (addr_exp, "No stack.", &selected_frame_p); |
c906108c | 863 | |
82de1e5b AC |
864 | /* Name of the value returned by get_frame_pc(). Per comments, "pc" |
865 | is not a good name. */ | |
866 | if (PC_REGNUM >= 0) | |
867 | /* OK, this is weird. The PC_REGNUM hardware register's value can | |
868 | easily not match that of the internal value returned by | |
869 | get_frame_pc(). */ | |
870 | pc_regname = REGISTER_NAME (PC_REGNUM); | |
871 | else | |
872 | /* But then, this is weird to. Even without PC_REGNUM, an | |
873 | architectures will often have a hardware register called "pc", | |
874 | and that register's value, again, can easily not match | |
875 | get_frame_pc(). */ | |
876 | pc_regname = "pc"; | |
877 | ||
1058bca7 | 878 | find_frame_sal (fi, &sal); |
c906108c | 879 | func = get_frame_function (fi); |
1058bca7 AC |
880 | /* FIXME: cagney/2002-11-28: Why bother? Won't sal.symtab contain |
881 | the same value. */ | |
bdd78e62 | 882 | s = find_pc_symtab (get_frame_pc (fi)); |
c906108c SS |
883 | if (func) |
884 | { | |
de5ad195 | 885 | /* I'd like to use SYMBOL_PRINT_NAME() here, to display |
c906108c SS |
886 | * the demangled name that we already have stored in |
887 | * the symbol table, but we stored a version with | |
888 | * DMGL_PARAMS turned on, and here we don't want | |
889 | * to display parameters. So call the demangler again, | |
890 | * with DMGL_ANSI only. RT | |
891 | * (Yes, I know that printf_symbol_filtered() will | |
892 | * again try to demangle the name on the fly, but | |
893 | * the issue is that if cplus_demangle() fails here, | |
894 | * it'll fail there too. So we want to catch the failure | |
895 | * ("demangled==NULL" case below) here, while we still | |
896 | * have our hands on the function symbol.) | |
897 | */ | |
c5aa993b | 898 | char *demangled; |
22abf04a | 899 | funname = DEPRECATED_SYMBOL_NAME (func); |
c5aa993b JM |
900 | funlang = SYMBOL_LANGUAGE (func); |
901 | if (funlang == language_cplus) | |
902 | { | |
903 | demangled = cplus_demangle (funname, DMGL_ANSI); | |
904 | /* If the demangler fails, try the demangled name | |
905 | * from the symbol table. This'll have parameters, | |
906 | * but that's preferable to diplaying a mangled name. | |
907 | */ | |
908 | if (demangled == NULL) | |
de5ad195 | 909 | funname = SYMBOL_PRINT_NAME (func); |
c5aa993b | 910 | } |
c906108c SS |
911 | } |
912 | else | |
913 | { | |
aa1ee363 | 914 | struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (get_frame_pc (fi)); |
c906108c SS |
915 | if (msymbol != NULL) |
916 | { | |
22abf04a | 917 | funname = DEPRECATED_SYMBOL_NAME (msymbol); |
c906108c SS |
918 | funlang = SYMBOL_LANGUAGE (msymbol); |
919 | } | |
920 | } | |
921 | calling_frame_info = get_prev_frame (fi); | |
922 | ||
1c8831c5 | 923 | if (selected_frame_p && frame_relative_level (fi) >= 0) |
c906108c | 924 | { |
b31da25e | 925 | printf_filtered ("Stack level %d, frame at ", |
1c8831c5 | 926 | frame_relative_level (fi)); |
8b36eed8 | 927 | print_address_numeric (get_frame_base (fi), 1, gdb_stdout); |
c906108c SS |
928 | printf_filtered (":\n"); |
929 | } | |
930 | else | |
931 | { | |
932 | printf_filtered ("Stack frame at "); | |
8b36eed8 | 933 | print_address_numeric (get_frame_base (fi), 1, gdb_stdout); |
c906108c SS |
934 | printf_filtered (":\n"); |
935 | } | |
82de1e5b | 936 | printf_filtered (" %s = ", pc_regname); |
bdd78e62 | 937 | print_address_numeric (get_frame_pc (fi), 1, gdb_stdout); |
c906108c SS |
938 | |
939 | wrap_here (" "); | |
940 | if (funname) | |
941 | { | |
942 | printf_filtered (" in "); | |
943 | fprintf_symbol_filtered (gdb_stdout, funname, funlang, | |
944 | DMGL_ANSI | DMGL_PARAMS); | |
945 | } | |
946 | wrap_here (" "); | |
947 | if (sal.symtab) | |
948 | printf_filtered (" (%s:%d)", sal.symtab->filename, sal.line); | |
949 | puts_filtered ("; "); | |
950 | wrap_here (" "); | |
82de1e5b | 951 | printf_filtered ("saved %s ", pc_regname); |
f18c5a73 | 952 | print_address_numeric (frame_pc_unwind (fi), 1, gdb_stdout); |
c906108c SS |
953 | printf_filtered ("\n"); |
954 | ||
c906108c SS |
955 | if (calling_frame_info) |
956 | { | |
957 | printf_filtered (" called by frame at "); | |
8b36eed8 AC |
958 | print_address_numeric (get_frame_base (calling_frame_info), |
959 | 1, gdb_stdout); | |
c906108c | 960 | } |
75e3c1f9 | 961 | if (get_next_frame (fi) && calling_frame_info) |
c906108c SS |
962 | puts_filtered (","); |
963 | wrap_here (" "); | |
75e3c1f9 | 964 | if (get_next_frame (fi)) |
c906108c SS |
965 | { |
966 | printf_filtered (" caller of frame at "); | |
8b36eed8 AC |
967 | print_address_numeric (get_frame_base (get_next_frame (fi)), 1, |
968 | gdb_stdout); | |
c906108c | 969 | } |
75e3c1f9 | 970 | if (get_next_frame (fi) || calling_frame_info) |
c906108c SS |
971 | puts_filtered ("\n"); |
972 | if (s) | |
1058bca7 AC |
973 | printf_filtered (" source language %s.\n", |
974 | language_str (s->language)); | |
c906108c | 975 | |
c906108c SS |
976 | { |
977 | /* Address of the argument list for this frame, or 0. */ | |
da62e633 | 978 | CORE_ADDR arg_list = get_frame_args_address (fi); |
c906108c SS |
979 | /* Number of args for this frame, or -1 if unknown. */ |
980 | int numargs; | |
981 | ||
982 | if (arg_list == 0) | |
983 | printf_filtered (" Arglist at unknown address.\n"); | |
984 | else | |
985 | { | |
986 | printf_filtered (" Arglist at "); | |
987 | print_address_numeric (arg_list, 1, gdb_stdout); | |
988 | printf_filtered (","); | |
989 | ||
983a287a AC |
990 | if (!FRAME_NUM_ARGS_P ()) |
991 | { | |
992 | numargs = -1; | |
993 | puts_filtered (" args: "); | |
994 | } | |
c906108c | 995 | else |
983a287a AC |
996 | { |
997 | numargs = FRAME_NUM_ARGS (fi); | |
998 | gdb_assert (numargs >= 0); | |
999 | if (numargs == 0) | |
1000 | puts_filtered (" no args."); | |
1001 | else if (numargs == 1) | |
1002 | puts_filtered (" 1 arg: "); | |
1003 | else | |
1004 | printf_filtered (" %d args: ", numargs); | |
1005 | } | |
c906108c SS |
1006 | print_frame_args (func, fi, numargs, gdb_stdout); |
1007 | puts_filtered ("\n"); | |
1008 | } | |
1009 | } | |
1010 | { | |
1011 | /* Address of the local variables for this frame, or 0. */ | |
da62e633 | 1012 | CORE_ADDR arg_list = get_frame_locals_address (fi); |
c906108c SS |
1013 | |
1014 | if (arg_list == 0) | |
1015 | printf_filtered (" Locals at unknown address,"); | |
1016 | else | |
1017 | { | |
1018 | printf_filtered (" Locals at "); | |
1019 | print_address_numeric (arg_list, 1, gdb_stdout); | |
1020 | printf_filtered (","); | |
1021 | } | |
1022 | } | |
1023 | ||
4f460812 AC |
1024 | /* Print as much information as possible on the location of all the |
1025 | registers. */ | |
1026 | { | |
1027 | enum lval_type lval; | |
1028 | int optimized; | |
1029 | CORE_ADDR addr; | |
1030 | int realnum; | |
1031 | int count; | |
1032 | int i; | |
1033 | int need_nl = 1; | |
1034 | ||
1035 | /* The sp is special; what's displayed isn't the save address, but | |
1036 | the value of the previous frame's sp. This is a legacy thing, | |
1037 | at one stage the frame cached the previous frame's SP instead | |
1038 | of its address, hence it was easiest to just display the cached | |
1039 | value. */ | |
1040 | if (SP_REGNUM >= 0) | |
1041 | { | |
1042 | /* Find out the location of the saved stack pointer with out | |
1043 | actually evaluating it. */ | |
1044 | frame_register_unwind (fi, SP_REGNUM, &optimized, &lval, &addr, | |
1045 | &realnum, NULL); | |
1046 | if (!optimized && lval == not_lval) | |
c906108c | 1047 | { |
d9d9c31f | 1048 | char value[MAX_REGISTER_SIZE]; |
4f460812 AC |
1049 | CORE_ADDR sp; |
1050 | frame_register_unwind (fi, SP_REGNUM, &optimized, &lval, &addr, | |
1051 | &realnum, value); | |
af1342ab AC |
1052 | /* NOTE: cagney/2003-05-22: This is assuming that the |
1053 | stack pointer was packed as an unsigned integer. That | |
1054 | may or may not be valid. */ | |
3acba339 | 1055 | sp = extract_unsigned_integer (value, register_size (current_gdbarch, SP_REGNUM)); |
4f460812 AC |
1056 | printf_filtered (" Previous frame's sp is "); |
1057 | print_address_numeric (sp, 1, gdb_stdout); | |
1058 | printf_filtered ("\n"); | |
1059 | need_nl = 0; | |
c906108c | 1060 | } |
4f460812 AC |
1061 | else if (!optimized && lval == lval_memory) |
1062 | { | |
1063 | printf_filtered (" Previous frame's sp at "); | |
1064 | print_address_numeric (addr, 1, gdb_stdout); | |
1065 | printf_filtered ("\n"); | |
1066 | need_nl = 0; | |
1067 | } | |
1068 | else if (!optimized && lval == lval_register) | |
1069 | { | |
1070 | printf_filtered (" Previous frame's sp in %s\n", | |
1071 | REGISTER_NAME (realnum)); | |
1072 | need_nl = 0; | |
1073 | } | |
1074 | /* else keep quiet. */ | |
1075 | } | |
1076 | ||
1077 | count = 0; | |
1078 | numregs = NUM_REGS + NUM_PSEUDO_REGS; | |
1079 | for (i = 0; i < numregs; i++) | |
898c62f5 DJ |
1080 | if (i != SP_REGNUM |
1081 | && gdbarch_register_reggroup_p (current_gdbarch, i, all_reggroup)) | |
4f460812 AC |
1082 | { |
1083 | /* Find out the location of the saved register without | |
1084 | fetching the corresponding value. */ | |
1085 | frame_register_unwind (fi, i, &optimized, &lval, &addr, &realnum, | |
1086 | NULL); | |
1087 | /* For moment, only display registers that were saved on the | |
1088 | stack. */ | |
1089 | if (!optimized && lval == lval_memory) | |
1090 | { | |
1091 | if (count == 0) | |
1092 | puts_filtered (" Saved registers:\n "); | |
1093 | else | |
1094 | puts_filtered (","); | |
1095 | wrap_here (" "); | |
1096 | printf_filtered (" %s at ", REGISTER_NAME (i)); | |
1097 | print_address_numeric (addr, 1, gdb_stdout); | |
1098 | count++; | |
1099 | } | |
1100 | } | |
1101 | if (count || need_nl) | |
c906108c | 1102 | puts_filtered ("\n"); |
4f460812 | 1103 | } |
c906108c SS |
1104 | } |
1105 | ||
c906108c SS |
1106 | /* Print briefly all stack frames or just the innermost COUNT frames. */ |
1107 | ||
a14ed312 KB |
1108 | static void backtrace_command_1 (char *count_exp, int show_locals, |
1109 | int from_tty); | |
c906108c | 1110 | static void |
fba45db2 | 1111 | backtrace_command_1 (char *count_exp, int show_locals, int from_tty) |
c906108c SS |
1112 | { |
1113 | struct frame_info *fi; | |
52f0bd74 AC |
1114 | int count; |
1115 | int i; | |
1116 | struct frame_info *trailing; | |
1117 | int trailing_level; | |
c906108c SS |
1118 | |
1119 | if (!target_has_stack) | |
1120 | error ("No stack."); | |
1121 | ||
1122 | /* The following code must do two things. First, it must | |
1123 | set the variable TRAILING to the frame from which we should start | |
1124 | printing. Second, it must set the variable count to the number | |
1125 | of frames which we should print, or -1 if all of them. */ | |
1126 | trailing = get_current_frame (); | |
d082b2bb AC |
1127 | |
1128 | /* The target can be in a state where there is no valid frames | |
1129 | (e.g., just connected). */ | |
1130 | if (trailing == NULL) | |
1131 | error ("No stack."); | |
1132 | ||
c906108c SS |
1133 | trailing_level = 0; |
1134 | if (count_exp) | |
1135 | { | |
bb518678 | 1136 | count = parse_and_eval_long (count_exp); |
c906108c SS |
1137 | if (count < 0) |
1138 | { | |
1139 | struct frame_info *current; | |
1140 | ||
1141 | count = -count; | |
1142 | ||
1143 | current = trailing; | |
1144 | while (current && count--) | |
1145 | { | |
1146 | QUIT; | |
1147 | current = get_prev_frame (current); | |
1148 | } | |
c5aa993b | 1149 | |
c906108c SS |
1150 | /* Will stop when CURRENT reaches the top of the stack. TRAILING |
1151 | will be COUNT below it. */ | |
1152 | while (current) | |
1153 | { | |
1154 | QUIT; | |
1155 | trailing = get_prev_frame (trailing); | |
1156 | current = get_prev_frame (current); | |
1157 | trailing_level++; | |
1158 | } | |
c5aa993b | 1159 | |
c906108c SS |
1160 | count = -1; |
1161 | } | |
1162 | } | |
1163 | else | |
1164 | count = -1; | |
1165 | ||
1166 | if (info_verbose) | |
1167 | { | |
1168 | struct partial_symtab *ps; | |
c5aa993b | 1169 | |
c906108c | 1170 | /* Read in symbols for all of the frames. Need to do this in |
c5aa993b JM |
1171 | a separate pass so that "Reading in symbols for xxx" messages |
1172 | don't screw up the appearance of the backtrace. Also | |
1173 | if people have strong opinions against reading symbols for | |
1174 | backtrace this may have to be an option. */ | |
c906108c SS |
1175 | i = count; |
1176 | for (fi = trailing; | |
1177 | fi != NULL && i--; | |
1178 | fi = get_prev_frame (fi)) | |
1179 | { | |
1180 | QUIT; | |
c4a09524 | 1181 | ps = find_pc_psymtab (get_frame_address_in_block (fi)); |
c906108c SS |
1182 | if (ps) |
1183 | PSYMTAB_TO_SYMTAB (ps); /* Force syms to come in */ | |
1184 | } | |
1185 | } | |
1186 | ||
1187 | for (i = 0, fi = trailing; | |
1188 | fi && count--; | |
1189 | i++, fi = get_prev_frame (fi)) | |
1190 | { | |
1191 | QUIT; | |
1192 | ||
1193 | /* Don't use print_stack_frame; if an error() occurs it probably | |
c5aa993b JM |
1194 | means further attempts to backtrace would fail (on the other |
1195 | hand, perhaps the code does or could be fixed to make sure | |
1196 | the frame->prev field gets set to NULL in that case). */ | |
0faf0076 | 1197 | print_frame_info (fi, 1, LOCATION, 1); |
c906108c | 1198 | if (show_locals) |
c5aa993b | 1199 | print_frame_local_vars (fi, 1, gdb_stdout); |
c906108c SS |
1200 | } |
1201 | ||
1202 | /* If we've stopped before the end, mention that. */ | |
1203 | if (fi && from_tty) | |
1204 | printf_filtered ("(More stack frames follow...)\n"); | |
1205 | } | |
1206 | ||
1207 | static void | |
fba45db2 | 1208 | backtrace_command (char *arg, int from_tty) |
c906108c | 1209 | { |
c5aa993b JM |
1210 | struct cleanup *old_chain = (struct cleanup *) NULL; |
1211 | char **argv = (char **) NULL; | |
1212 | int argIndicatingFullTrace = (-1), totArgLen = 0, argc = 0; | |
1213 | char *argPtr = arg; | |
c906108c | 1214 | |
c5aa993b | 1215 | if (arg != (char *) NULL) |
c906108c SS |
1216 | { |
1217 | int i; | |
1218 | ||
c5aa993b | 1219 | argv = buildargv (arg); |
7a292a7a | 1220 | old_chain = make_cleanup_freeargv (argv); |
c906108c | 1221 | argc = 0; |
c5aa993b JM |
1222 | for (i = 0; (argv[i] != (char *) NULL); i++) |
1223 | { | |
745b8ca0 | 1224 | unsigned int j; |
c5aa993b JM |
1225 | |
1226 | for (j = 0; (j < strlen (argv[i])); j++) | |
1227 | argv[i][j] = tolower (argv[i][j]); | |
1228 | ||
1229 | if (argIndicatingFullTrace < 0 && subset_compare (argv[i], "full")) | |
1230 | argIndicatingFullTrace = argc; | |
1231 | else | |
1232 | { | |
1233 | argc++; | |
1234 | totArgLen += strlen (argv[i]); | |
1235 | } | |
1236 | } | |
c906108c SS |
1237 | totArgLen += argc; |
1238 | if (argIndicatingFullTrace >= 0) | |
c5aa993b JM |
1239 | { |
1240 | if (totArgLen > 0) | |
1241 | { | |
1242 | argPtr = (char *) xmalloc (totArgLen + 1); | |
1243 | if (!argPtr) | |
1244 | nomem (0); | |
1245 | else | |
1246 | { | |
1247 | memset (argPtr, 0, totArgLen + 1); | |
1248 | for (i = 0; (i < (argc + 1)); i++) | |
1249 | { | |
1250 | if (i != argIndicatingFullTrace) | |
1251 | { | |
1252 | strcat (argPtr, argv[i]); | |
1253 | strcat (argPtr, " "); | |
1254 | } | |
1255 | } | |
1256 | } | |
1257 | } | |
1258 | else | |
1259 | argPtr = (char *) NULL; | |
1260 | } | |
c906108c SS |
1261 | } |
1262 | ||
1263 | backtrace_command_1 (argPtr, (argIndicatingFullTrace >= 0), from_tty); | |
1264 | ||
1265 | if (argIndicatingFullTrace >= 0 && totArgLen > 0) | |
b8c9b27d | 1266 | xfree (argPtr); |
c906108c SS |
1267 | |
1268 | if (old_chain) | |
c5aa993b | 1269 | do_cleanups (old_chain); |
c906108c SS |
1270 | } |
1271 | ||
a14ed312 | 1272 | static void backtrace_full_command (char *arg, int from_tty); |
c906108c | 1273 | static void |
fba45db2 | 1274 | backtrace_full_command (char *arg, int from_tty) |
c906108c SS |
1275 | { |
1276 | backtrace_command_1 (arg, 1, from_tty); | |
1277 | } | |
c906108c | 1278 | \f |
c5aa993b | 1279 | |
c906108c SS |
1280 | /* Print the local variables of a block B active in FRAME. |
1281 | Return 1 if any variables were printed; 0 otherwise. */ | |
1282 | ||
1283 | static int | |
de4f826b DC |
1284 | print_block_frame_locals (struct block *b, struct frame_info *fi, |
1285 | int num_tabs, struct ui_file *stream) | |
c906108c | 1286 | { |
de4f826b DC |
1287 | struct dict_iterator iter; |
1288 | int j; | |
1289 | struct symbol *sym; | |
1290 | int values_printed = 0; | |
c906108c | 1291 | |
de4f826b | 1292 | ALL_BLOCK_SYMBOLS (b, iter, sym) |
c906108c | 1293 | { |
c906108c SS |
1294 | switch (SYMBOL_CLASS (sym)) |
1295 | { | |
1296 | case LOC_LOCAL: | |
1297 | case LOC_REGISTER: | |
1298 | case LOC_STATIC: | |
1299 | case LOC_BASEREG: | |
4c2df51b | 1300 | case LOC_COMPUTED: |
c906108c SS |
1301 | values_printed = 1; |
1302 | for (j = 0; j < num_tabs; j++) | |
c5aa993b | 1303 | fputs_filtered ("\t", stream); |
de5ad195 | 1304 | fputs_filtered (SYMBOL_PRINT_NAME (sym), stream); |
c906108c SS |
1305 | fputs_filtered (" = ", stream); |
1306 | print_variable_value (sym, fi, stream); | |
1307 | fprintf_filtered (stream, "\n"); | |
1308 | break; | |
1309 | ||
1310 | default: | |
1311 | /* Ignore symbols which are not locals. */ | |
1312 | break; | |
1313 | } | |
1314 | } | |
1315 | return values_printed; | |
1316 | } | |
1317 | ||
1318 | /* Same, but print labels. */ | |
1319 | ||
1320 | static int | |
fba45db2 | 1321 | print_block_frame_labels (struct block *b, int *have_default, |
aa1ee363 | 1322 | struct ui_file *stream) |
c906108c | 1323 | { |
de4f826b | 1324 | struct dict_iterator iter; |
52f0bd74 AC |
1325 | struct symbol *sym; |
1326 | int values_printed = 0; | |
c906108c | 1327 | |
de4f826b | 1328 | ALL_BLOCK_SYMBOLS (b, iter, sym) |
c906108c | 1329 | { |
acd8056e | 1330 | if (strcmp (DEPRECATED_SYMBOL_NAME (sym), "default") == 0) |
c906108c SS |
1331 | { |
1332 | if (*have_default) | |
1333 | continue; | |
1334 | *have_default = 1; | |
1335 | } | |
1336 | if (SYMBOL_CLASS (sym) == LOC_LABEL) | |
1337 | { | |
1338 | struct symtab_and_line sal; | |
1339 | sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0); | |
1340 | values_printed = 1; | |
de5ad195 | 1341 | fputs_filtered (SYMBOL_PRINT_NAME (sym), stream); |
c906108c SS |
1342 | if (addressprint) |
1343 | { | |
1344 | fprintf_filtered (stream, " "); | |
1345 | print_address_numeric (SYMBOL_VALUE_ADDRESS (sym), 1, stream); | |
1346 | } | |
1347 | fprintf_filtered (stream, " in file %s, line %d\n", | |
1348 | sal.symtab->filename, sal.line); | |
1349 | } | |
1350 | } | |
1351 | return values_printed; | |
1352 | } | |
1353 | ||
1354 | /* Print on STREAM all the local variables in frame FRAME, | |
1355 | including all the blocks active in that frame | |
1356 | at its current pc. | |
1357 | ||
1358 | Returns 1 if the job was done, | |
1359 | or 0 if nothing was printed because we have no info | |
1360 | on the function running in FRAME. */ | |
1361 | ||
1362 | static void | |
aa1ee363 AC |
1363 | print_frame_local_vars (struct frame_info *fi, int num_tabs, |
1364 | struct ui_file *stream) | |
c906108c | 1365 | { |
52f0bd74 AC |
1366 | struct block *block = get_frame_block (fi, 0); |
1367 | int values_printed = 0; | |
c906108c SS |
1368 | |
1369 | if (block == 0) | |
1370 | { | |
1371 | fprintf_filtered (stream, "No symbol table info available.\n"); | |
1372 | return; | |
1373 | } | |
c5aa993b | 1374 | |
c906108c SS |
1375 | while (block != 0) |
1376 | { | |
1377 | if (print_block_frame_locals (block, fi, num_tabs, stream)) | |
1378 | values_printed = 1; | |
1379 | /* After handling the function's top-level block, stop. | |
c5aa993b JM |
1380 | Don't continue to its superblock, the block of |
1381 | per-file symbols. */ | |
c906108c SS |
1382 | if (BLOCK_FUNCTION (block)) |
1383 | break; | |
1384 | block = BLOCK_SUPERBLOCK (block); | |
1385 | } | |
1386 | ||
1387 | if (!values_printed) | |
1388 | { | |
1389 | fprintf_filtered (stream, "No locals.\n"); | |
1390 | } | |
1391 | } | |
1392 | ||
1393 | /* Same, but print labels. */ | |
1394 | ||
1395 | static void | |
aa1ee363 AC |
1396 | print_frame_label_vars (struct frame_info *fi, int this_level_only, |
1397 | struct ui_file *stream) | |
c906108c | 1398 | { |
52f0bd74 AC |
1399 | struct blockvector *bl; |
1400 | struct block *block = get_frame_block (fi, 0); | |
1401 | int values_printed = 0; | |
c906108c SS |
1402 | int index, have_default = 0; |
1403 | char *blocks_printed; | |
bdd78e62 | 1404 | CORE_ADDR pc = get_frame_pc (fi); |
c906108c SS |
1405 | |
1406 | if (block == 0) | |
1407 | { | |
1408 | fprintf_filtered (stream, "No symbol table info available.\n"); | |
1409 | return; | |
1410 | } | |
1411 | ||
1412 | bl = blockvector_for_pc (BLOCK_END (block) - 4, &index); | |
1413 | blocks_printed = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char)); | |
1414 | memset (blocks_printed, 0, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char)); | |
1415 | ||
1416 | while (block != 0) | |
1417 | { | |
1418 | CORE_ADDR end = BLOCK_END (block) - 4; | |
1419 | int last_index; | |
1420 | ||
1421 | if (bl != blockvector_for_pc (end, &index)) | |
1422 | error ("blockvector blotch"); | |
1423 | if (BLOCKVECTOR_BLOCK (bl, index) != block) | |
1424 | error ("blockvector botch"); | |
1425 | last_index = BLOCKVECTOR_NBLOCKS (bl); | |
1426 | index += 1; | |
1427 | ||
1428 | /* Don't print out blocks that have gone by. */ | |
1429 | while (index < last_index | |
1430 | && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc) | |
1431 | index++; | |
1432 | ||
1433 | while (index < last_index | |
1434 | && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end) | |
1435 | { | |
1436 | if (blocks_printed[index] == 0) | |
1437 | { | |
1438 | if (print_block_frame_labels (BLOCKVECTOR_BLOCK (bl, index), &have_default, stream)) | |
1439 | values_printed = 1; | |
1440 | blocks_printed[index] = 1; | |
1441 | } | |
1442 | index++; | |
1443 | } | |
1444 | if (have_default) | |
1445 | return; | |
1446 | if (values_printed && this_level_only) | |
1447 | return; | |
1448 | ||
1449 | /* After handling the function's top-level block, stop. | |
c5aa993b JM |
1450 | Don't continue to its superblock, the block of |
1451 | per-file symbols. */ | |
c906108c SS |
1452 | if (BLOCK_FUNCTION (block)) |
1453 | break; | |
1454 | block = BLOCK_SUPERBLOCK (block); | |
1455 | } | |
1456 | ||
1457 | if (!values_printed && !this_level_only) | |
1458 | { | |
1459 | fprintf_filtered (stream, "No catches.\n"); | |
1460 | } | |
1461 | } | |
1462 | ||
c906108c | 1463 | void |
fba45db2 | 1464 | locals_info (char *args, int from_tty) |
c906108c | 1465 | { |
b04f3ab4 AC |
1466 | print_frame_local_vars (get_selected_frame ("No frame selected."), |
1467 | 0, gdb_stdout); | |
c906108c SS |
1468 | } |
1469 | ||
1470 | static void | |
fba45db2 | 1471 | catch_info (char *ignore, int from_tty) |
c906108c | 1472 | { |
c5aa993b | 1473 | struct symtab_and_line *sal; |
c906108c | 1474 | |
c5aa993b | 1475 | /* Check for target support for exception handling */ |
c906108c SS |
1476 | sal = target_enable_exception_callback (EX_EVENT_CATCH, 1); |
1477 | if (sal) | |
1478 | { | |
1479 | /* Currently not handling this */ | |
1480 | /* Ideally, here we should interact with the C++ runtime | |
1481 | system to find the list of active handlers, etc. */ | |
1482 | fprintf_filtered (gdb_stdout, "Info catch not supported with this target/compiler combination.\n"); | |
c906108c SS |
1483 | } |
1484 | else | |
1485 | { | |
c5aa993b | 1486 | /* Assume g++ compiled code -- old v 4.16 behaviour */ |
b04f3ab4 AC |
1487 | print_frame_label_vars (get_selected_frame ("No frame selected."), |
1488 | 0, gdb_stdout); | |
c906108c SS |
1489 | } |
1490 | } | |
1491 | ||
1492 | static void | |
aa1ee363 AC |
1493 | print_frame_arg_vars (struct frame_info *fi, |
1494 | struct ui_file *stream) | |
c906108c SS |
1495 | { |
1496 | struct symbol *func = get_frame_function (fi); | |
52f0bd74 | 1497 | struct block *b; |
de4f826b | 1498 | struct dict_iterator iter; |
52f0bd74 AC |
1499 | struct symbol *sym, *sym2; |
1500 | int values_printed = 0; | |
c906108c SS |
1501 | |
1502 | if (func == 0) | |
1503 | { | |
1504 | fprintf_filtered (stream, "No symbol table info available.\n"); | |
1505 | return; | |
1506 | } | |
1507 | ||
1508 | b = SYMBOL_BLOCK_VALUE (func); | |
de4f826b | 1509 | ALL_BLOCK_SYMBOLS (b, iter, sym) |
c906108c | 1510 | { |
c906108c SS |
1511 | switch (SYMBOL_CLASS (sym)) |
1512 | { | |
1513 | case LOC_ARG: | |
1514 | case LOC_LOCAL_ARG: | |
1515 | case LOC_REF_ARG: | |
1516 | case LOC_REGPARM: | |
1517 | case LOC_REGPARM_ADDR: | |
1518 | case LOC_BASEREG_ARG: | |
4c2df51b | 1519 | case LOC_COMPUTED_ARG: |
c906108c | 1520 | values_printed = 1; |
de5ad195 | 1521 | fputs_filtered (SYMBOL_PRINT_NAME (sym), stream); |
c906108c SS |
1522 | fputs_filtered (" = ", stream); |
1523 | ||
1524 | /* We have to look up the symbol because arguments can have | |
1525 | two entries (one a parameter, one a local) and the one we | |
1526 | want is the local, which lookup_symbol will find for us. | |
1527 | This includes gcc1 (not gcc2) on the sparc when passing a | |
1528 | small structure and gcc2 when the argument type is float | |
1529 | and it is passed as a double and converted to float by | |
1530 | the prologue (in the latter case the type of the LOC_ARG | |
1531 | symbol is double and the type of the LOC_LOCAL symbol is | |
1532 | float). There are also LOC_ARG/LOC_REGISTER pairs which | |
1533 | are not combined in symbol-reading. */ | |
1534 | ||
22abf04a | 1535 | sym2 = lookup_symbol (DEPRECATED_SYMBOL_NAME (sym), |
176620f1 | 1536 | b, VAR_DOMAIN, (int *) NULL, (struct symtab **) NULL); |
c906108c SS |
1537 | print_variable_value (sym2, fi, stream); |
1538 | fprintf_filtered (stream, "\n"); | |
1539 | break; | |
1540 | ||
1541 | default: | |
1542 | /* Don't worry about things which aren't arguments. */ | |
1543 | break; | |
1544 | } | |
1545 | } | |
c906108c SS |
1546 | if (!values_printed) |
1547 | { | |
1548 | fprintf_filtered (stream, "No arguments.\n"); | |
1549 | } | |
1550 | } | |
1551 | ||
1552 | void | |
fba45db2 | 1553 | args_info (char *ignore, int from_tty) |
c906108c | 1554 | { |
b04f3ab4 AC |
1555 | print_frame_arg_vars (get_selected_frame ("No frame selected."), |
1556 | gdb_stdout); | |
c906108c SS |
1557 | } |
1558 | ||
1559 | ||
1560 | static void | |
fba45db2 | 1561 | args_plus_locals_info (char *ignore, int from_tty) |
c906108c | 1562 | { |
c5aa993b JM |
1563 | args_info (ignore, from_tty); |
1564 | locals_info (ignore, from_tty); | |
c906108c | 1565 | } |
c906108c | 1566 | \f |
c5aa993b | 1567 | |
0f7d239c AC |
1568 | /* Select frame FI. Also print the stack frame and show the source if |
1569 | this is the tui version. */ | |
bedfa57b AC |
1570 | static void |
1571 | select_and_print_frame (struct frame_info *fi) | |
c906108c | 1572 | { |
0f7d239c | 1573 | select_frame (fi); |
c906108c | 1574 | if (fi) |
0faf0076 | 1575 | print_stack_frame (fi, 1, SRC_AND_LOC); |
c906108c | 1576 | } |
c906108c | 1577 | \f |
c906108c | 1578 | /* Return the symbol-block in which the selected frame is executing. |
ae767bfb JB |
1579 | Can return zero under various legitimate circumstances. |
1580 | ||
1581 | If ADDR_IN_BLOCK is non-zero, set *ADDR_IN_BLOCK to the relevant | |
1582 | code address within the block returned. We use this to decide | |
1583 | which macros are in scope. */ | |
c906108c SS |
1584 | |
1585 | struct block * | |
ae767bfb | 1586 | get_selected_block (CORE_ADDR *addr_in_block) |
c906108c SS |
1587 | { |
1588 | if (!target_has_stack) | |
1589 | return 0; | |
1590 | ||
8c69fc49 | 1591 | /* NOTE: cagney/2002-11-28: Why go to all this effort to not create |
b2fa5097 | 1592 | a selected/current frame? Perhaps this function is called, |
8c69fc49 AC |
1593 | indirectly, by WFI in "infrun.c" where avoiding the creation of |
1594 | an inner most frame is very important (it slows down single | |
1595 | step). I suspect, though that this was true in the deep dark | |
1596 | past but is no longer the case. A mindless look at all the | |
1597 | callers tends to support this theory. I think we should be able | |
1598 | to assume that there is always a selcted frame. */ | |
6e7f8b9c AC |
1599 | /* gdb_assert (deprecated_selected_frame != NULL); So, do you feel |
1600 | lucky? */ | |
1601 | if (!deprecated_selected_frame) | |
8c69fc49 AC |
1602 | { |
1603 | CORE_ADDR pc = read_pc (); | |
1604 | if (addr_in_block != NULL) | |
1605 | *addr_in_block = pc; | |
1606 | return block_for_pc (pc); | |
1607 | } | |
6e7f8b9c | 1608 | return get_frame_block (deprecated_selected_frame, addr_in_block); |
c906108c SS |
1609 | } |
1610 | ||
1611 | /* Find a frame a certain number of levels away from FRAME. | |
1612 | LEVEL_OFFSET_PTR points to an int containing the number of levels. | |
1613 | Positive means go to earlier frames (up); negative, the reverse. | |
1614 | The int that contains the number of levels is counted toward | |
1615 | zero as the frames for those levels are found. | |
1616 | If the top or bottom frame is reached, that frame is returned, | |
1617 | but the final value of *LEVEL_OFFSET_PTR is nonzero and indicates | |
1618 | how much farther the original request asked to go. */ | |
1619 | ||
1620 | struct frame_info * | |
aa1ee363 AC |
1621 | find_relative_frame (struct frame_info *frame, |
1622 | int *level_offset_ptr) | |
c906108c | 1623 | { |
52f0bd74 AC |
1624 | struct frame_info *prev; |
1625 | struct frame_info *frame1; | |
c906108c SS |
1626 | |
1627 | /* Going up is simple: just do get_prev_frame enough times | |
1628 | or until initial frame is reached. */ | |
1629 | while (*level_offset_ptr > 0) | |
1630 | { | |
1631 | prev = get_prev_frame (frame); | |
1632 | if (prev == 0) | |
1633 | break; | |
1634 | (*level_offset_ptr)--; | |
1635 | frame = prev; | |
1636 | } | |
1637 | /* Going down is just as simple. */ | |
1638 | if (*level_offset_ptr < 0) | |
1639 | { | |
c5aa993b JM |
1640 | while (*level_offset_ptr < 0) |
1641 | { | |
1642 | frame1 = get_next_frame (frame); | |
1643 | if (!frame1) | |
1644 | break; | |
1645 | frame = frame1; | |
1646 | (*level_offset_ptr)++; | |
1647 | } | |
c906108c SS |
1648 | } |
1649 | return frame; | |
1650 | } | |
1651 | ||
1652 | /* The "select_frame" command. With no arg, NOP. | |
1653 | With arg LEVEL_EXP, select the frame at level LEVEL if it is a | |
1654 | valid level. Otherwise, treat level_exp as an address expression | |
1655 | and select it. See parse_frame_specification for more info on proper | |
1656 | frame expressions. */ | |
1657 | ||
8b93c638 | 1658 | void |
fba45db2 | 1659 | select_frame_command (char *level_exp, int from_tty) |
c906108c | 1660 | { |
1c8831c5 | 1661 | select_frame (parse_frame_specification_1 (level_exp, "No stack.", NULL)); |
c906108c SS |
1662 | } |
1663 | ||
1664 | /* The "frame" command. With no arg, print selected frame briefly. | |
1665 | With arg, behaves like select_frame and then prints the selected | |
1666 | frame. */ | |
1667 | ||
1668 | void | |
fba45db2 | 1669 | frame_command (char *level_exp, int from_tty) |
c906108c SS |
1670 | { |
1671 | select_frame_command (level_exp, from_tty); | |
b04f3ab4 | 1672 | print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC); |
c906108c SS |
1673 | } |
1674 | ||
1675 | /* The XDB Compatibility command to print the current frame. */ | |
1676 | ||
7a292a7a | 1677 | static void |
fba45db2 | 1678 | current_frame_command (char *level_exp, int from_tty) |
c906108c | 1679 | { |
b04f3ab4 | 1680 | print_stack_frame (get_selected_frame ("No stack."), 1, SRC_AND_LOC); |
7a292a7a | 1681 | } |
c906108c SS |
1682 | |
1683 | /* Select the frame up one or COUNT stack levels | |
1684 | from the previously selected frame, and print it briefly. */ | |
1685 | ||
c906108c | 1686 | static void |
fba45db2 | 1687 | up_silently_base (char *count_exp) |
c906108c | 1688 | { |
52f0bd74 | 1689 | struct frame_info *fi; |
c906108c SS |
1690 | int count = 1, count1; |
1691 | if (count_exp) | |
bb518678 | 1692 | count = parse_and_eval_long (count_exp); |
c906108c | 1693 | count1 = count; |
c5aa993b | 1694 | |
b04f3ab4 | 1695 | fi = find_relative_frame (get_selected_frame ("No stack."), &count1); |
c906108c SS |
1696 | if (count1 != 0 && count_exp == 0) |
1697 | error ("Initial frame selected; you cannot go up."); | |
0f7d239c | 1698 | select_frame (fi); |
c906108c SS |
1699 | } |
1700 | ||
1701 | static void | |
fba45db2 | 1702 | up_silently_command (char *count_exp, int from_tty) |
c906108c | 1703 | { |
c5aa993b | 1704 | up_silently_base (count_exp); |
c906108c SS |
1705 | } |
1706 | ||
1707 | static void | |
fba45db2 | 1708 | up_command (char *count_exp, int from_tty) |
c906108c SS |
1709 | { |
1710 | up_silently_base (count_exp); | |
b04f3ab4 | 1711 | print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC); |
c906108c SS |
1712 | } |
1713 | ||
1714 | /* Select the frame down one or COUNT stack levels | |
1715 | from the previously selected frame, and print it briefly. */ | |
1716 | ||
c906108c | 1717 | static void |
fba45db2 | 1718 | down_silently_base (char *count_exp) |
c906108c | 1719 | { |
52f0bd74 | 1720 | struct frame_info *frame; |
c906108c SS |
1721 | int count = -1, count1; |
1722 | if (count_exp) | |
bb518678 | 1723 | count = -parse_and_eval_long (count_exp); |
c906108c | 1724 | count1 = count; |
c5aa993b | 1725 | |
b04f3ab4 | 1726 | frame = find_relative_frame (get_selected_frame ("No stack."), &count1); |
c906108c SS |
1727 | if (count1 != 0 && count_exp == 0) |
1728 | { | |
1729 | ||
1730 | /* We only do this if count_exp is not specified. That way "down" | |
c5aa993b JM |
1731 | means to really go down (and let me know if that is |
1732 | impossible), but "down 9999" can be used to mean go all the way | |
1733 | down without getting an error. */ | |
c906108c SS |
1734 | |
1735 | error ("Bottom (i.e., innermost) frame selected; you cannot go down."); | |
1736 | } | |
1737 | ||
0f7d239c | 1738 | select_frame (frame); |
c906108c SS |
1739 | } |
1740 | ||
c906108c | 1741 | static void |
fba45db2 | 1742 | down_silently_command (char *count_exp, int from_tty) |
c906108c SS |
1743 | { |
1744 | down_silently_base (count_exp); | |
c906108c SS |
1745 | } |
1746 | ||
1747 | static void | |
fba45db2 | 1748 | down_command (char *count_exp, int from_tty) |
c906108c SS |
1749 | { |
1750 | down_silently_base (count_exp); | |
b04f3ab4 | 1751 | print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC); |
c906108c SS |
1752 | } |
1753 | \f | |
8b93c638 | 1754 | void |
fba45db2 | 1755 | return_command (char *retval_exp, int from_tty) |
c906108c SS |
1756 | { |
1757 | struct symbol *thisfun; | |
3d6d86c6 | 1758 | struct value *return_value = NULL; |
fc70c2a0 | 1759 | const char *query_prefix = ""; |
c906108c | 1760 | |
b04f3ab4 | 1761 | thisfun = get_frame_function (get_selected_frame ("No selected frame.")); |
c906108c | 1762 | |
fc70c2a0 AC |
1763 | /* Compute the return value. If the computation triggers an error, |
1764 | let it bail. If the return type can't be handled, set | |
1765 | RETURN_VALUE to NULL, and QUERY_PREFIX to an informational | |
1766 | message. */ | |
c906108c SS |
1767 | if (retval_exp) |
1768 | { | |
1769 | struct type *return_type = NULL; | |
1770 | ||
fc70c2a0 AC |
1771 | /* Compute the return value. Should the computation fail, this |
1772 | call throws an error. */ | |
c906108c SS |
1773 | return_value = parse_and_eval (retval_exp); |
1774 | ||
fc70c2a0 AC |
1775 | /* Cast return value to the return type of the function. Should |
1776 | the cast fail, this call throws an error. */ | |
c906108c SS |
1777 | if (thisfun != NULL) |
1778 | return_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (thisfun)); | |
1779 | if (return_type == NULL) | |
1780 | return_type = builtin_type_int; | |
3e9a183c | 1781 | CHECK_TYPEDEF (return_type); |
c906108c SS |
1782 | return_value = value_cast (return_type, return_value); |
1783 | ||
fc70c2a0 AC |
1784 | /* Make sure the value is fully evaluated. It may live in the |
1785 | stack frame we're about to pop. */ | |
c906108c SS |
1786 | if (VALUE_LAZY (return_value)) |
1787 | value_fetch_lazy (return_value); | |
c906108c | 1788 | |
667e784f AC |
1789 | if (TYPE_CODE (return_type) == TYPE_CODE_VOID) |
1790 | /* If the return-type is "void", don't try to find the | |
1791 | return-value's location. However, do still evaluate the | |
1792 | return expression so that, even when the expression result | |
1793 | is discarded, side effects such as "return i++" still | |
1794 | occure. */ | |
1795 | return_value = NULL; | |
74055713 AC |
1796 | /* FIXME: cagney/2004-01-17: If the architecture implements both |
1797 | return_value and extract_returned_value_address, should allow | |
1798 | "return" to work - don't set return_value to NULL. */ | |
667e784f AC |
1799 | else if (!gdbarch_return_value_p (current_gdbarch) |
1800 | && (TYPE_CODE (return_type) == TYPE_CODE_STRUCT | |
1801 | || TYPE_CODE (return_type) == TYPE_CODE_UNION)) | |
c906108c | 1802 | { |
667e784f AC |
1803 | /* NOTE: cagney/2003-10-20: Compatibility hack for legacy |
1804 | code. Old architectures don't expect STORE_RETURN_VALUE | |
1805 | to be called with with a small struct that needs to be | |
1806 | stored in registers. Don't start doing it now. */ | |
1807 | query_prefix = "\ | |
1808 | A structure or union return type is not supported by this architecture.\n\ | |
1809 | If you continue, the return value that you specified will be ignored.\n"; | |
1810 | return_value = NULL; | |
c906108c | 1811 | } |
667e784f | 1812 | else if (using_struct_return (return_type, 0)) |
fc70c2a0 | 1813 | { |
667e784f AC |
1814 | query_prefix = "\ |
1815 | The location at which to store the function's return value is unknown.\n\ | |
1816 | If you continue, the return value that you specified will be ignored.\n"; | |
1817 | return_value = NULL; | |
fc70c2a0 | 1818 | } |
c906108c SS |
1819 | } |
1820 | ||
fc70c2a0 AC |
1821 | /* Does an interactive user really want to do this? Include |
1822 | information, such as how well GDB can handle the return value, in | |
1823 | the query message. */ | |
1824 | if (from_tty) | |
1825 | { | |
1826 | int confirmed; | |
1827 | if (thisfun == NULL) | |
1828 | confirmed = query ("%sMake selected stack frame return now? ", | |
1829 | query_prefix); | |
1830 | else | |
1831 | confirmed = query ("%sMake %s return now? ", query_prefix, | |
1832 | SYMBOL_PRINT_NAME (thisfun)); | |
1833 | if (!confirmed) | |
1834 | error ("Not confirmed"); | |
1835 | } | |
c906108c | 1836 | |
fc70c2a0 AC |
1837 | /* NOTE: cagney/2003-01-18: Is this silly? Rather than pop each |
1838 | frame in turn, should this code just go straight to the relevant | |
1839 | frame and pop that? */ | |
c906108c | 1840 | |
fc70c2a0 AC |
1841 | /* First discard all frames inner-to the selected frame (making the |
1842 | selected frame current). */ | |
1843 | { | |
b04f3ab4 | 1844 | struct frame_id selected_id = get_frame_id (get_selected_frame (NULL)); |
fc70c2a0 AC |
1845 | while (!frame_id_eq (selected_id, get_frame_id (get_current_frame ()))) |
1846 | { | |
1847 | if (frame_id_inner (selected_id, get_frame_id (get_current_frame ()))) | |
1848 | /* Caught in the safety net, oops! We've gone way past the | |
1849 | selected frame. */ | |
1850 | error ("Problem while popping stack frames (corrupt stack?)"); | |
1851 | frame_pop (get_current_frame ()); | |
1852 | } | |
1853 | } | |
c906108c | 1854 | |
fc70c2a0 AC |
1855 | /* Second discard the selected frame (which is now also the current |
1856 | frame). */ | |
dbe9fe58 | 1857 | frame_pop (get_current_frame ()); |
c906108c | 1858 | |
fc70c2a0 AC |
1859 | /* Store RETURN_VAUE in the just-returned register set. */ |
1860 | if (return_value != NULL) | |
1861 | { | |
1862 | struct type *return_type = VALUE_TYPE (return_value); | |
750eb019 AC |
1863 | gdb_assert (gdbarch_return_value (current_gdbarch, return_type, |
1864 | NULL, NULL, NULL) | |
1865 | == RETURN_VALUE_REGISTER_CONVENTION); | |
1866 | gdbarch_return_value (current_gdbarch, return_type, | |
1867 | current_regcache, NULL /*read*/, | |
1868 | VALUE_CONTENTS (return_value) /*write*/); | |
fc70c2a0 | 1869 | } |
1a2aab69 | 1870 | |
fc70c2a0 AC |
1871 | /* If we are at the end of a call dummy now, pop the dummy frame |
1872 | too. */ | |
e8bcf01f AC |
1873 | if (get_frame_type (get_current_frame ()) == DUMMY_FRAME) |
1874 | frame_pop (get_current_frame ()); | |
1a2aab69 | 1875 | |
c906108c | 1876 | /* If interactive, print the frame that is now current. */ |
c906108c SS |
1877 | if (from_tty) |
1878 | frame_command ("0", 1); | |
1879 | else | |
1880 | select_frame_command ("0", 0); | |
1881 | } | |
1882 | ||
1883 | /* Sets the scope to input function name, provided that the | |
1884 | function is within the current stack frame */ | |
1885 | ||
1886 | struct function_bounds | |
1887 | { | |
1888 | CORE_ADDR low, high; | |
1889 | }; | |
1890 | ||
a14ed312 | 1891 | static void func_command (char *arg, int from_tty); |
c906108c | 1892 | static void |
fba45db2 | 1893 | func_command (char *arg, int from_tty) |
c906108c SS |
1894 | { |
1895 | struct frame_info *fp; | |
1896 | int found = 0; | |
1897 | struct symtabs_and_lines sals; | |
1898 | int i; | |
1899 | int level = 1; | |
1900 | struct function_bounds *func_bounds = (struct function_bounds *) NULL; | |
1901 | ||
1902 | if (arg != (char *) NULL) | |
1903 | return; | |
1904 | ||
1905 | fp = parse_frame_specification ("0"); | |
1906 | sals = decode_line_spec (arg, 1); | |
1907 | func_bounds = (struct function_bounds *) xmalloc ( | |
1908 | sizeof (struct function_bounds) * sals.nelts); | |
1909 | for (i = 0; (i < sals.nelts && !found); i++) | |
1910 | { | |
1911 | if (sals.sals[i].pc == (CORE_ADDR) 0 || | |
1912 | find_pc_partial_function (sals.sals[i].pc, | |
1913 | (char **) NULL, | |
1914 | &func_bounds[i].low, | |
1915 | &func_bounds[i].high) == 0) | |
1916 | { | |
1917 | func_bounds[i].low = | |
1918 | func_bounds[i].high = (CORE_ADDR) NULL; | |
1919 | } | |
1920 | } | |
1921 | ||
1922 | do | |
1923 | { | |
1924 | for (i = 0; (i < sals.nelts && !found); i++) | |
bdd78e62 AC |
1925 | found = (get_frame_pc (fp) >= func_bounds[i].low && |
1926 | get_frame_pc (fp) < func_bounds[i].high); | |
c906108c SS |
1927 | if (!found) |
1928 | { | |
1929 | level = 1; | |
1930 | fp = find_relative_frame (fp, &level); | |
1931 | } | |
1932 | } | |
1933 | while (!found && level == 0); | |
1934 | ||
1935 | if (func_bounds) | |
b8c9b27d | 1936 | xfree (func_bounds); |
c906108c SS |
1937 | |
1938 | if (!found) | |
1939 | printf_filtered ("'%s' not within current stack frame.\n", arg); | |
6e7f8b9c | 1940 | else if (fp != deprecated_selected_frame) |
bedfa57b | 1941 | select_and_print_frame (fp); |
c906108c SS |
1942 | } |
1943 | ||
1944 | /* Gets the language of the current frame. */ | |
1945 | ||
1946 | enum language | |
fba45db2 | 1947 | get_frame_language (void) |
c906108c | 1948 | { |
52f0bd74 | 1949 | struct symtab *s; |
c906108c | 1950 | enum language flang; /* The language of the current frame */ |
c5aa993b | 1951 | |
6e7f8b9c | 1952 | if (deprecated_selected_frame) |
c906108c | 1953 | { |
7ae4c3a5 JB |
1954 | /* We determine the current frame language by looking up its |
1955 | associated symtab. To retrieve this symtab, we use the frame PC. | |
1956 | However we cannot use the frame pc as is, because it usually points | |
1957 | to the instruction following the "call", which is sometimes the first | |
1958 | instruction of another function. So we rely on | |
1959 | get_frame_address_in_block(), it provides us with a PC which is | |
1960 | guaranteed to be inside the frame's code block. */ | |
1961 | s = find_pc_symtab (get_frame_address_in_block (deprecated_selected_frame)); | |
c906108c SS |
1962 | if (s) |
1963 | flang = s->language; | |
1964 | else | |
1965 | flang = language_unknown; | |
1966 | } | |
1967 | else | |
1968 | flang = language_unknown; | |
1969 | ||
1970 | return flang; | |
1971 | } | |
1972 | \f | |
1973 | void | |
fba45db2 | 1974 | _initialize_stack (void) |
c906108c | 1975 | { |
c5aa993b | 1976 | #if 0 |
c906108c SS |
1977 | backtrace_limit = 30; |
1978 | #endif | |
1979 | ||
1980 | add_com ("return", class_stack, return_command, | |
1981 | "Make selected stack frame return to its caller.\n\ | |
1982 | Control remains in the debugger, but when you continue\n\ | |
1983 | execution will resume in the frame above the one now selected.\n\ | |
1984 | If an argument is given, it is an expression for the value to return."); | |
1985 | ||
1986 | add_com ("up", class_stack, up_command, | |
1987 | "Select and print stack frame that called this one.\n\ | |
1988 | An argument says how many frames up to go."); | |
1989 | add_com ("up-silently", class_support, up_silently_command, | |
1990 | "Same as the `up' command, but does not print anything.\n\ | |
1991 | This is useful in command scripts."); | |
1992 | ||
1993 | add_com ("down", class_stack, down_command, | |
1994 | "Select and print stack frame called by this one.\n\ | |
1995 | An argument says how many frames down to go."); | |
1996 | add_com_alias ("do", "down", class_stack, 1); | |
1997 | add_com_alias ("dow", "down", class_stack, 1); | |
1998 | add_com ("down-silently", class_support, down_silently_command, | |
1999 | "Same as the `down' command, but does not print anything.\n\ | |
2000 | This is useful in command scripts."); | |
2001 | ||
2002 | add_com ("frame", class_stack, frame_command, | |
2003 | "Select and print a stack frame.\n\ | |
2004 | With no argument, print the selected stack frame. (See also \"info frame\").\n\ | |
2005 | An argument specifies the frame to select.\n\ | |
2006 | It can be a stack frame number or the address of the frame.\n\ | |
2007 | With argument, nothing is printed if input is coming from\n\ | |
2008 | a command file or a user-defined command."); | |
2009 | ||
2010 | add_com_alias ("f", "frame", class_stack, 1); | |
2011 | ||
2012 | if (xdb_commands) | |
2013 | { | |
c5aa993b JM |
2014 | add_com ("L", class_stack, current_frame_command, |
2015 | "Print the current stack frame.\n"); | |
c906108c SS |
2016 | add_com_alias ("V", "frame", class_stack, 1); |
2017 | } | |
2018 | add_com ("select-frame", class_stack, select_frame_command, | |
2019 | "Select a stack frame without printing anything.\n\ | |
2020 | An argument specifies the frame to select.\n\ | |
2021 | It can be a stack frame number or the address of the frame.\n"); | |
2022 | ||
2023 | add_com ("backtrace", class_stack, backtrace_command, | |
2024 | "Print backtrace of all stack frames, or innermost COUNT frames.\n\ | |
2025 | With a negative argument, print outermost -COUNT frames.\n\ | |
2026 | Use of the 'full' qualifier also prints the values of the local variables.\n"); | |
2027 | add_com_alias ("bt", "backtrace", class_stack, 0); | |
2028 | if (xdb_commands) | |
2029 | { | |
2030 | add_com_alias ("t", "backtrace", class_stack, 0); | |
2031 | add_com ("T", class_stack, backtrace_full_command, | |
c5aa993b | 2032 | "Print backtrace of all stack frames, or innermost COUNT frames \n\ |
c906108c SS |
2033 | and the values of the local variables.\n\ |
2034 | With a negative argument, print outermost -COUNT frames.\n\ | |
2035 | Usage: T <count>\n"); | |
2036 | } | |
2037 | ||
2038 | add_com_alias ("where", "backtrace", class_alias, 0); | |
2039 | add_info ("stack", backtrace_command, | |
2040 | "Backtrace of the stack, or innermost COUNT frames."); | |
2041 | add_info_alias ("s", "stack", 1); | |
2042 | add_info ("frame", frame_info, | |
2043 | "All about selected stack frame, or frame at ADDR."); | |
2044 | add_info_alias ("f", "frame", 1); | |
2045 | add_info ("locals", locals_info, | |
2046 | "Local variables of current stack frame."); | |
2047 | add_info ("args", args_info, | |
2048 | "Argument variables of current stack frame."); | |
2049 | if (xdb_commands) | |
c5aa993b JM |
2050 | add_com ("l", class_info, args_plus_locals_info, |
2051 | "Argument and local variables of current stack frame."); | |
c906108c SS |
2052 | |
2053 | if (dbx_commands) | |
c5aa993b JM |
2054 | add_com ("func", class_stack, func_command, |
2055 | "Select the stack frame that contains <func>.\nUsage: func <name>\n"); | |
c906108c SS |
2056 | |
2057 | add_info ("catch", catch_info, | |
2058 | "Exceptions that can be caught in the current stack frame."); | |
2059 | ||
2060 | #if 0 | |
c5aa993b JM |
2061 | add_cmd ("backtrace-limit", class_stack, set_backtrace_limit_command, |
2062 | "Specify maximum number of frames for \"backtrace\" to print by default.", | |
c906108c SS |
2063 | &setlist); |
2064 | add_info ("backtrace-limit", backtrace_limit_info, | |
c5aa993b | 2065 | "The maximum number of frames for \"backtrace\" to print by default."); |
c906108c SS |
2066 | #endif |
2067 | } |