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