1 /* Print and select stack frames for GDB, the GNU debugger.
2 Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
4 This file is part of GDB.
6 GDB is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
11 GDB is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GDB; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
30 #include "breakpoint.h"
32 extern int addressprint; /* Print addresses, or stay symbolic only? */
33 extern int info_verbose; /* Verbosity of symbol reading msgs */
34 extern char *reg_names[]; /* Names of registers */
36 /* Thie "selected" stack frame is used by default for local and arg access.
37 May be zero, for no selected frame. */
41 /* Level of the selected frame:
42 0 for innermost, 1 for its caller, ...
43 or -1 for frame specified by address with no defined level. */
45 int selected_frame_level;
47 /* Nonzero means print the full filename and linenumber
48 when a frame is printed, and do so in a format programs can parse. */
50 int frame_file_full_name = 0;
52 void print_frame_info ();
54 /* Print a stack frame briefly. FRAME should be the frame id
55 and LEVEL should be its level in the stack (or -1 for level not defined).
56 This prints the level, the function executing, the arguments,
57 and the file name and line number.
58 If the pc is not at the beginning of the source line,
59 the actual pc is printed at the beginning.
61 If SOURCE is 1, print the source line as well.
62 If SOURCE is -1, print ONLY the source line. */
65 print_stack_frame (frame, level, source)
70 struct frame_info *fi;
72 fi = get_frame_info (frame);
74 print_frame_info (fi, level, source, 1);
78 print_frame_info (fi, level, source, args)
79 struct frame_info *fi;
84 struct symtab_and_line sal;
86 register char *funname = 0;
89 #if 0 /* Symbol reading is fast enough now */
90 struct partial_symtab *pst;
92 /* Don't give very much information if we haven't readin the
94 pst = find_pc_psymtab (fi->pc);
95 if (pst && !pst->readin)
97 /* Abbreviated information. */
100 if (!find_pc_partial_function (fi->pc, &fname, 0))
103 printf_filtered ("#%-2d ", level);
105 printf_filtered ("0x%x in ", fi->pc);
107 fputs_demangled (fname, stdout, -1);
108 fputs_filtered (" (...)\n", stdout);
114 sal = find_pc_line (fi->pc, fi->next_frame);
115 func = find_pc_function (fi->pc);
118 /* In certain pathological cases, the symtabs give the wrong
119 function (when we are in the first function in a file which
120 is compiled without debugging symbols, the previous function
121 is compiled with debugging symbols, and the "foo.o" symbol
122 that is supposed to tell us where the file with debugging symbols
123 ends has been truncated by ar because it is longer than 15
126 So look in the misc_function_vector as well, and if it comes
127 up with a larger address for the function use that instead.
128 I don't think this can ever cause any problems;
129 there shouldn't be any
130 misc_function_vector symbols in the middle of a function. */
131 int misc_index = find_pc_misc_function (fi->pc);
133 && (misc_function_vector[misc_index].address
134 > BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
136 /* In this case we have no way of knowing the source file
137 and line number, so don't print them. */
139 /* We also don't know anything about the function besides
140 its address and name. */
142 funname = misc_function_vector[misc_index].name;
145 funname = SYMBOL_NAME (func);
149 register int misc_index = find_pc_misc_function (fi->pc);
151 funname = misc_function_vector[misc_index].name;
154 if (source >= 0 || !sal.symtab)
157 printf_filtered ("#%-2d ", level);
159 if (fi->pc != sal.pc || !sal.symtab)
160 printf_filtered ("0x%x in ", fi->pc);
161 fputs_demangled (funname ? funname : "??", stdout, -1);
163 fputs_filtered (" (", stdout);
166 FRAME_NUM_ARGS (numargs, fi);
167 print_frame_args (func, fi, numargs, stdout);
169 printf_filtered (")");
170 if (sal.symtab && sal.symtab->filename)
173 printf_filtered (" at %s:%d", sal.symtab->filename, sal.line);
175 printf_filtered ("\n");
178 if ((source != 0) && sal.symtab)
181 int mid_statement = source < 0 && fi->pc != sal.pc;
182 if (frame_file_full_name)
183 done = identify_source_line (sal.symtab, sal.line, mid_statement);
186 if (addressprint && mid_statement)
187 printf_filtered ("0x%x\t", fi->pc);
188 print_source_lines (sal.symtab, sal.line, sal.line + 1, 0);
190 current_source_line = max (sal.line - lines_to_list () / 2, 1);
193 set_default_breakpoint (1, fi->pc, sal.symtab, sal.line);
198 /* Call here to print info on selected frame, after a trap. */
201 print_sel_frame (just_source)
204 print_stack_frame (selected_frame, -1, just_source ? -1 : 1);
207 /* Print info on the selected frame, including level number
211 print_selected_frame ()
213 print_stack_frame (selected_frame, selected_frame_level, 0);
216 void flush_cached_frames ();
218 #ifdef FRAME_SPECIFICATION_DYADIC
219 extern FRAME setup_arbitrary_frame ();
223 * Read a frame specification in whatever the appropriate format is.
224 * Call error() if the specification is in any way invalid (i.e.
225 * this function never returns NULL).
228 parse_frame_specification (frame_exp)
236 char *addr_string, *p;
237 struct cleanup *tmp_cleanup;
239 while (*frame_exp == ' ') frame_exp++;
240 for (p = frame_exp; *p && *p != ' '; p++)
246 addr_string = savestring(frame_exp, p - frame_exp);
249 tmp_cleanup = make_cleanup (free, addr_string);
250 arg1 = parse_and_eval_address (addr_string);
251 do_cleanups (tmp_cleanup);
254 while (*p == ' ') p++;
259 arg2 = parse_and_eval_address (p);
267 if (selected_frame == NULL)
268 error ("No selected frame.");
269 return selected_frame;
274 FRAME fid = find_relative_frame (get_current_frame (), &level);
278 /* find_relative_frame was successful */
281 /* If (s)he specifies the frame with an address, he deserves what
282 (s)he gets. Still, give the highest one that matches. */
284 for (fid = get_current_frame ();
285 fid && FRAME_FP (fid) != arg1;
286 fid = get_prev_frame (fid))
290 while ((tfid = get_prev_frame (fid)) &&
291 (FRAME_FP (tfid) == arg1))
294 #ifdef FRAME_SPECIFICATION_DYADIC
296 error ("Incorrect number of args in frame specification");
300 return create_new_frame (arg1, 0);
305 /* Must be addresses */
306 #ifndef FRAME_SPECIFICATION_DYADIC
307 error ("Incorrect number of args in frame specification");
309 return setup_arbitrary_frame (arg1, arg2);
313 fatal ("Internal: Error in parsing in parse_frame_specification");
317 /* FRAME_ARGS_ADDRESS_CORRECT is just like FRAME_ARGS_ADDRESS except
318 that if it is unsure about the answer, it returns 0
319 instead of guessing (this happens on the VAX and i960, for example).
321 On most machines, we never have to guess about the args address,
322 so FRAME_ARGS_ADDRESS{,_CORRECT} are the same. */
323 #if !defined (FRAME_ARGS_ADDRESS_CORRECT)
324 #define FRAME_ARGS_ADDRESS_CORRECT FRAME_ARGS_ADDRESS
327 /* Print verbosely the selected frame or the frame at address ADDR.
328 This means absolutely all information in the frame is printed. */
331 frame_info (addr_exp)
335 struct frame_info *fi;
336 struct frame_saved_regs fsr;
337 struct symtab_and_line sal;
343 if (!target_has_stack)
344 error ("No inferior or core file.");
346 frame = parse_frame_specification (addr_exp);
348 error ("Invalid frame specified.");
350 fi = get_frame_info (frame);
351 sal = find_pc_line (fi->pc, fi->next_frame);
352 func = get_frame_function (frame);
354 funname = SYMBOL_NAME (func);
357 register int misc_index = find_pc_misc_function (fi->pc);
359 funname = misc_function_vector[misc_index].name;
361 calling_frame = get_prev_frame (frame);
363 if (!addr_exp && selected_frame_level >= 0)
364 printf_filtered ("Stack level %d, frame at 0x%x:\n %s = 0x%x",
365 selected_frame_level, FRAME_FP(frame),
366 reg_names[PC_REGNUM], fi->pc);
368 printf_filtered ("Stack frame at 0x%x:\n %s = 0x%x",
369 FRAME_FP(frame), reg_names[PC_REGNUM], fi->pc);
373 printf_filtered (" in %s", funname);
376 printf_filtered (" (%s:%d)", sal.symtab->filename, sal.line);
377 puts_filtered ("; ");
379 printf_filtered ("saved %s 0x%x\n", reg_names[PC_REGNUM],
380 FRAME_SAVED_PC (frame));
382 printf_filtered (" called by frame at 0x%x", FRAME_FP (calling_frame));
383 if (fi->next_frame && calling_frame)
387 printf_filtered (" caller of frame at 0x%x", fi->next_frame);
388 if (fi->next_frame || calling_frame)
389 puts_filtered ("\n");
392 /* Address of the argument list for this frame, or 0. */
393 CORE_ADDR arg_list = FRAME_ARGS_ADDRESS_CORRECT (fi);
394 /* Number of args for this frame, or -1 if unknown. */
398 printf_filtered (" Arglist at unknown address.\n");
401 printf_filtered (" Arglist at 0x%x,", arg_list);
403 FRAME_NUM_ARGS (numargs, fi);
405 puts_filtered (" args: ");
406 else if (numargs == 0)
407 puts_filtered (" no args.");
408 else if (numargs == 1)
409 puts_filtered (" 1 arg: ");
411 printf_filtered (" %d args: ", numargs);
412 print_frame_args (func, fi, numargs, stdout);
413 puts_filtered ("\n");
417 #if defined (FRAME_FIND_SAVED_REGS)
418 get_frame_saved_regs (fi, &fsr);
419 /* The sp is special; what's returned isn't the save address, but
420 actually the value of the previous frame's sp. */
421 printf_filtered (" Previous frame's sp is 0x%x\n", fsr.regs[SP_REGNUM]);
423 for (i = 0; i < NUM_REGS; i++)
424 if (fsr.regs[i] && i != SP_REGNUM)
427 puts_filtered (" Saved registers:\n ");
431 printf_filtered (" %s at 0x%x", reg_names[i], fsr.regs[i]);
435 puts_filtered ("\n");
436 #endif /* Have FRAME_FIND_SAVED_REGS. */
440 /* Set a limit on the number of frames printed by default in a
443 static int backtrace_limit;
446 set_backtrace_limit_command (count_exp, from_tty)
450 int count = parse_and_eval_address (count_exp);
453 error ("Negative argument not meaningful as backtrace limit.");
455 backtrace_limit = count;
459 backtrace_limit_info (arg, from_tty)
464 error ("\"Info backtrace-limit\" takes no arguments.");
466 printf ("Backtrace limit: %d.\n", backtrace_limit);
470 /* Print briefly all stack frames or just the innermost COUNT frames. */
473 backtrace_command (count_exp, from_tty)
477 struct frame_info *fi;
479 register FRAME frame;
481 register FRAME trailing;
482 register int trailing_level;
484 if (!target_has_stack)
487 /* The following code must do two things. First, it must
488 set the variable TRAILING to the frame from which we should start
489 printing. Second, it must set the variable count to the number
490 of frames which we should print, or -1 if all of them. */
491 trailing = get_current_frame ();
495 count = parse_and_eval_address (count_exp);
503 while (current && count--)
506 current = get_prev_frame (current);
509 /* Will stop when CURRENT reaches the top of the stack. TRAILING
510 will be COUNT below it. */
514 trailing = get_prev_frame (trailing);
515 current = get_prev_frame (current);
527 struct partial_symtab *ps;
529 /* Read in symbols for all of the frames. Need to do this in
530 a separate pass so that "Reading in symbols for xxx" messages
531 don't screw up the appearance of the backtrace. Also
532 if people have strong opinions against reading symbols for
533 backtrace this may have to be an option. */
535 for (frame = trailing;
536 frame != NULL && i--;
537 frame = get_prev_frame (frame))
540 fi = get_frame_info (frame);
541 ps = find_pc_psymtab (fi->pc);
543 (void) PSYMTAB_TO_SYMTAB (ps); /* Force syms to come in */
547 for (i = 0, frame = trailing;
549 i++, frame = get_prev_frame (frame))
552 fi = get_frame_info (frame);
553 print_frame_info (fi, trailing_level + i, 0, 1);
556 /* If we've stopped before the end, mention that. */
557 if (frame && from_tty)
558 printf_filtered ("(More stack frames follow...)\n");
561 /* Print the local variables of a block B active in FRAME.
562 Return 1 if any variables were printed; 0 otherwise. */
565 print_block_frame_locals (b, frame, stream)
567 register FRAME frame;
568 register FILE *stream;
572 register struct symbol *sym;
573 register int values_printed = 0;
575 nsyms = BLOCK_NSYMS (b);
577 for (i = 0; i < nsyms; i++)
579 sym = BLOCK_SYM (b, i);
580 if (SYMBOL_CLASS (sym) == LOC_LOCAL
581 || SYMBOL_CLASS (sym) == LOC_REGISTER
582 || SYMBOL_CLASS (sym) == LOC_STATIC)
585 fprint_symbol (stream, SYMBOL_NAME (sym));
586 fputs_filtered (" = ", stream);
587 print_variable_value (sym, frame, stream);
588 fprintf_filtered (stream, "\n");
592 return values_printed;
595 /* Same, but print labels.
596 FIXME, this does not even reference FRAME... --gnu */
599 print_block_frame_labels (b, frame, have_default, stream)
601 register FRAME frame;
603 register FILE *stream;
607 register struct symbol *sym;
608 register int values_printed = 0;
610 nsyms = BLOCK_NSYMS (b);
612 for (i = 0; i < nsyms; i++)
614 sym = BLOCK_SYM (b, i);
615 if (! strcmp (SYMBOL_NAME (sym), "default"))
621 if (SYMBOL_CLASS (sym) == LOC_LABEL)
623 struct symtab_and_line sal;
624 sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
626 fputs_demangled (SYMBOL_NAME (sym), stream, 1);
628 fprintf_filtered (stream, " 0x%x", SYMBOL_VALUE_ADDRESS (sym));
629 fprintf_filtered (stream, " in file %s, line %d\n",
630 sal.symtab->filename, sal.line);
634 return values_printed;
637 /* Print on STREAM all the local variables in frame FRAME,
638 including all the blocks active in that frame
641 Returns 1 if the job was done,
642 or 0 if nothing was printed because we have no info
643 on the function running in FRAME. */
646 print_frame_local_vars (frame, stream)
647 register FRAME frame;
648 register FILE *stream;
650 register struct block *block = get_frame_block (frame);
651 register int values_printed = 0;
655 fprintf_filtered (stream, "No symbol table info available.\n");
662 if (print_block_frame_locals (block, frame, stream))
664 /* After handling the function's top-level block, stop.
665 Don't continue to its superblock, the block of
667 if (BLOCK_FUNCTION (block))
669 block = BLOCK_SUPERBLOCK (block);
674 fprintf_filtered (stream, "No locals.\n");
681 /* Same, but print labels. */
684 print_frame_label_vars (frame, this_level_only, stream)
685 register FRAME frame;
687 register FILE *stream;
689 extern struct blockvector *blockvector_for_pc ();
690 register struct blockvector *bl;
691 register struct block *block = get_frame_block (frame);
692 register int values_printed = 0;
693 int index, have_default = 0;
694 char *blocks_printed;
695 struct frame_info *fi = get_frame_info (frame);
696 CORE_ADDR pc = fi->pc;
700 fprintf_filtered (stream, "No symbol table info available.\n");
705 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
706 blocks_printed = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
707 bzero (blocks_printed, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
711 CORE_ADDR end = BLOCK_END (block) - 4;
714 if (bl != blockvector_for_pc (end, &index))
715 error ("blockvector blotch");
716 if (BLOCKVECTOR_BLOCK (bl, index) != block)
717 error ("blockvector botch");
718 last_index = BLOCKVECTOR_NBLOCKS (bl);
721 /* Don't print out blocks that have gone by. */
722 while (index < last_index
723 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
726 while (index < last_index
727 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
729 if (blocks_printed[index] == 0)
731 if (print_block_frame_labels (BLOCKVECTOR_BLOCK (bl, index), frame, &have_default, stream))
733 blocks_printed[index] = 1;
739 if (values_printed && this_level_only)
742 /* After handling the function's top-level block, stop.
743 Don't continue to its superblock, the block of
745 if (BLOCK_FUNCTION (block))
747 block = BLOCK_SUPERBLOCK (block);
750 if (!values_printed && !this_level_only)
752 fprintf_filtered (stream, "No catches.\n");
756 return values_printed;
761 locals_info (args, from_tty)
765 if (!target_has_stack)
768 print_frame_local_vars (selected_frame, stdout);
774 if (!target_has_stack)
777 print_frame_label_vars (selected_frame, 0, stdout);
781 print_frame_arg_vars (frame, stream)
782 register FRAME frame;
783 register FILE *stream;
785 struct symbol *func = get_frame_function (frame);
786 register struct block *b;
789 register struct symbol *sym, *sym2;
790 register int values_printed = 0;
794 fprintf_filtered (stream, "No symbol table info available.\n");
799 b = SYMBOL_BLOCK_VALUE (func);
800 nsyms = BLOCK_NSYMS (b);
802 for (i = 0; i < nsyms; i++)
804 sym = BLOCK_SYM (b, i);
805 if (SYMBOL_CLASS (sym) == LOC_ARG
806 || SYMBOL_CLASS (sym) == LOC_LOCAL_ARG
807 || SYMBOL_CLASS (sym) == LOC_REF_ARG
808 || SYMBOL_CLASS (sym) == LOC_REGPARM)
811 fprint_symbol (stream, SYMBOL_NAME (sym));
812 fputs_filtered (" = ", stream);
813 /* We have to look up the symbol because arguments often have
814 two entries (one a parameter, one a register) and the one
815 we want is the register, which lookup_symbol will find for
817 sym2 = lookup_symbol (SYMBOL_NAME (sym),
818 b, VAR_NAMESPACE, (int *)NULL, (struct symtab **)NULL);
819 print_variable_value (sym2, frame, stream);
820 fprintf_filtered (stream, "\n");
827 fprintf_filtered (stream, "No arguments.\n");
837 if (!target_has_stack)
839 print_frame_arg_vars (selected_frame, stdout);
842 /* Select frame FRAME, and note that its stack level is LEVEL.
843 LEVEL may be -1 if an actual level number is not known. */
846 select_frame (frame, level)
850 selected_frame = frame;
851 selected_frame_level = level;
852 /* Ensure that symbols for this frame are readin. */
854 find_pc_symtab (get_frame_info (frame)->pc);
857 /* Store the selected frame and its level into *FRAMEP and *LEVELP.
858 If there is no selected frame, *FRAMEP is set to NULL. */
861 record_selected_frame (frameaddrp, levelp)
862 FRAME_ADDR *frameaddrp;
865 *frameaddrp = selected_frame ? FRAME_FP (selected_frame) : NULL;
866 *levelp = selected_frame_level;
869 /* Return the symbol-block in which the selected frame is executing.
870 Can return zero under various legitimate circumstances. */
873 get_selected_block ()
875 if (!target_has_stack)
879 return get_current_block ();
880 return get_frame_block (selected_frame);
883 /* Find a frame a certain number of levels away from FRAME.
884 LEVEL_OFFSET_PTR points to an int containing the number of levels.
885 Positive means go to earlier frames (up); negative, the reverse.
886 The int that contains the number of levels is counted toward
887 zero as the frames for those levels are found.
888 If the top or bottom frame is reached, that frame is returned,
889 but the final value of *LEVEL_OFFSET_PTR is nonzero and indicates
890 how much farther the original request asked to go. */
893 find_relative_frame (frame, level_offset_ptr)
894 register FRAME frame;
895 register int* level_offset_ptr;
898 register FRAME frame1, frame2;
900 /* Going up is simple: just do get_prev_frame enough times
901 or until initial frame is reached. */
902 while (*level_offset_ptr > 0)
904 prev = get_prev_frame (frame);
907 (*level_offset_ptr)--;
910 /* Going down could be done by iterating get_frame_info to
911 find the next frame, but that would be quadratic
912 since get_frame_info must scan all the way from the current frame.
913 The following algorithm is linear. */
914 if (*level_offset_ptr < 0)
916 /* First put frame1 at innermost frame
917 and frame2 N levels up from there. */
918 frame1 = get_current_frame ();
920 while (*level_offset_ptr < 0 && frame2 != frame)
922 frame2 = get_prev_frame (frame2);
923 (*level_offset_ptr) ++;
925 /* Then slide frame1 and frame2 up in synchrony
926 and when frame2 reaches our starting point
927 frame1 must be N levels down from there. */
928 while (frame2 != frame)
930 frame1 = get_prev_frame (frame1);
931 frame2 = get_prev_frame (frame2);
938 /* The "frame" command. With no arg, print selected frame briefly.
939 With arg LEVEL_EXP, select the frame at level LEVEL if it is a
940 valid level. Otherwise, treat level_exp as an address expression
941 and print it. See parse_frame_specification for more info on proper
942 frame expressions. */
945 frame_command (level_exp, from_tty)
949 register FRAME frame, frame1;
950 unsigned int level = 0;
952 if (!target_has_stack)
955 frame = parse_frame_specification (level_exp);
957 for (frame1 = get_prev_frame (0);
958 frame1 && frame1 != frame;
959 frame1 = get_prev_frame (frame1))
965 select_frame (frame, level);
970 print_stack_frame (selected_frame, selected_frame_level, 1);
973 /* Select the frame up one or COUNT stack levels
974 from the previously selected frame, and print it briefly. */
978 up_silently_command (count_exp, from_tty)
982 register FRAME frame;
983 int count = 1, count1;
985 count = parse_and_eval_address (count_exp);
988 if (!target_has_stack)
991 frame = find_relative_frame (selected_frame, &count1);
992 if (count1 != 0 && count_exp == 0)
993 error ("Initial frame selected; you cannot go up.");
994 select_frame (frame, selected_frame_level + count - count1);
998 up_command (count_exp, from_tty)
1002 up_silently_command (count_exp, from_tty);
1003 print_stack_frame (selected_frame, selected_frame_level, 1);
1006 /* Select the frame down one or COUNT stack levels
1007 from the previously selected frame, and print it briefly. */
1011 down_silently_command (count_exp, from_tty)
1015 register FRAME frame;
1016 int count = -1, count1;
1018 count = - parse_and_eval_address (count_exp);
1021 frame = find_relative_frame (selected_frame, &count1);
1022 if (count1 != 0 && count_exp == 0)
1023 error ("Bottom (i.e., innermost) frame selected; you cannot go down.");
1024 select_frame (frame, selected_frame_level + count - count1);
1029 down_command (count_exp, from_tty)
1033 down_silently_command (count_exp, from_tty);
1034 print_stack_frame (selected_frame, selected_frame_level, 1);
1038 return_command (retval_exp, from_tty)
1042 struct symbol *thisfun;
1043 FRAME_ADDR selected_frame_addr;
1044 CORE_ADDR selected_frame_pc;
1047 if (selected_frame == NULL)
1048 error ("No selected frame.");
1049 thisfun = get_frame_function (selected_frame);
1050 selected_frame_addr = FRAME_FP (selected_frame);
1051 selected_frame_pc = (get_frame_info (selected_frame))->pc;
1053 /* If interactive, require confirmation. */
1059 if (!query ("Make %s return now? ", SYMBOL_NAME (thisfun)))
1060 error ("Not confirmed.");
1063 if (!query ("Make selected stack frame return now? "))
1064 error ("Not confirmed.");
1067 /* Do the real work. Pop until the specified frame is current. We
1068 use this method because the selected_frame is not valid after
1069 a POP_FRAME. The pc comparison makes this work even if the
1070 selected frame shares its fp with another frame. */
1072 while ( selected_frame_addr != FRAME_FP (frame = get_current_frame())
1073 || selected_frame_pc != (get_frame_info (frame))->pc )
1076 /* Then pop that frame. */
1080 /* Compute the return value (if any) and store in the place
1081 for return values. */
1084 set_return_value (parse_and_eval (retval_exp));
1086 /* If interactive, print the frame that is now current. */
1089 frame_command ("0", 1);
1093 _initialize_stack ()
1096 backtrace_limit = 30;
1099 add_com ("return", class_stack, return_command,
1100 "Make selected stack frame return to its caller.\n\
1101 Control remains in the debugger, but when you continue\n\
1102 execution will resume in the frame above the one now selected.\n\
1103 If an argument is given, it is an expression for the value to return.");
1105 add_com ("up", class_stack, up_command,
1106 "Select and print stack frame that called this one.\n\
1107 An argument says how many frames up to go.");
1108 add_com ("up-silently", class_support, up_silently_command,
1109 "Same as the `up' command, but does not print anything.\n\
1110 This is useful in command scripts.");
1112 add_com ("down", class_stack, down_command,
1113 "Select and print stack frame called by this one.\n\
1114 An argument says how many frames down to go.");
1115 add_com_alias ("do", "down", class_stack, 1);
1116 add_com ("down-silently", class_support, down_silently_command,
1117 "Same as the `down' command, but does not print anything.\n\
1118 This is useful in command scripts.");
1120 add_com ("frame", class_stack, frame_command,
1121 "Select and print a stack frame.\n\
1122 With no argument, print the selected stack frame. (See also \"info frame\").\n\
1123 An argument specifies the frame to select.\n\
1124 It can be a stack frame number or the address of the frame.\n\
1125 With argument, nothing is printed if input is coming from\n\
1126 a command file or a user-defined command.");
1128 add_com_alias ("f", "frame", class_stack, 1);
1130 add_com ("backtrace", class_stack, backtrace_command,
1131 "Print backtrace of all stack frames, or innermost COUNT frames.\n\
1132 With a negative argument, print outermost -COUNT frames.");
1133 add_com_alias ("bt", "backtrace", class_stack, 0);
1134 add_com_alias ("where", "backtrace", class_alias, 0);
1135 add_info ("stack", backtrace_command,
1136 "Backtrace of the stack, or innermost COUNT frames.");
1137 add_info_alias ("s", "stack", 1);
1138 add_info ("frame", frame_info,
1139 "All about selected stack frame, or frame at ADDR.");
1140 add_info_alias ("f", "frame", 1);
1141 add_info ("locals", locals_info,
1142 "Local variables of current stack frame.");
1143 add_info ("args", args_info,
1144 "Argument variables of current stack frame.");
1145 add_info ("catch", catch_info,
1146 "Exceptions that can be caught in the current stack frame.");
1149 add_cmd ("backtrace-limit", class_stack, set_backtrace_limit_command,
1150 "Specify maximum number of frames for \"backtrace\" to print by default.",
1152 add_info ("backtrace-limit", backtrace_limit_info,
1153 "The maximum number of frames for \"backtrace\" to print by default.");