1 /* Print and select stack frames for GDB, the GNU debugger.
2 Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program 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 2 of the License, or
9 (at your option) any later version.
11 This program 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 this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
31 #include "breakpoint.h"
33 extern int addressprint; /* Print addresses, or stay symbolic only? */
34 extern int info_verbose; /* Verbosity of symbol reading msgs */
35 extern int lines_to_list; /* # of lines "list" command shows by default */
36 extern char *reg_names[]; /* Names of registers */
38 /* Thie "selected" stack frame is used by default for local and arg access.
39 May be zero, for no selected frame. */
43 /* Level of the selected frame:
44 0 for innermost, 1 for its caller, ...
45 or -1 for frame specified by address with no defined level. */
47 int selected_frame_level;
49 /* Nonzero means print the full filename and linenumber
50 when a frame is printed, and do so in a format programs can parse. */
52 int frame_file_full_name = 0;
54 void print_frame_info ();
56 /* Print a stack frame briefly. FRAME should be the frame id
57 and LEVEL should be its level in the stack (or -1 for level not defined).
58 This prints the level, the function executing, the arguments,
59 and the file name and line number.
60 If the pc is not at the beginning of the source line,
61 the actual pc is printed at the beginning.
63 If SOURCE is 1, print the source line as well.
64 If SOURCE is -1, print ONLY the source line. */
67 print_stack_frame (frame, level, source)
72 struct frame_info *fi;
74 fi = get_frame_info (frame);
76 print_frame_info (fi, level, source, 1);
80 print_frame_info (fi, level, source, args)
81 struct frame_info *fi;
86 struct symtab_and_line sal;
88 register char *funname = 0;
91 #if 0 /* Symbol reading is fast enough now */
92 struct partial_symtab *pst;
94 /* Don't give very much information if we haven't readin the
96 pst = find_pc_psymtab (fi->pc);
97 if (pst && !pst->readin)
99 /* Abbreviated information. */
102 if (!find_pc_partial_function (fi->pc, &fname, 0))
105 printf_filtered ("#%-2d ", level);
107 printf_filtered ("%s in ", local_hex_string(fi->pc));
109 fputs_demangled (fname, stdout, -1);
110 fputs_filtered (" (...)\n", stdout);
116 sal = find_pc_line (fi->pc, fi->next_frame);
117 func = find_pc_function (fi->pc);
120 /* In certain pathological cases, the symtabs give the wrong
121 function (when we are in the first function in a file which
122 is compiled without debugging symbols, the previous function
123 is compiled with debugging symbols, and the "foo.o" symbol
124 that is supposed to tell us where the file with debugging symbols
125 ends has been truncated by ar because it is longer than 15
128 So look in the misc_function_vector as well, and if it comes
129 up with a larger address for the function use that instead.
130 I don't think this can ever cause any problems;
131 there shouldn't be any
132 misc_function_vector symbols in the middle of a function. */
133 int misc_index = find_pc_misc_function (fi->pc);
135 && (misc_function_vector[misc_index].address
136 > BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
138 /* In this case we have no way of knowing the source file
139 and line number, so don't print them. */
141 /* We also don't know anything about the function besides
142 its address and name. */
144 funname = misc_function_vector[misc_index].name;
147 funname = SYMBOL_NAME (func);
151 register int misc_index = find_pc_misc_function (fi->pc);
153 funname = misc_function_vector[misc_index].name;
156 if (source >= 0 || !sal.symtab)
159 printf_filtered ("#%-2d ", level);
161 if (fi->pc != sal.pc || !sal.symtab)
162 printf_filtered ("%s in ", local_hex_string(fi->pc));
163 fputs_demangled (funname ? funname : "??", stdout, -1);
165 fputs_filtered (" (", stdout);
168 FRAME_NUM_ARGS (numargs, fi);
169 print_frame_args (func, fi, numargs, stdout);
171 printf_filtered (")");
172 if (sal.symtab && sal.symtab->filename)
175 printf_filtered (" at %s:%d", sal.symtab->filename, sal.line);
177 printf_filtered ("\n");
180 if ((source != 0) && sal.symtab)
183 int mid_statement = source < 0 && fi->pc != sal.pc;
184 if (frame_file_full_name)
185 done = identify_source_line (sal.symtab, sal.line, mid_statement);
188 if (addressprint && mid_statement)
189 printf_filtered ("%s\t", local_hex_string(fi->pc));
190 print_source_lines (sal.symtab, sal.line, sal.line + 1, 0);
192 current_source_line = max (sal.line - lines_to_list/2, 1);
195 set_default_breakpoint (1, fi->pc, sal.symtab, sal.line);
200 void flush_cached_frames ();
202 #ifdef FRAME_SPECIFICATION_DYADIC
203 extern FRAME setup_arbitrary_frame ();
207 * Read a frame specification in whatever the appropriate format is.
208 * Call error() if the specification is in any way invalid (i.e.
209 * this function never returns NULL).
212 parse_frame_specification (frame_exp)
220 char *addr_string, *p;
221 struct cleanup *tmp_cleanup;
223 while (*frame_exp == ' ') frame_exp++;
224 for (p = frame_exp; *p && *p != ' '; p++)
230 addr_string = savestring(frame_exp, p - frame_exp);
233 tmp_cleanup = make_cleanup (free, addr_string);
234 arg1 = parse_and_eval_address (addr_string);
235 do_cleanups (tmp_cleanup);
238 while (*p == ' ') p++;
243 arg2 = parse_and_eval_address (p);
251 if (selected_frame == NULL)
252 error ("No selected frame.");
253 return selected_frame;
258 FRAME fid = find_relative_frame (get_current_frame (), &level);
262 /* find_relative_frame was successful */
265 /* If (s)he specifies the frame with an address, he deserves what
266 (s)he gets. Still, give the highest one that matches. */
268 for (fid = get_current_frame ();
269 fid && FRAME_FP (fid) != arg1;
270 fid = get_prev_frame (fid))
274 while ((tfid = get_prev_frame (fid)) &&
275 (FRAME_FP (tfid) == arg1))
278 #ifdef FRAME_SPECIFICATION_DYADIC
280 error ("Incorrect number of args in frame specification");
284 return create_new_frame (arg1, 0);
289 /* Must be addresses */
290 #ifndef FRAME_SPECIFICATION_DYADIC
291 error ("Incorrect number of args in frame specification");
293 return setup_arbitrary_frame (arg1, arg2);
297 fatal ("Internal: Error in parsing in parse_frame_specification");
301 /* FRAME_ARGS_ADDRESS_CORRECT is just like FRAME_ARGS_ADDRESS except
302 that if it is unsure about the answer, it returns 0
303 instead of guessing (this happens on the VAX and i960, for example).
305 On most machines, we never have to guess about the args address,
306 so FRAME_ARGS_ADDRESS{,_CORRECT} are the same. */
307 #if !defined (FRAME_ARGS_ADDRESS_CORRECT)
308 #define FRAME_ARGS_ADDRESS_CORRECT FRAME_ARGS_ADDRESS
311 /* Print verbosely the selected frame or the frame at address ADDR.
312 This means absolutely all information in the frame is printed. */
315 frame_info (addr_exp)
319 struct frame_info *fi;
320 struct frame_saved_regs fsr;
321 struct symtab_and_line sal;
328 if (!target_has_stack)
329 error ("No inferior or core file.");
331 frame = parse_frame_specification (addr_exp);
333 error ("Invalid frame specified.");
335 fi = get_frame_info (frame);
336 sal = find_pc_line (fi->pc, fi->next_frame);
337 func = get_frame_function (frame);
338 s = find_pc_symtab(fi->pc);
340 funname = SYMBOL_NAME (func);
343 register int misc_index = find_pc_misc_function (fi->pc);
345 funname = misc_function_vector[misc_index].name;
347 calling_frame = get_prev_frame (frame);
349 if (!addr_exp && selected_frame_level >= 0) {
350 printf_filtered ("Stack level %d, frame at %s:\n",
351 selected_frame_level,
352 local_hex_string(FRAME_FP(frame)));
354 printf_filtered ("Stack frame at %s:\n",
355 local_hex_string(FRAME_FP(frame)));
357 printf_filtered (" %s = %s",
358 reg_names[PC_REGNUM],
359 local_hex_string(fi->pc));
364 printf_filtered (" in ");
365 fputs_demangled (funname, stdout, 1);
369 printf_filtered (" (%s:%d)", sal.symtab->filename, sal.line);
370 puts_filtered ("; ");
372 printf_filtered ("saved %s %s\n", reg_names[PC_REGNUM],
373 local_hex_string(FRAME_SAVED_PC (frame)));
375 printf_filtered (" called by frame at %s",
376 local_hex_string(FRAME_FP (calling_frame)));
377 if (fi->next_frame && calling_frame)
381 printf_filtered (" caller of frame at %s", local_hex_string(fi->next_frame));
382 if (fi->next_frame || calling_frame)
383 puts_filtered ("\n");
385 printf_filtered(" source language %s.\n", language_str(s->language));
388 /* Address of the argument list for this frame, or 0. */
389 CORE_ADDR arg_list = FRAME_ARGS_ADDRESS_CORRECT (fi);
390 /* Number of args for this frame, or -1 if unknown. */
394 printf_filtered (" Arglist at unknown address.\n");
397 printf_filtered (" Arglist at %s,", local_hex_string(arg_list));
399 FRAME_NUM_ARGS (numargs, fi);
401 puts_filtered (" args: ");
402 else if (numargs == 0)
403 puts_filtered (" no args.");
404 else if (numargs == 1)
405 puts_filtered (" 1 arg: ");
407 printf_filtered (" %d args: ", numargs);
408 print_frame_args (func, fi, numargs, stdout);
409 puts_filtered ("\n");
413 #if defined (FRAME_FIND_SAVED_REGS)
414 get_frame_saved_regs (fi, &fsr);
415 /* The sp is special; what's returned isn't the save address, but
416 actually the value of the previous frame's sp. */
417 printf_filtered (" Previous frame's sp is %s\n",
418 local_hex_string(fsr.regs[SP_REGNUM]));
420 for (i = 0; i < NUM_REGS; i++)
421 if (fsr.regs[i] && i != SP_REGNUM)
424 puts_filtered (" Saved registers:\n ");
428 printf_filtered (" %s at %s", reg_names[i],
429 local_hex_string(fsr.regs[i]));
433 puts_filtered ("\n");
434 #endif /* Have FRAME_FIND_SAVED_REGS. */
438 /* Set a limit on the number of frames printed by default in a
441 static int backtrace_limit;
444 set_backtrace_limit_command (count_exp, from_tty)
448 int count = parse_and_eval_address (count_exp);
451 error ("Negative argument not meaningful as backtrace limit.");
453 backtrace_limit = count;
457 backtrace_limit_info (arg, from_tty)
462 error ("\"Info backtrace-limit\" takes no arguments.");
464 printf ("Backtrace limit: %d.\n", backtrace_limit);
468 /* Print briefly all stack frames or just the innermost COUNT frames. */
471 backtrace_command (count_exp, from_tty)
475 struct frame_info *fi;
477 register FRAME frame;
479 register FRAME trailing;
480 register int trailing_level;
482 if (!target_has_stack)
485 /* The following code must do two things. First, it must
486 set the variable TRAILING to the frame from which we should start
487 printing. Second, it must set the variable count to the number
488 of frames which we should print, or -1 if all of them. */
489 trailing = get_current_frame ();
493 count = parse_and_eval_address (count_exp);
501 while (current && count--)
504 current = get_prev_frame (current);
507 /* Will stop when CURRENT reaches the top of the stack. TRAILING
508 will be COUNT below it. */
512 trailing = get_prev_frame (trailing);
513 current = get_prev_frame (current);
525 struct partial_symtab *ps;
527 /* Read in symbols for all of the frames. Need to do this in
528 a separate pass so that "Reading in symbols for xxx" messages
529 don't screw up the appearance of the backtrace. Also
530 if people have strong opinions against reading symbols for
531 backtrace this may have to be an option. */
533 for (frame = trailing;
534 frame != NULL && i--;
535 frame = get_prev_frame (frame))
538 fi = get_frame_info (frame);
539 ps = find_pc_psymtab (fi->pc);
541 (void) PSYMTAB_TO_SYMTAB (ps); /* Force syms to come in */
545 for (i = 0, frame = trailing;
547 i++, frame = get_prev_frame (frame))
550 fi = get_frame_info (frame);
551 print_frame_info (fi, trailing_level + i, 0, 1);
554 /* If we've stopped before the end, mention that. */
555 if (frame && from_tty)
556 printf_filtered ("(More stack frames follow...)\n");
559 /* Print the local variables of a block B active in FRAME.
560 Return 1 if any variables were printed; 0 otherwise. */
563 print_block_frame_locals (b, frame, stream)
565 register FRAME frame;
566 register FILE *stream;
570 register struct symbol *sym;
571 register int values_printed = 0;
573 nsyms = BLOCK_NSYMS (b);
575 for (i = 0; i < nsyms; i++)
577 sym = BLOCK_SYM (b, i);
578 if (SYMBOL_CLASS (sym) == LOC_LOCAL
579 || SYMBOL_CLASS (sym) == LOC_REGISTER
580 || SYMBOL_CLASS (sym) == LOC_STATIC)
583 fprint_symbol (stream, SYMBOL_NAME (sym));
584 fputs_filtered (" = ", stream);
585 print_variable_value (sym, frame, stream);
586 fprintf_filtered (stream, "\n");
589 return values_printed;
592 /* Same, but print labels. */
595 print_block_frame_labels (b, have_default, stream)
598 register FILE *stream;
602 register struct symbol *sym;
603 register int values_printed = 0;
605 nsyms = BLOCK_NSYMS (b);
607 for (i = 0; i < nsyms; i++)
609 sym = BLOCK_SYM (b, i);
610 if (! strcmp (SYMBOL_NAME (sym), "default"))
616 if (SYMBOL_CLASS (sym) == LOC_LABEL)
618 struct symtab_and_line sal;
619 sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
621 fputs_demangled (SYMBOL_NAME (sym), stream, 1);
623 fprintf_filtered (stream, " %s",
624 local_hex_string(SYMBOL_VALUE_ADDRESS (sym)));
625 fprintf_filtered (stream, " in file %s, line %d\n",
626 sal.symtab->filename, sal.line);
629 return values_printed;
632 /* Print on STREAM all the local variables in frame FRAME,
633 including all the blocks active in that frame
636 Returns 1 if the job was done,
637 or 0 if nothing was printed because we have no info
638 on the function running in FRAME. */
641 print_frame_local_vars (frame, stream)
642 register FRAME frame;
643 register FILE *stream;
645 register struct block *block = get_frame_block (frame);
646 register int values_printed = 0;
650 fprintf_filtered (stream, "No symbol table info available.\n");
656 if (print_block_frame_locals (block, frame, stream))
658 /* After handling the function's top-level block, stop.
659 Don't continue to its superblock, the block of
661 if (BLOCK_FUNCTION (block))
663 block = BLOCK_SUPERBLOCK (block);
668 fprintf_filtered (stream, "No locals.\n");
672 /* Same, but print labels. */
675 print_frame_label_vars (frame, this_level_only, stream)
676 register FRAME frame;
678 register FILE *stream;
680 extern struct blockvector *blockvector_for_pc ();
681 register struct blockvector *bl;
682 register struct block *block = get_frame_block (frame);
683 register int values_printed = 0;
684 int index, have_default = 0;
685 char *blocks_printed;
686 struct frame_info *fi = get_frame_info (frame);
687 CORE_ADDR pc = fi->pc;
691 fprintf_filtered (stream, "No symbol table info available.\n");
695 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
696 blocks_printed = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
697 bzero (blocks_printed, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
701 CORE_ADDR end = BLOCK_END (block) - 4;
704 if (bl != blockvector_for_pc (end, &index))
705 error ("blockvector blotch");
706 if (BLOCKVECTOR_BLOCK (bl, index) != block)
707 error ("blockvector botch");
708 last_index = BLOCKVECTOR_NBLOCKS (bl);
711 /* Don't print out blocks that have gone by. */
712 while (index < last_index
713 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
716 while (index < last_index
717 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
719 if (blocks_printed[index] == 0)
721 if (print_block_frame_labels (BLOCKVECTOR_BLOCK (bl, index), &have_default, stream))
723 blocks_printed[index] = 1;
729 if (values_printed && this_level_only)
732 /* After handling the function's top-level block, stop.
733 Don't continue to its superblock, the block of
735 if (BLOCK_FUNCTION (block))
737 block = BLOCK_SUPERBLOCK (block);
740 if (!values_printed && !this_level_only)
742 fprintf_filtered (stream, "No catches.\n");
748 locals_info (args, from_tty)
753 error ("No frame selected.");
754 print_frame_local_vars (selected_frame, stdout);
761 error ("No frame selected.");
762 print_frame_label_vars (selected_frame, 0, stdout);
766 print_frame_arg_vars (frame, stream)
767 register FRAME frame;
768 register FILE *stream;
770 struct symbol *func = get_frame_function (frame);
771 register struct block *b;
774 register struct symbol *sym, *sym2;
775 register int values_printed = 0;
779 fprintf_filtered (stream, "No symbol table info available.\n");
783 b = SYMBOL_BLOCK_VALUE (func);
784 nsyms = BLOCK_NSYMS (b);
786 for (i = 0; i < nsyms; i++)
788 sym = BLOCK_SYM (b, i);
789 if (SYMBOL_CLASS (sym) == LOC_ARG
790 || SYMBOL_CLASS (sym) == LOC_LOCAL_ARG
791 || SYMBOL_CLASS (sym) == LOC_REF_ARG
792 || SYMBOL_CLASS (sym) == LOC_REGPARM)
795 fprint_symbol (stream, SYMBOL_NAME (sym));
796 fputs_filtered (" = ", stream);
797 /* We have to look up the symbol because arguments often have
798 two entries (one a parameter, one a register) and the one
799 we want is the register, which lookup_symbol will find for
801 sym2 = lookup_symbol (SYMBOL_NAME (sym),
802 b, VAR_NAMESPACE, (int *)NULL, (struct symtab **)NULL);
803 print_variable_value (sym2, frame, stream);
804 fprintf_filtered (stream, "\n");
810 fprintf_filtered (stream, "No arguments.\n");
818 error ("No frame selected.");
819 print_frame_arg_vars (selected_frame, stdout);
822 /* Select frame FRAME, and note that its stack level is LEVEL.
823 LEVEL may be -1 if an actual level number is not known. */
826 select_frame (frame, level)
830 register struct symtab *s;
832 selected_frame = frame;
833 selected_frame_level = level;
835 /* Ensure that symbols for this frame are read in. Also, determine the
836 source language of this frame, and switch to it if desired. */
839 s = find_pc_symtab (get_frame_info (frame)->pc);
841 && s->language != current_language->la_language
842 && s->language != language_unknown
843 && language_mode == language_mode_auto) {
844 set_language(s->language);
849 /* Store the selected frame and its level into *FRAMEP and *LEVELP.
850 If there is no selected frame, *FRAMEP is set to NULL. */
853 record_selected_frame (frameaddrp, levelp)
854 FRAME_ADDR *frameaddrp;
857 *frameaddrp = selected_frame ? FRAME_FP (selected_frame) : NULL;
858 *levelp = selected_frame_level;
861 /* Return the symbol-block in which the selected frame is executing.
862 Can return zero under various legitimate circumstances. */
865 get_selected_block ()
867 if (!target_has_stack)
871 return get_current_block ();
872 return get_frame_block (selected_frame);
875 /* Find a frame a certain number of levels away from FRAME.
876 LEVEL_OFFSET_PTR points to an int containing the number of levels.
877 Positive means go to earlier frames (up); negative, the reverse.
878 The int that contains the number of levels is counted toward
879 zero as the frames for those levels are found.
880 If the top or bottom frame is reached, that frame is returned,
881 but the final value of *LEVEL_OFFSET_PTR is nonzero and indicates
882 how much farther the original request asked to go. */
885 find_relative_frame (frame, level_offset_ptr)
886 register FRAME frame;
887 register int* level_offset_ptr;
890 register FRAME frame1;
892 /* Going up is simple: just do get_prev_frame enough times
893 or until initial frame is reached. */
894 while (*level_offset_ptr > 0)
896 prev = get_prev_frame (frame);
899 (*level_offset_ptr)--;
902 /* Going down is just as simple. */
903 if (*level_offset_ptr < 0)
905 while (*level_offset_ptr < 0) {
906 frame1 = get_next_frame (frame);
910 (*level_offset_ptr)++;
916 /* The "select_frame" command. With no arg, NOP.
917 With arg LEVEL_EXP, select the frame at level LEVEL if it is a
918 valid level. Otherwise, treat level_exp as an address expression
919 and select it. See parse_frame_specification for more info on proper
920 frame expressions. */
924 select_frame_command (level_exp, from_tty)
928 register FRAME frame, frame1;
929 unsigned int level = 0;
931 if (!target_has_stack)
934 frame = parse_frame_specification (level_exp);
936 /* Try to figure out what level this frame is. But if there is
937 no current stack, don't error out -- let the user set one. */
939 if (get_current_frame()) {
940 for (frame1 = get_prev_frame (0);
941 frame1 && frame1 != frame;
942 frame1 = get_prev_frame (frame1))
949 select_frame (frame, level);
952 /* The "frame" command. With no arg, print selected frame briefly.
953 With arg, behaves like select_frame and then prints the selected
957 frame_command (level_exp, from_tty)
961 select_frame_command (level_exp, from_tty);
962 print_stack_frame (selected_frame, selected_frame_level, 1);
965 /* Select the frame up one or COUNT stack levels
966 from the previously selected frame, and print it briefly. */
970 up_silently_command (count_exp, from_tty)
974 register FRAME frame;
975 int count = 1, count1;
977 count = parse_and_eval_address (count_exp);
980 if (!target_has_stack)
983 frame = find_relative_frame (selected_frame, &count1);
984 if (count1 != 0 && count_exp == 0)
985 error ("Initial frame selected; you cannot go up.");
986 select_frame (frame, selected_frame_level + count - count1);
990 up_command (count_exp, from_tty)
994 up_silently_command (count_exp, from_tty);
995 print_stack_frame (selected_frame, selected_frame_level, 1);
998 /* Select the frame down one or COUNT stack levels
999 from the previously selected frame, and print it briefly. */
1003 down_silently_command (count_exp, from_tty)
1007 register FRAME frame;
1008 int count = -1, count1;
1010 count = - parse_and_eval_address (count_exp);
1013 if (!target_has_stack)
1014 error ("No stack.");
1016 frame = find_relative_frame (selected_frame, &count1);
1017 if (count1 != 0 && count_exp == 0)
1018 error ("Bottom (i.e., innermost) frame selected; you cannot go down.");
1019 select_frame (frame, selected_frame_level + count - count1);
1024 down_command (count_exp, from_tty)
1028 down_silently_command (count_exp, from_tty);
1029 print_stack_frame (selected_frame, selected_frame_level, 1);
1033 return_command (retval_exp, from_tty)
1037 struct symbol *thisfun;
1038 FRAME_ADDR selected_frame_addr;
1039 CORE_ADDR selected_frame_pc;
1042 if (selected_frame == NULL)
1043 error ("No selected frame.");
1044 thisfun = get_frame_function (selected_frame);
1045 selected_frame_addr = FRAME_FP (selected_frame);
1046 selected_frame_pc = (get_frame_info (selected_frame))->pc;
1048 /* If interactive, require confirmation. */
1054 if (!query ("Make %s return now? ", SYMBOL_NAME (thisfun)))
1055 error ("Not confirmed.");
1058 if (!query ("Make selected stack frame return now? "))
1059 error ("Not confirmed.");
1062 /* Do the real work. Pop until the specified frame is current. We
1063 use this method because the selected_frame is not valid after
1064 a POP_FRAME. The pc comparison makes this work even if the
1065 selected frame shares its fp with another frame. */
1067 while ( selected_frame_addr != FRAME_FP (frame = get_current_frame())
1068 || selected_frame_pc != (get_frame_info (frame))->pc )
1071 /* Then pop that frame. */
1075 /* Compute the return value (if any) and store in the place
1076 for return values. */
1079 set_return_value (parse_and_eval (retval_exp));
1081 /* If interactive, print the frame that is now current. */
1084 frame_command ("0", 1);
1087 /* Gets the language of the current frame. */
1089 get_frame_language()
1091 register struct symtab *s;
1093 enum language flang; /* The language of the current frame */
1095 fr = get_frame_info(selected_frame);
1098 s = find_pc_symtab(fr->pc);
1100 flang = s->language;
1102 flang = language_unknown;
1105 flang = language_unknown;
1111 _initialize_stack ()
1114 backtrace_limit = 30;
1117 add_com ("return", class_stack, return_command,
1118 "Make selected stack frame return to its caller.\n\
1119 Control remains in the debugger, but when you continue\n\
1120 execution will resume in the frame above the one now selected.\n\
1121 If an argument is given, it is an expression for the value to return.");
1123 add_com ("up", class_stack, up_command,
1124 "Select and print stack frame that called this one.\n\
1125 An argument says how many frames up to go.");
1126 add_com ("up-silently", class_support, up_silently_command,
1127 "Same as the `up' command, but does not print anything.\n\
1128 This is useful in command scripts.");
1130 add_com ("down", class_stack, down_command,
1131 "Select and print stack frame called by this one.\n\
1132 An argument says how many frames down to go.");
1133 add_com_alias ("do", "down", class_stack, 1);
1134 add_com ("down-silently", class_support, down_silently_command,
1135 "Same as the `down' command, but does not print anything.\n\
1136 This is useful in command scripts.");
1138 add_com ("frame", class_stack, frame_command,
1139 "Select and print a stack frame.\n\
1140 With no argument, print the selected stack frame. (See also \"info frame\").\n\
1141 An argument specifies the frame to select.\n\
1142 It can be a stack frame number or the address of the frame.\n\
1143 With argument, nothing is printed if input is coming from\n\
1144 a command file or a user-defined command.");
1146 add_com_alias ("f", "frame", class_stack, 1);
1148 add_com ("select-frame", class_stack, select_frame_command,
1149 "Select a stack frame without printing anything.\n\
1150 An argument specifies the frame to select.\n\
1151 It can be a stack frame number or the address of the frame.\n");
1153 add_com ("backtrace", class_stack, backtrace_command,
1154 "Print backtrace of all stack frames, or innermost COUNT frames.\n\
1155 With a negative argument, print outermost -COUNT frames.");
1156 add_com_alias ("bt", "backtrace", class_stack, 0);
1157 add_com_alias ("where", "backtrace", class_alias, 0);
1158 add_info ("stack", backtrace_command,
1159 "Backtrace of the stack, or innermost COUNT frames.");
1160 add_info_alias ("s", "stack", 1);
1161 add_info ("frame", frame_info,
1162 "All about selected stack frame, or frame at ADDR.");
1163 add_info_alias ("f", "frame", 1);
1164 add_info ("locals", locals_info,
1165 "Local variables of current stack frame.");
1166 add_info ("args", args_info,
1167 "Argument variables of current stack frame.");
1168 add_info ("catch", catch_info,
1169 "Exceptions that can be caught in the current stack frame.");
1172 add_cmd ("backtrace-limit", class_stack, set_backtrace_limit_command,
1173 "Specify maximum number of frames for \"backtrace\" to print by default.",
1175 add_info ("backtrace-limit", backtrace_limit_info,
1176 "The maximum number of frames for \"backtrace\" to print by default.");