1 /* Print and select stack frames for GDB, the GNU debugger.
3 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
4 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
7 This file is part of GDB.
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.
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.
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. */
26 #include "gdb_string.h"
30 #include "expression.h"
37 #include "breakpoint.h"
44 /* Prototypes for exported functions. */
46 void args_info (char *, int);
48 void locals_info (char *, int);
50 void (*selected_frame_level_changed_hook
) (int);
52 void _initialize_stack (void);
54 void return_command (char *, int);
56 /* Prototypes for local functions. */
58 static void down_command (char *, int);
60 static void down_silently_base (char *);
62 static void down_silently_command (char *, int);
64 static void up_command (char *, int);
66 static void up_silently_base (char *);
68 static void up_silently_command (char *, int);
70 void frame_command (char *, int);
72 static void current_frame_command (char *, int);
74 static void select_frame_command (char *, int);
76 static void print_frame_arg_vars (struct frame_info
*, struct ui_file
*);
78 static void catch_info (char *, int);
80 static void args_plus_locals_info (char *, int);
82 static void print_frame_label_vars (struct frame_info
*, int,
85 static void print_frame_local_vars (struct frame_info
*, int,
88 static int print_block_frame_labels (struct block
*, int *,
91 static int print_block_frame_locals (struct block
*,
96 static void print_frame (struct frame_info
*fi
,
100 struct symtab_and_line sal
);
102 static void backtrace_command (char *, int);
104 struct frame_info
*parse_frame_specification (char *);
106 static void frame_info (char *, int);
108 extern int addressprint
; /* Print addresses, or stay symbolic only? */
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. */
116 int annotation_level
= 0;
119 struct print_stack_frame_args
121 struct frame_info
*fi
;
127 /* Show or print the frame arguments.
128 Pass the args the way catch_errors wants them. */
129 static int print_stack_frame_stub (void *args
);
131 print_stack_frame_stub (void *args
)
133 struct print_stack_frame_args
*p
= (struct print_stack_frame_args
*) args
;
135 print_frame_info (p
->fi
, p
->level
, p
->source
, p
->args
);
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.
146 If SOURCE is 1, print the source line as well.
147 If SOURCE is -1, print ONLY the source line. */
150 print_stack_frame (struct frame_info
*fi
, int level
, int source
)
152 struct print_stack_frame_args args
;
156 args
.source
= source
;
159 catch_errors (print_stack_frame_stub
, (char *) &args
, "", RETURN_MASK_ALL
);
162 struct print_args_args
165 struct frame_info
*fi
;
166 struct ui_file
*stream
;
169 static int print_args_stub (void *);
171 /* Pass the args the way catch_errors wants them. */
174 print_args_stub (void *args
)
177 struct print_args_args
*p
= (struct print_args_args
*) args
;
179 numargs
= FRAME_NUM_ARGS (p
->fi
);
180 print_frame_args (p
->func
, p
->fi
, numargs
, p
->stream
);
184 /* Print information about a frame for frame "fi" at level "level".
185 Used in "where" output, also used to emit breakpoint or step
187 LEVEL is the level of the frame, or -1 if it is the
188 innermost frame but we don't want to print the level.
189 The meaning of the SOURCE argument is:
190 SRC_LINE: Print only source line
191 LOCATION: Print only location
192 LOC_AND_SRC: Print location and source line. */
195 print_frame_info (struct frame_info
*fi
, int level
, int source
, int args
)
197 struct symtab_and_line sal
;
201 if (get_frame_type (fi
) == DUMMY_FRAME
202 || get_frame_type (fi
) == SIGTRAMP_FRAME
)
204 struct cleanup
*uiout_cleanup
205 = make_cleanup_ui_out_tuple_begin_end (uiout
, "frame");
207 annotate_frame_begin (level
== -1 ? 0 : level
, get_frame_pc (fi
));
209 /* Do this regardless of SOURCE because we don't have any source
210 to list for this frame. */
213 ui_out_text (uiout
, "#");
214 ui_out_field_fmt_int (uiout
, 2, ui_left
, "level", level
);
216 if (ui_out_is_mi_like_p (uiout
))
218 annotate_frame_address ();
219 ui_out_field_core_addr (uiout
, "addr", fi
->pc
);
220 annotate_frame_address_end ();
223 if (get_frame_type (fi
) == DUMMY_FRAME
)
225 annotate_function_call ();
226 ui_out_field_string (uiout
, "func", "<function called from gdb>");
228 else if (get_frame_type (fi
) == SIGTRAMP_FRAME
)
230 annotate_signal_handler_caller ();
231 ui_out_field_string (uiout
, "func", "<signal handler called>");
233 ui_out_text (uiout
, "\n");
234 annotate_frame_end ();
236 do_cleanups (uiout_cleanup
);
240 /* If fi is not the innermost frame, that normally means that fi->pc
241 points to *after* the call instruction, and we want to get the
242 line containing the call, never the next line. But if the next
243 frame is a SIGTRAMP_FRAME or a DUMMY_FRAME, then the next frame
244 was not entered as the result of a call, and we want to get the
245 line containing fi->pc. */
246 find_frame_sal (fi
, &sal
);
248 location_print
= (source
== LOCATION
249 || source
== LOC_AND_ADDRESS
250 || source
== SRC_AND_LOC
);
252 if (location_print
|| !sal
.symtab
)
253 print_frame (fi
, level
, source
, args
, sal
);
255 source_print
= (source
== SRC_LINE
|| source
== SRC_AND_LOC
);
258 set_current_source_symtab_and_line (&sal
);
260 if (source_print
&& sal
.symtab
)
262 struct symtab_and_line cursal
;
264 int mid_statement
= (source
== SRC_LINE
) && (get_frame_pc (fi
) != sal
.pc
);
266 if (annotation_level
)
267 done
= identify_source_line (sal
.symtab
, sal
.line
, mid_statement
,
271 if (print_frame_info_listing_hook
)
272 print_frame_info_listing_hook (sal
.symtab
, sal
.line
, sal
.line
+ 1, 0);
275 /* We used to do this earlier, but that is clearly
276 wrong. This function is used by many different
277 parts of gdb, including normal_stop in infrun.c,
278 which uses this to print out the current PC
279 when we stepi/nexti into the middle of a source
280 line. Only the command line really wants this
281 behavior. Other UIs probably would like the
282 ability to decide for themselves if it is desired. */
283 if (addressprint
&& mid_statement
)
285 ui_out_field_core_addr (uiout
, "addr", get_frame_pc (fi
));
286 ui_out_text (uiout
, "\t");
289 print_source_lines (sal
.symtab
, sal
.line
, sal
.line
+ 1, 0);
292 /* Make sure we have at least a default source file */
293 set_default_source_symtab_and_line ();
294 cursal
= get_current_source_symtab_and_line ();
295 cursal
.line
= max (sal
.line
- get_lines_to_list () / 2, 1);
296 set_current_source_symtab_and_line (&cursal
);
300 set_default_breakpoint (1, get_frame_pc (fi
), sal
.symtab
, sal
.line
);
302 annotate_frame_end ();
304 gdb_flush (gdb_stdout
);
308 print_frame (struct frame_info
*fi
,
312 struct symtab_and_line sal
)
315 register char *funname
= 0;
316 enum language funlang
= language_unknown
;
317 struct ui_stream
*stb
;
318 struct cleanup
*old_chain
;
319 struct cleanup
*list_chain
;
321 stb
= ui_out_stream_new (uiout
);
322 old_chain
= make_cleanup_ui_out_stream_delete (stb
);
324 func
= find_pc_function (frame_address_in_block (fi
));
327 /* In certain pathological cases, the symtabs give the wrong
328 function (when we are in the first function in a file which
329 is compiled without debugging symbols, the previous function
330 is compiled with debugging symbols, and the "foo.o" symbol
331 that is supposed to tell us where the file with debugging symbols
332 ends has been truncated by ar because it is longer than 15
333 characters). This also occurs if the user uses asm() to create
334 a function but not stabs for it (in a file compiled -g).
336 So look in the minimal symbol tables as well, and if it comes
337 up with a larger address for the function use that instead.
338 I don't think this can ever cause any problems; there shouldn't
339 be any minimal symbols in the middle of a function; if this is
340 ever changed many parts of GDB will need to be changed (and we'll
341 create a find_pc_minimal_function or some such). */
343 struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (frame_address_in_block (fi
));
345 && (SYMBOL_VALUE_ADDRESS (msymbol
)
346 > BLOCK_START (SYMBOL_BLOCK_VALUE (func
))))
349 /* There is no particular reason to think the line number
350 information is wrong. Someone might have just put in
351 a label with asm() but left the line numbers alone. */
352 /* In this case we have no way of knowing the source file
353 and line number, so don't print them. */
356 /* We also don't know anything about the function besides
357 its address and name. */
359 funname
= DEPRECATED_SYMBOL_NAME (msymbol
);
360 funlang
= SYMBOL_LANGUAGE (msymbol
);
364 /* I'd like to use SYMBOL_PRINT_NAME() here, to display the
365 demangled name that we already have stored in the symbol
366 table, but we stored a version with DMGL_PARAMS turned
367 on, and here we don't want to display parameters. So call
368 the demangler again, with DMGL_ANSI only. (Yes, I know
369 that printf_symbol_filtered() will again try to demangle
370 the name on the fly, but the issue is that if
371 cplus_demangle() fails here, it'll fail there too. So we
372 want to catch the failure ("demangled==NULL" case below)
373 here, while we still have our hands on the function
376 funname
= DEPRECATED_SYMBOL_NAME (func
);
377 funlang
= SYMBOL_LANGUAGE (func
);
378 if (funlang
== language_cplus
)
380 demangled
= cplus_demangle (funname
, DMGL_ANSI
);
381 if (demangled
== NULL
)
382 /* If the demangler fails, try the demangled name from
383 the symbol table. This'll have parameters, but
384 that's preferable to diplaying a mangled name. */
385 funname
= SYMBOL_PRINT_NAME (func
);
391 struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (frame_address_in_block (fi
));
394 funname
= DEPRECATED_SYMBOL_NAME (msymbol
);
395 funlang
= SYMBOL_LANGUAGE (msymbol
);
399 annotate_frame_begin (level
== -1 ? 0 : level
, get_frame_pc (fi
));
401 list_chain
= make_cleanup_ui_out_tuple_begin_end (uiout
, "frame");
405 ui_out_text (uiout
, "#");
406 ui_out_field_fmt_int (uiout
, 2, ui_left
, "level", level
);
409 if (get_frame_pc (fi
) != sal
.pc
411 || source
== LOC_AND_ADDRESS
)
413 annotate_frame_address ();
414 ui_out_field_core_addr (uiout
, "addr", get_frame_pc (fi
));
415 annotate_frame_address_end ();
416 ui_out_text (uiout
, " in ");
418 annotate_frame_function_name ();
419 fprintf_symbol_filtered (stb
->stream
, funname
? funname
: "??", funlang
,
421 ui_out_field_stream (uiout
, "func", stb
);
422 ui_out_wrap_hint (uiout
, " ");
423 annotate_frame_args ();
425 ui_out_text (uiout
, " (");
428 struct print_args_args args
;
429 struct cleanup
*args_list_chain
;
432 args
.stream
= gdb_stdout
;
433 args_list_chain
= make_cleanup_ui_out_list_begin_end (uiout
, "args");
434 catch_errors (print_args_stub
, &args
, "", RETURN_MASK_ALL
);
435 /* FIXME: args must be a list. If one argument is a string it will
436 have " that will not be properly escaped. */
437 /* Invoke ui_out_tuple_end. */
438 do_cleanups (args_list_chain
);
441 ui_out_text (uiout
, ")");
442 if (sal
.symtab
&& sal
.symtab
->filename
)
444 annotate_frame_source_begin ();
445 ui_out_wrap_hint (uiout
, " ");
446 ui_out_text (uiout
, " at ");
447 annotate_frame_source_file ();
448 ui_out_field_string (uiout
, "file", sal
.symtab
->filename
);
449 annotate_frame_source_file_end ();
450 ui_out_text (uiout
, ":");
451 annotate_frame_source_line ();
452 ui_out_field_int (uiout
, "line", sal
.line
);
453 annotate_frame_source_end ();
457 if (!funname
|| (!sal
.symtab
|| !sal
.symtab
->filename
))
459 char *lib
= PC_SOLIB (get_frame_pc (fi
));
462 annotate_frame_where ();
463 ui_out_wrap_hint (uiout
, " ");
464 ui_out_text (uiout
, " from ");
465 ui_out_field_string (uiout
, "from", lib
);
468 #endif /* PC_SOLIB */
470 /* do_cleanups will call ui_out_tuple_end() for us. */
471 do_cleanups (list_chain
);
472 ui_out_text (uiout
, "\n");
473 do_cleanups (old_chain
);
476 /* Show the frame info. If this is the tui, it will be shown in
477 the source display otherwise, nothing is done */
479 show_stack_frame (struct frame_info
*fi
)
484 /* Read a frame specification in whatever the appropriate format is.
485 Call error() if the specification is in any way invalid (i.e.
486 this function never returns NULL). */
489 parse_frame_specification (char *frame_exp
)
493 CORE_ADDR args
[MAXARGS
];
498 char *addr_string
, *p
;
499 struct cleanup
*tmp_cleanup
;
501 while (*frame_exp
== ' ')
506 if (numargs
> MAXARGS
)
507 error ("Too many args in frame specification");
508 /* Parse an argument. */
509 for (p
= frame_exp
; *p
&& *p
!= ' '; p
++)
511 addr_string
= savestring (frame_exp
, p
- frame_exp
);
516 tmp_cleanup
= make_cleanup (xfree
, addr_string
);
518 /* NOTE: we call parse_and_eval and then both
519 value_as_long and value_as_address rather than calling
520 parse_and_eval_long and parse_and_eval_address because
521 of the issue of potential side effects from evaluating
523 vp
= parse_and_eval (addr_string
);
525 level
= value_as_long (vp
);
527 args
[numargs
++] = value_as_address (vp
);
528 do_cleanups (tmp_cleanup
);
531 /* Skip spaces, move to possible next arg. */
541 if (deprecated_selected_frame
== NULL
)
542 error ("No selected frame.");
543 return deprecated_selected_frame
;
547 struct frame_info
*fid
=
548 find_relative_frame (get_current_frame (), &level
);
549 struct frame_info
*tfid
;
552 /* find_relative_frame was successful */
555 /* If SETUP_ARBITRARY_FRAME is defined, then frame specifications
556 take at least 2 addresses. It is important to detect this case
557 here so that "frame 100" does not give a confusing error message
558 like "frame specification requires two addresses". This of course
559 does not solve the "frame 100" problem for machines on which
560 a frame specification can be made with one address. To solve
561 that, we need a new syntax for a specifying a frame by address.
562 I think the cleanest syntax is $frame(0x45) ($frame(0x23,0x45) for
563 two args, etc.), but people might think that is too much typing,
564 so I guess *0x23,0x45 would be a possible alternative (commas
565 really should be used instead of spaces to delimit; using spaces
566 normally works in an expression). */
567 #ifdef SETUP_ARBITRARY_FRAME
568 error ("No frame %s", paddr_d (args
[0]));
571 /* If (s)he specifies the frame with an address, he deserves what
572 (s)he gets. Still, give the highest one that matches. */
574 for (fid
= get_current_frame ();
575 fid
&& get_frame_base (fid
) != args
[0];
576 fid
= get_prev_frame (fid
))
580 while ((tfid
= get_prev_frame (fid
)) &&
581 (get_frame_base (tfid
) == args
[0]))
584 /* We couldn't identify the frame as an existing frame, but
585 perhaps we can create one with a single argument. */
589 #ifdef SETUP_ARBITRARY_FRAME
590 return SETUP_ARBITRARY_FRAME (numargs
, args
);
592 /* Usual case. Do it here rather than have everyone supply
593 a SETUP_ARBITRARY_FRAME that does this. */
595 return create_new_frame (args
[0], 0);
596 error ("Too many args in frame specification");
603 /* Print verbosely the selected frame or the frame at address ADDR.
604 This means absolutely all information in the frame is printed. */
607 frame_info (char *addr_exp
, int from_tty
)
609 struct frame_info
*fi
;
610 struct symtab_and_line sal
;
613 struct frame_info
*calling_frame_info
;
614 int i
, count
, numregs
;
616 enum language funlang
= language_unknown
;
618 if (!target_has_stack
)
621 fi
= parse_frame_specification (addr_exp
);
623 error ("Invalid frame specified.");
625 find_frame_sal (fi
, &sal
);
626 func
= get_frame_function (fi
);
627 /* FIXME: cagney/2002-11-28: Why bother? Won't sal.symtab contain
629 s
= find_pc_symtab (get_frame_pc (fi
));
632 /* I'd like to use SYMBOL_PRINT_NAME() here, to display
633 * the demangled name that we already have stored in
634 * the symbol table, but we stored a version with
635 * DMGL_PARAMS turned on, and here we don't want
636 * to display parameters. So call the demangler again,
637 * with DMGL_ANSI only. RT
638 * (Yes, I know that printf_symbol_filtered() will
639 * again try to demangle the name on the fly, but
640 * the issue is that if cplus_demangle() fails here,
641 * it'll fail there too. So we want to catch the failure
642 * ("demangled==NULL" case below) here, while we still
643 * have our hands on the function symbol.)
646 funname
= DEPRECATED_SYMBOL_NAME (func
);
647 funlang
= SYMBOL_LANGUAGE (func
);
648 if (funlang
== language_cplus
)
650 demangled
= cplus_demangle (funname
, DMGL_ANSI
);
651 /* If the demangler fails, try the demangled name
652 * from the symbol table. This'll have parameters,
653 * but that's preferable to diplaying a mangled name.
655 if (demangled
== NULL
)
656 funname
= SYMBOL_PRINT_NAME (func
);
661 register struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (get_frame_pc (fi
));
664 funname
= DEPRECATED_SYMBOL_NAME (msymbol
);
665 funlang
= SYMBOL_LANGUAGE (msymbol
);
668 calling_frame_info
= get_prev_frame (fi
);
670 if (!addr_exp
&& frame_relative_level (deprecated_selected_frame
) >= 0)
672 printf_filtered ("Stack level %d, frame at ",
673 frame_relative_level (deprecated_selected_frame
));
674 print_address_numeric (get_frame_base (fi
), 1, gdb_stdout
);
675 printf_filtered (":\n");
679 printf_filtered ("Stack frame at ");
680 print_address_numeric (get_frame_base (fi
), 1, gdb_stdout
);
681 printf_filtered (":\n");
683 printf_filtered (" %s = ", REGISTER_NAME (PC_REGNUM
));
684 print_address_numeric (get_frame_pc (fi
), 1, gdb_stdout
);
689 printf_filtered (" in ");
690 fprintf_symbol_filtered (gdb_stdout
, funname
, funlang
,
691 DMGL_ANSI
| DMGL_PARAMS
);
695 printf_filtered (" (%s:%d)", sal
.symtab
->filename
, sal
.line
);
696 puts_filtered ("; ");
698 printf_filtered ("saved %s ", REGISTER_NAME (PC_REGNUM
));
699 print_address_numeric (frame_pc_unwind (fi
), 1, gdb_stdout
);
700 printf_filtered ("\n");
704 frameless
= FRAMELESS_FUNCTION_INVOCATION (fi
);
706 printf_filtered (" (FRAMELESS),");
709 if (calling_frame_info
)
711 printf_filtered (" called by frame at ");
712 print_address_numeric (get_frame_base (calling_frame_info
),
715 if (get_next_frame (fi
) && calling_frame_info
)
718 if (get_next_frame (fi
))
720 printf_filtered (" caller of frame at ");
721 print_address_numeric (get_frame_base (get_next_frame (fi
)), 1,
724 if (get_next_frame (fi
) || calling_frame_info
)
725 puts_filtered ("\n");
727 printf_filtered (" source language %s.\n",
728 language_str (s
->language
));
730 #ifdef PRINT_EXTRA_FRAME_INFO
731 PRINT_EXTRA_FRAME_INFO (fi
);
735 /* Address of the argument list for this frame, or 0. */
736 CORE_ADDR arg_list
= get_frame_args_address (fi
);
737 /* Number of args for this frame, or -1 if unknown. */
741 printf_filtered (" Arglist at unknown address.\n");
744 printf_filtered (" Arglist at ");
745 print_address_numeric (arg_list
, 1, gdb_stdout
);
746 printf_filtered (",");
748 numargs
= FRAME_NUM_ARGS (fi
);
750 puts_filtered (" args: ");
751 else if (numargs
== 0)
752 puts_filtered (" no args.");
753 else if (numargs
== 1)
754 puts_filtered (" 1 arg: ");
756 printf_filtered (" %d args: ", numargs
);
757 print_frame_args (func
, fi
, numargs
, gdb_stdout
);
758 puts_filtered ("\n");
762 /* Address of the local variables for this frame, or 0. */
763 CORE_ADDR arg_list
= get_frame_locals_address (fi
);
766 printf_filtered (" Locals at unknown address,");
769 printf_filtered (" Locals at ");
770 print_address_numeric (arg_list
, 1, gdb_stdout
);
771 printf_filtered (",");
775 if (DEPRECATED_FRAME_INIT_SAVED_REGS_P ()
776 && get_frame_saved_regs (fi
) == NULL
)
777 DEPRECATED_FRAME_INIT_SAVED_REGS (fi
);
778 /* Print as much information as possible on the location of all the
789 /* The sp is special; what's displayed isn't the save address, but
790 the value of the previous frame's sp. This is a legacy thing,
791 at one stage the frame cached the previous frame's SP instead
792 of its address, hence it was easiest to just display the cached
796 /* Find out the location of the saved stack pointer with out
797 actually evaluating it. */
798 frame_register_unwind (fi
, SP_REGNUM
, &optimized
, &lval
, &addr
,
800 if (!optimized
&& lval
== not_lval
)
802 void *value
= alloca (MAX_REGISTER_RAW_SIZE
);
804 frame_register_unwind (fi
, SP_REGNUM
, &optimized
, &lval
, &addr
,
806 sp
= extract_address (value
, REGISTER_RAW_SIZE (SP_REGNUM
));
807 printf_filtered (" Previous frame's sp is ");
808 print_address_numeric (sp
, 1, gdb_stdout
);
809 printf_filtered ("\n");
812 else if (!optimized
&& lval
== lval_memory
)
814 printf_filtered (" Previous frame's sp at ");
815 print_address_numeric (addr
, 1, gdb_stdout
);
816 printf_filtered ("\n");
819 else if (!optimized
&& lval
== lval_register
)
821 printf_filtered (" Previous frame's sp in %s\n",
822 REGISTER_NAME (realnum
));
825 /* else keep quiet. */
829 numregs
= NUM_REGS
+ NUM_PSEUDO_REGS
;
830 for (i
= 0; i
< numregs
; i
++)
833 /* Find out the location of the saved register without
834 fetching the corresponding value. */
835 frame_register_unwind (fi
, i
, &optimized
, &lval
, &addr
, &realnum
,
837 /* For moment, only display registers that were saved on the
839 if (!optimized
&& lval
== lval_memory
)
842 puts_filtered (" Saved registers:\n ");
846 printf_filtered (" %s at ", REGISTER_NAME (i
));
847 print_address_numeric (addr
, 1, gdb_stdout
);
851 if (count
|| need_nl
)
852 puts_filtered ("\n");
857 /* Set a limit on the number of frames printed by default in a
860 static int backtrace_limit
;
863 set_backtrace_limit_command (char *count_exp
, int from_tty
)
865 int count
= parse_and_eval_long (count_exp
);
868 error ("Negative argument not meaningful as backtrace limit.");
870 backtrace_limit
= count
;
874 backtrace_limit_info (char *arg
, int from_tty
)
877 error ("\"Info backtrace-limit\" takes no arguments.");
879 printf_unfiltered ("Backtrace limit: %d.\n", backtrace_limit
);
883 /* Print briefly all stack frames or just the innermost COUNT frames. */
885 static void backtrace_command_1 (char *count_exp
, int show_locals
,
888 backtrace_command_1 (char *count_exp
, int show_locals
, int from_tty
)
890 struct frame_info
*fi
;
893 register struct frame_info
*trailing
;
894 register int trailing_level
;
896 if (!target_has_stack
)
899 /* The following code must do two things. First, it must
900 set the variable TRAILING to the frame from which we should start
901 printing. Second, it must set the variable count to the number
902 of frames which we should print, or -1 if all of them. */
903 trailing
= get_current_frame ();
905 /* The target can be in a state where there is no valid frames
906 (e.g., just connected). */
907 if (trailing
== NULL
)
913 count
= parse_and_eval_long (count_exp
);
916 struct frame_info
*current
;
921 while (current
&& count
--)
924 current
= get_prev_frame (current
);
927 /* Will stop when CURRENT reaches the top of the stack. TRAILING
928 will be COUNT below it. */
932 trailing
= get_prev_frame (trailing
);
933 current
= get_prev_frame (current
);
945 struct partial_symtab
*ps
;
947 /* Read in symbols for all of the frames. Need to do this in
948 a separate pass so that "Reading in symbols for xxx" messages
949 don't screw up the appearance of the backtrace. Also
950 if people have strong opinions against reading symbols for
951 backtrace this may have to be an option. */
955 fi
= get_prev_frame (fi
))
958 ps
= find_pc_psymtab (frame_address_in_block (fi
));
960 PSYMTAB_TO_SYMTAB (ps
); /* Force syms to come in */
964 for (i
= 0, fi
= trailing
;
966 i
++, fi
= get_prev_frame (fi
))
970 /* Don't use print_stack_frame; if an error() occurs it probably
971 means further attempts to backtrace would fail (on the other
972 hand, perhaps the code does or could be fixed to make sure
973 the frame->prev field gets set to NULL in that case). */
974 print_frame_info (fi
, trailing_level
+ i
, 0, 1);
976 print_frame_local_vars (fi
, 1, gdb_stdout
);
979 /* If we've stopped before the end, mention that. */
981 printf_filtered ("(More stack frames follow...)\n");
985 backtrace_command (char *arg
, int from_tty
)
987 struct cleanup
*old_chain
= (struct cleanup
*) NULL
;
988 char **argv
= (char **) NULL
;
989 int argIndicatingFullTrace
= (-1), totArgLen
= 0, argc
= 0;
992 if (arg
!= (char *) NULL
)
996 argv
= buildargv (arg
);
997 old_chain
= make_cleanup_freeargv (argv
);
999 for (i
= 0; (argv
[i
] != (char *) NULL
); i
++)
1003 for (j
= 0; (j
< strlen (argv
[i
])); j
++)
1004 argv
[i
][j
] = tolower (argv
[i
][j
]);
1006 if (argIndicatingFullTrace
< 0 && subset_compare (argv
[i
], "full"))
1007 argIndicatingFullTrace
= argc
;
1011 totArgLen
+= strlen (argv
[i
]);
1015 if (argIndicatingFullTrace
>= 0)
1019 argPtr
= (char *) xmalloc (totArgLen
+ 1);
1024 memset (argPtr
, 0, totArgLen
+ 1);
1025 for (i
= 0; (i
< (argc
+ 1)); i
++)
1027 if (i
!= argIndicatingFullTrace
)
1029 strcat (argPtr
, argv
[i
]);
1030 strcat (argPtr
, " ");
1036 argPtr
= (char *) NULL
;
1040 backtrace_command_1 (argPtr
, (argIndicatingFullTrace
>= 0), from_tty
);
1042 if (argIndicatingFullTrace
>= 0 && totArgLen
> 0)
1046 do_cleanups (old_chain
);
1049 static void backtrace_full_command (char *arg
, int from_tty
);
1051 backtrace_full_command (char *arg
, int from_tty
)
1053 backtrace_command_1 (arg
, 1, from_tty
);
1057 /* Print the local variables of a block B active in FRAME.
1058 Return 1 if any variables were printed; 0 otherwise. */
1061 print_block_frame_locals (struct block
*b
, register struct frame_info
*fi
,
1062 int num_tabs
, register struct ui_file
*stream
)
1065 register struct symbol
*sym
;
1066 register int values_printed
= 0;
1068 ALL_BLOCK_SYMBOLS (b
, i
, sym
)
1070 switch (SYMBOL_CLASS (sym
))
1078 for (j
= 0; j
< num_tabs
; j
++)
1079 fputs_filtered ("\t", stream
);
1080 fputs_filtered (SYMBOL_PRINT_NAME (sym
), stream
);
1081 fputs_filtered (" = ", stream
);
1082 print_variable_value (sym
, fi
, stream
);
1083 fprintf_filtered (stream
, "\n");
1087 /* Ignore symbols which are not locals. */
1091 return values_printed
;
1094 /* Same, but print labels. */
1097 print_block_frame_labels (struct block
*b
, int *have_default
,
1098 register struct ui_file
*stream
)
1101 register struct symbol
*sym
;
1102 register int values_printed
= 0;
1104 ALL_BLOCK_SYMBOLS (b
, i
, sym
)
1106 if (STREQ (DEPRECATED_SYMBOL_NAME (sym
), "default"))
1112 if (SYMBOL_CLASS (sym
) == LOC_LABEL
)
1114 struct symtab_and_line sal
;
1115 sal
= find_pc_line (SYMBOL_VALUE_ADDRESS (sym
), 0);
1117 fputs_filtered (SYMBOL_PRINT_NAME (sym
), stream
);
1120 fprintf_filtered (stream
, " ");
1121 print_address_numeric (SYMBOL_VALUE_ADDRESS (sym
), 1, stream
);
1123 fprintf_filtered (stream
, " in file %s, line %d\n",
1124 sal
.symtab
->filename
, sal
.line
);
1127 return values_printed
;
1130 /* Print on STREAM all the local variables in frame FRAME,
1131 including all the blocks active in that frame
1134 Returns 1 if the job was done,
1135 or 0 if nothing was printed because we have no info
1136 on the function running in FRAME. */
1139 print_frame_local_vars (register struct frame_info
*fi
, register int num_tabs
,
1140 register struct ui_file
*stream
)
1142 register struct block
*block
= get_frame_block (fi
, 0);
1143 register int values_printed
= 0;
1147 fprintf_filtered (stream
, "No symbol table info available.\n");
1153 if (print_block_frame_locals (block
, fi
, num_tabs
, stream
))
1155 /* After handling the function's top-level block, stop.
1156 Don't continue to its superblock, the block of
1157 per-file symbols. */
1158 if (BLOCK_FUNCTION (block
))
1160 block
= BLOCK_SUPERBLOCK (block
);
1163 if (!values_printed
)
1165 fprintf_filtered (stream
, "No locals.\n");
1169 /* Same, but print labels. */
1172 print_frame_label_vars (register struct frame_info
*fi
, int this_level_only
,
1173 register struct ui_file
*stream
)
1175 register struct blockvector
*bl
;
1176 register struct block
*block
= get_frame_block (fi
, 0);
1177 register int values_printed
= 0;
1178 int index
, have_default
= 0;
1179 char *blocks_printed
;
1180 CORE_ADDR pc
= get_frame_pc (fi
);
1184 fprintf_filtered (stream
, "No symbol table info available.\n");
1188 bl
= blockvector_for_pc (BLOCK_END (block
) - 4, &index
);
1189 blocks_printed
= (char *) alloca (BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
1190 memset (blocks_printed
, 0, BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
1194 CORE_ADDR end
= BLOCK_END (block
) - 4;
1197 if (bl
!= blockvector_for_pc (end
, &index
))
1198 error ("blockvector blotch");
1199 if (BLOCKVECTOR_BLOCK (bl
, index
) != block
)
1200 error ("blockvector botch");
1201 last_index
= BLOCKVECTOR_NBLOCKS (bl
);
1204 /* Don't print out blocks that have gone by. */
1205 while (index
< last_index
1206 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < pc
)
1209 while (index
< last_index
1210 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < end
)
1212 if (blocks_printed
[index
] == 0)
1214 if (print_block_frame_labels (BLOCKVECTOR_BLOCK (bl
, index
), &have_default
, stream
))
1216 blocks_printed
[index
] = 1;
1222 if (values_printed
&& this_level_only
)
1225 /* After handling the function's top-level block, stop.
1226 Don't continue to its superblock, the block of
1227 per-file symbols. */
1228 if (BLOCK_FUNCTION (block
))
1230 block
= BLOCK_SUPERBLOCK (block
);
1233 if (!values_printed
&& !this_level_only
)
1235 fprintf_filtered (stream
, "No catches.\n");
1241 locals_info (char *args
, int from_tty
)
1243 if (!deprecated_selected_frame
)
1244 error ("No frame selected.");
1245 print_frame_local_vars (deprecated_selected_frame
, 0, gdb_stdout
);
1249 catch_info (char *ignore
, int from_tty
)
1251 struct symtab_and_line
*sal
;
1253 /* Check for target support for exception handling */
1254 sal
= target_enable_exception_callback (EX_EVENT_CATCH
, 1);
1257 /* Currently not handling this */
1258 /* Ideally, here we should interact with the C++ runtime
1259 system to find the list of active handlers, etc. */
1260 fprintf_filtered (gdb_stdout
, "Info catch not supported with this target/compiler combination.\n");
1262 if (!deprecated_selected_frame
)
1263 error ("No frame selected.");
1268 /* Assume g++ compiled code -- old v 4.16 behaviour */
1269 if (!deprecated_selected_frame
)
1270 error ("No frame selected.");
1272 print_frame_label_vars (deprecated_selected_frame
, 0, gdb_stdout
);
1277 print_frame_arg_vars (register struct frame_info
*fi
,
1278 register struct ui_file
*stream
)
1280 struct symbol
*func
= get_frame_function (fi
);
1281 register struct block
*b
;
1283 register struct symbol
*sym
, *sym2
;
1284 register int values_printed
= 0;
1288 fprintf_filtered (stream
, "No symbol table info available.\n");
1292 b
= SYMBOL_BLOCK_VALUE (func
);
1293 ALL_BLOCK_SYMBOLS (b
, i
, sym
)
1295 switch (SYMBOL_CLASS (sym
))
1301 case LOC_REGPARM_ADDR
:
1302 case LOC_BASEREG_ARG
:
1303 case LOC_COMPUTED_ARG
:
1305 fputs_filtered (SYMBOL_PRINT_NAME (sym
), stream
);
1306 fputs_filtered (" = ", stream
);
1308 /* We have to look up the symbol because arguments can have
1309 two entries (one a parameter, one a local) and the one we
1310 want is the local, which lookup_symbol will find for us.
1311 This includes gcc1 (not gcc2) on the sparc when passing a
1312 small structure and gcc2 when the argument type is float
1313 and it is passed as a double and converted to float by
1314 the prologue (in the latter case the type of the LOC_ARG
1315 symbol is double and the type of the LOC_LOCAL symbol is
1316 float). There are also LOC_ARG/LOC_REGISTER pairs which
1317 are not combined in symbol-reading. */
1319 sym2
= lookup_symbol (DEPRECATED_SYMBOL_NAME (sym
),
1320 b
, VAR_NAMESPACE
, (int *) NULL
, (struct symtab
**) NULL
);
1321 print_variable_value (sym2
, fi
, stream
);
1322 fprintf_filtered (stream
, "\n");
1326 /* Don't worry about things which aren't arguments. */
1330 if (!values_printed
)
1332 fprintf_filtered (stream
, "No arguments.\n");
1337 args_info (char *ignore
, int from_tty
)
1339 if (!deprecated_selected_frame
)
1340 error ("No frame selected.");
1341 print_frame_arg_vars (deprecated_selected_frame
, gdb_stdout
);
1346 args_plus_locals_info (char *ignore
, int from_tty
)
1348 args_info (ignore
, from_tty
);
1349 locals_info (ignore
, from_tty
);
1353 /* Select frame FI. Also print the stack frame and show the source if
1354 this is the tui version. */
1356 select_and_print_frame (struct frame_info
*fi
)
1361 print_stack_frame (fi
, frame_relative_level (fi
), 1);
1365 /* Return the symbol-block in which the selected frame is executing.
1366 Can return zero under various legitimate circumstances.
1368 If ADDR_IN_BLOCK is non-zero, set *ADDR_IN_BLOCK to the relevant
1369 code address within the block returned. We use this to decide
1370 which macros are in scope. */
1373 get_selected_block (CORE_ADDR
*addr_in_block
)
1375 if (!target_has_stack
)
1378 /* NOTE: cagney/2002-11-28: Why go to all this effort to not create
1379 a selected/current frame? Perhaphs this function is called,
1380 indirectly, by WFI in "infrun.c" where avoiding the creation of
1381 an inner most frame is very important (it slows down single
1382 step). I suspect, though that this was true in the deep dark
1383 past but is no longer the case. A mindless look at all the
1384 callers tends to support this theory. I think we should be able
1385 to assume that there is always a selcted frame. */
1386 /* gdb_assert (deprecated_selected_frame != NULL); So, do you feel
1388 if (!deprecated_selected_frame
)
1390 CORE_ADDR pc
= read_pc ();
1391 if (addr_in_block
!= NULL
)
1392 *addr_in_block
= pc
;
1393 return block_for_pc (pc
);
1395 return get_frame_block (deprecated_selected_frame
, addr_in_block
);
1398 /* Find a frame a certain number of levels away from FRAME.
1399 LEVEL_OFFSET_PTR points to an int containing the number of levels.
1400 Positive means go to earlier frames (up); negative, the reverse.
1401 The int that contains the number of levels is counted toward
1402 zero as the frames for those levels are found.
1403 If the top or bottom frame is reached, that frame is returned,
1404 but the final value of *LEVEL_OFFSET_PTR is nonzero and indicates
1405 how much farther the original request asked to go. */
1408 find_relative_frame (register struct frame_info
*frame
,
1409 register int *level_offset_ptr
)
1411 register struct frame_info
*prev
;
1412 register struct frame_info
*frame1
;
1414 /* Going up is simple: just do get_prev_frame enough times
1415 or until initial frame is reached. */
1416 while (*level_offset_ptr
> 0)
1418 prev
= get_prev_frame (frame
);
1421 (*level_offset_ptr
)--;
1424 /* Going down is just as simple. */
1425 if (*level_offset_ptr
< 0)
1427 while (*level_offset_ptr
< 0)
1429 frame1
= get_next_frame (frame
);
1433 (*level_offset_ptr
)++;
1439 /* The "select_frame" command. With no arg, NOP.
1440 With arg LEVEL_EXP, select the frame at level LEVEL if it is a
1441 valid level. Otherwise, treat level_exp as an address expression
1442 and select it. See parse_frame_specification for more info on proper
1443 frame expressions. */
1447 select_frame_command_wrapper (char *level_exp
, int from_tty
)
1449 select_frame_command (level_exp
, from_tty
);
1453 select_frame_command (char *level_exp
, int from_tty
)
1455 struct frame_info
*frame
;
1456 int level
= frame_relative_level (deprecated_selected_frame
);
1458 if (!target_has_stack
)
1459 error ("No stack.");
1461 frame
= parse_frame_specification (level_exp
);
1463 select_frame (frame
);
1464 if (level
!= frame_relative_level (deprecated_selected_frame
))
1465 selected_frame_level_changed_event (frame_relative_level (deprecated_selected_frame
));
1468 /* The "frame" command. With no arg, print selected frame briefly.
1469 With arg, behaves like select_frame and then prints the selected
1473 frame_command (char *level_exp
, int from_tty
)
1475 select_frame_command (level_exp
, from_tty
);
1476 print_stack_frame (deprecated_selected_frame
,
1477 frame_relative_level (deprecated_selected_frame
), 1);
1480 /* The XDB Compatibility command to print the current frame. */
1483 current_frame_command (char *level_exp
, int from_tty
)
1485 if (target_has_stack
== 0 || deprecated_selected_frame
== 0)
1486 error ("No stack.");
1487 print_stack_frame (deprecated_selected_frame
,
1488 frame_relative_level (deprecated_selected_frame
), 1);
1491 /* Select the frame up one or COUNT stack levels
1492 from the previously selected frame, and print it briefly. */
1496 up_silently_base (char *count_exp
)
1498 register struct frame_info
*fi
;
1499 int count
= 1, count1
;
1501 count
= parse_and_eval_long (count_exp
);
1504 if (target_has_stack
== 0 || deprecated_selected_frame
== 0)
1505 error ("No stack.");
1507 fi
= find_relative_frame (deprecated_selected_frame
, &count1
);
1508 if (count1
!= 0 && count_exp
== 0)
1509 error ("Initial frame selected; you cannot go up.");
1511 selected_frame_level_changed_event (frame_relative_level (deprecated_selected_frame
));
1515 up_silently_command (char *count_exp
, int from_tty
)
1517 up_silently_base (count_exp
);
1521 up_command (char *count_exp
, int from_tty
)
1523 up_silently_base (count_exp
);
1524 print_stack_frame (deprecated_selected_frame
,
1525 frame_relative_level (deprecated_selected_frame
), 1);
1528 /* Select the frame down one or COUNT stack levels
1529 from the previously selected frame, and print it briefly. */
1533 down_silently_base (char *count_exp
)
1535 register struct frame_info
*frame
;
1536 int count
= -1, count1
;
1538 count
= -parse_and_eval_long (count_exp
);
1541 if (target_has_stack
== 0 || deprecated_selected_frame
== 0)
1542 error ("No stack.");
1544 frame
= find_relative_frame (deprecated_selected_frame
, &count1
);
1545 if (count1
!= 0 && count_exp
== 0)
1548 /* We only do this if count_exp is not specified. That way "down"
1549 means to really go down (and let me know if that is
1550 impossible), but "down 9999" can be used to mean go all the way
1551 down without getting an error. */
1553 error ("Bottom (i.e., innermost) frame selected; you cannot go down.");
1556 select_frame (frame
);
1557 selected_frame_level_changed_event (frame_relative_level (deprecated_selected_frame
));
1562 down_silently_command (char *count_exp
, int from_tty
)
1564 down_silently_base (count_exp
);
1568 down_command (char *count_exp
, int from_tty
)
1570 down_silently_base (count_exp
);
1571 print_stack_frame (deprecated_selected_frame
,
1572 frame_relative_level (deprecated_selected_frame
), 1);
1576 return_command (char *retval_exp
, int from_tty
)
1578 struct symbol
*thisfun
;
1579 CORE_ADDR selected_frame_addr
;
1580 CORE_ADDR selected_frame_pc
;
1581 struct frame_info
*frame
;
1582 struct value
*return_value
= NULL
;
1584 if (deprecated_selected_frame
== NULL
)
1585 error ("No selected frame.");
1586 thisfun
= get_frame_function (deprecated_selected_frame
);
1587 selected_frame_addr
= get_frame_base (deprecated_selected_frame
);
1588 selected_frame_pc
= get_frame_pc (deprecated_selected_frame
);
1590 /* Compute the return value (if any -- possibly getting errors here). */
1594 struct type
*return_type
= NULL
;
1596 return_value
= parse_and_eval (retval_exp
);
1598 /* Cast return value to the return type of the function. */
1599 if (thisfun
!= NULL
)
1600 return_type
= TYPE_TARGET_TYPE (SYMBOL_TYPE (thisfun
));
1601 if (return_type
== NULL
)
1602 return_type
= builtin_type_int
;
1603 return_value
= value_cast (return_type
, return_value
);
1605 /* Make sure we have fully evaluated it, since
1606 it might live in the stack frame we're about to pop. */
1607 if (VALUE_LAZY (return_value
))
1608 value_fetch_lazy (return_value
);
1611 /* If interactive, require confirmation. */
1617 if (!query ("Make %s return now? ", SYMBOL_PRINT_NAME (thisfun
)))
1619 error ("Not confirmed.");
1623 else if (!query ("Make selected stack frame return now? "))
1624 error ("Not confirmed.");
1627 /* FIXME: cagney/2003-01-18: Rather than pop each frame in turn,
1628 this code should just go straight to the relevant frame and pop
1631 /* Do the real work. Pop until the specified frame is current. We
1632 use this method because the deprecated_selected_frame is not
1633 valid after a frame_pop(). The pc comparison makes this work
1634 even if the selected frame shares its fp with another frame. */
1636 /* FIXME: cagney/32003-03-12: This code should use frame_id_eq().
1637 Unfortunatly, that function doesn't yet include the PC in any
1638 frame ID comparison. */
1640 while (selected_frame_addr
!= get_frame_base (frame
= get_current_frame ())
1641 || selected_frame_pc
!= get_frame_pc (frame
))
1642 frame_pop (get_current_frame ());
1644 /* Then pop that frame. */
1646 frame_pop (get_current_frame ());
1648 /* Compute the return value (if any) and store in the place
1649 for return values. */
1652 set_return_value (return_value
);
1654 /* If we are at the end of a call dummy now, pop the dummy frame too. */
1656 /* FIXME: cagney/2003-01-18: This is silly. Instead of popping all
1657 the frames except the dummy, and then, as an afterthought,
1658 popping the dummy frame, this code should just pop through to the
1661 if (CALL_DUMMY_HAS_COMPLETED (read_pc(), read_sp (),
1662 get_frame_base (get_current_frame ())))
1663 frame_pop (get_current_frame ());
1665 /* If interactive, print the frame that is now current. */
1668 frame_command ("0", 1);
1670 select_frame_command ("0", 0);
1673 /* Sets the scope to input function name, provided that the
1674 function is within the current stack frame */
1676 struct function_bounds
1678 CORE_ADDR low
, high
;
1681 static void func_command (char *arg
, int from_tty
);
1683 func_command (char *arg
, int from_tty
)
1685 struct frame_info
*fp
;
1687 struct symtabs_and_lines sals
;
1690 struct function_bounds
*func_bounds
= (struct function_bounds
*) NULL
;
1692 if (arg
!= (char *) NULL
)
1695 fp
= parse_frame_specification ("0");
1696 sals
= decode_line_spec (arg
, 1);
1697 func_bounds
= (struct function_bounds
*) xmalloc (
1698 sizeof (struct function_bounds
) * sals
.nelts
);
1699 for (i
= 0; (i
< sals
.nelts
&& !found
); i
++)
1701 if (sals
.sals
[i
].pc
== (CORE_ADDR
) 0 ||
1702 find_pc_partial_function (sals
.sals
[i
].pc
,
1704 &func_bounds
[i
].low
,
1705 &func_bounds
[i
].high
) == 0)
1707 func_bounds
[i
].low
=
1708 func_bounds
[i
].high
= (CORE_ADDR
) NULL
;
1714 for (i
= 0; (i
< sals
.nelts
&& !found
); i
++)
1715 found
= (get_frame_pc (fp
) >= func_bounds
[i
].low
&&
1716 get_frame_pc (fp
) < func_bounds
[i
].high
);
1720 fp
= find_relative_frame (fp
, &level
);
1723 while (!found
&& level
== 0);
1726 xfree (func_bounds
);
1729 printf_filtered ("'%s' not within current stack frame.\n", arg
);
1730 else if (fp
!= deprecated_selected_frame
)
1731 select_and_print_frame (fp
);
1734 /* Gets the language of the current frame. */
1737 get_frame_language (void)
1739 register struct symtab
*s
;
1740 enum language flang
; /* The language of the current frame */
1742 if (deprecated_selected_frame
)
1744 s
= find_pc_symtab (get_frame_pc (deprecated_selected_frame
));
1746 flang
= s
->language
;
1748 flang
= language_unknown
;
1751 flang
= language_unknown
;
1757 _initialize_stack (void)
1760 backtrace_limit
= 30;
1763 add_com ("return", class_stack
, return_command
,
1764 "Make selected stack frame return to its caller.\n\
1765 Control remains in the debugger, but when you continue\n\
1766 execution will resume in the frame above the one now selected.\n\
1767 If an argument is given, it is an expression for the value to return.");
1769 add_com ("up", class_stack
, up_command
,
1770 "Select and print stack frame that called this one.\n\
1771 An argument says how many frames up to go.");
1772 add_com ("up-silently", class_support
, up_silently_command
,
1773 "Same as the `up' command, but does not print anything.\n\
1774 This is useful in command scripts.");
1776 add_com ("down", class_stack
, down_command
,
1777 "Select and print stack frame called by this one.\n\
1778 An argument says how many frames down to go.");
1779 add_com_alias ("do", "down", class_stack
, 1);
1780 add_com_alias ("dow", "down", class_stack
, 1);
1781 add_com ("down-silently", class_support
, down_silently_command
,
1782 "Same as the `down' command, but does not print anything.\n\
1783 This is useful in command scripts.");
1785 add_com ("frame", class_stack
, frame_command
,
1786 "Select and print a stack frame.\n\
1787 With no argument, print the selected stack frame. (See also \"info frame\").\n\
1788 An argument specifies the frame to select.\n\
1789 It can be a stack frame number or the address of the frame.\n\
1790 With argument, nothing is printed if input is coming from\n\
1791 a command file or a user-defined command.");
1793 add_com_alias ("f", "frame", class_stack
, 1);
1797 add_com ("L", class_stack
, current_frame_command
,
1798 "Print the current stack frame.\n");
1799 add_com_alias ("V", "frame", class_stack
, 1);
1801 add_com ("select-frame", class_stack
, select_frame_command
,
1802 "Select a stack frame without printing anything.\n\
1803 An argument specifies the frame to select.\n\
1804 It can be a stack frame number or the address of the frame.\n");
1806 add_com ("backtrace", class_stack
, backtrace_command
,
1807 "Print backtrace of all stack frames, or innermost COUNT frames.\n\
1808 With a negative argument, print outermost -COUNT frames.\n\
1809 Use of the 'full' qualifier also prints the values of the local variables.\n");
1810 add_com_alias ("bt", "backtrace", class_stack
, 0);
1813 add_com_alias ("t", "backtrace", class_stack
, 0);
1814 add_com ("T", class_stack
, backtrace_full_command
,
1815 "Print backtrace of all stack frames, or innermost COUNT frames \n\
1816 and the values of the local variables.\n\
1817 With a negative argument, print outermost -COUNT frames.\n\
1818 Usage: T <count>\n");
1821 add_com_alias ("where", "backtrace", class_alias
, 0);
1822 add_info ("stack", backtrace_command
,
1823 "Backtrace of the stack, or innermost COUNT frames.");
1824 add_info_alias ("s", "stack", 1);
1825 add_info ("frame", frame_info
,
1826 "All about selected stack frame, or frame at ADDR.");
1827 add_info_alias ("f", "frame", 1);
1828 add_info ("locals", locals_info
,
1829 "Local variables of current stack frame.");
1830 add_info ("args", args_info
,
1831 "Argument variables of current stack frame.");
1833 add_com ("l", class_info
, args_plus_locals_info
,
1834 "Argument and local variables of current stack frame.");
1837 add_com ("func", class_stack
, func_command
,
1838 "Select the stack frame that contains <func>.\nUsage: func <name>\n");
1840 add_info ("catch", catch_info
,
1841 "Exceptions that can be caught in the current stack frame.");
1844 add_cmd ("backtrace-limit", class_stack
, set_backtrace_limit_command
,
1845 "Specify maximum number of frames for \"backtrace\" to print by default.",
1847 add_info ("backtrace-limit", backtrace_limit_info
,
1848 "The maximum number of frames for \"backtrace\" to print by default.");