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"
43 /* Prototypes for exported functions. */
45 void args_info (char *, int);
47 void locals_info (char *, int);
49 void (*selected_frame_level_changed_hook
) (int);
51 void _initialize_stack (void);
53 void return_command (char *, int);
55 /* Prototypes for local functions. */
57 static void down_command (char *, int);
59 static void down_silently_base (char *);
61 static void down_silently_command (char *, int);
63 static void up_command (char *, int);
65 static void up_silently_base (char *);
67 static void up_silently_command (char *, int);
69 void frame_command (char *, int);
71 static void current_frame_command (char *, int);
73 static void select_frame_command (char *, int);
75 static void print_frame_arg_vars (struct frame_info
*, struct ui_file
*);
77 static void catch_info (char *, int);
79 static void args_plus_locals_info (char *, int);
81 static void print_frame_label_vars (struct frame_info
*, int,
84 static void print_frame_local_vars (struct frame_info
*, int,
87 static int print_block_frame_labels (struct block
*, int *,
90 static int print_block_frame_locals (struct block
*,
95 static void print_frame (struct frame_info
*fi
,
99 struct symtab_and_line sal
);
101 static void backtrace_command (char *, int);
103 struct frame_info
*parse_frame_specification (char *);
105 static void frame_info (char *, int);
107 extern int addressprint
; /* Print addresses, or stay symbolic only? */
109 /* Zero means do things normally; we are interacting directly with the
110 user. One means print the full filename and linenumber when a
111 frame is printed, and do so in a format emacs18/emacs19.22 can
112 parse. Two means print similar annotations, but in many more
113 cases and in a slightly different syntax. */
115 int annotation_level
= 0;
118 struct print_stack_frame_args
120 struct frame_info
*fi
;
126 /* Show or print the frame arguments.
127 Pass the args the way catch_errors wants them. */
128 static int print_stack_frame_stub (void *args
);
130 print_stack_frame_stub (void *args
)
132 struct print_stack_frame_args
*p
= (struct print_stack_frame_args
*) args
;
134 print_frame_info (p
->fi
, p
->level
, p
->source
, p
->args
);
138 /* Show or print a stack frame briefly. FRAME_INFI should be the frame info
139 and LEVEL should be its level in the stack (or -1 for level not defined).
140 This prints the level, the function executing, the arguments,
141 and the file name and line number.
142 If the pc is not at the beginning of the source line,
143 the actual pc is printed at the beginning.
145 If SOURCE is 1, print the source line as well.
146 If SOURCE is -1, print ONLY the source line. */
149 print_stack_frame (struct frame_info
*fi
, int level
, int source
)
151 struct print_stack_frame_args args
;
155 args
.source
= source
;
158 catch_errors (print_stack_frame_stub
, (char *) &args
, "", RETURN_MASK_ALL
);
161 struct print_args_args
164 struct frame_info
*fi
;
165 struct ui_file
*stream
;
168 static int print_args_stub (void *);
170 /* Pass the args the way catch_errors wants them. */
173 print_args_stub (void *args
)
176 struct print_args_args
*p
= (struct print_args_args
*) args
;
178 numargs
= FRAME_NUM_ARGS (p
->fi
);
179 print_frame_args (p
->func
, p
->fi
, numargs
, p
->stream
);
183 /* Print information about a frame for frame "fi" at level "level".
184 Used in "where" output, also used to emit breakpoint or step
186 LEVEL is the level of the frame, or -1 if it is the
187 innermost frame but we don't want to print the level.
188 The meaning of the SOURCE argument is:
189 SRC_LINE: Print only source line
190 LOCATION: Print only location
191 LOC_AND_SRC: Print location and source line. */
194 print_frame_info (struct frame_info
*fi
, int level
, int source
, int args
)
196 struct symtab_and_line sal
;
200 if (get_frame_type (fi
) == DUMMY_FRAME
201 || get_frame_type (fi
) == SIGTRAMP_FRAME
)
203 struct cleanup
*uiout_cleanup
204 = make_cleanup_ui_out_tuple_begin_end (uiout
, "frame");
206 /* Do this regardless of SOURCE because we don't have any source
207 to list for this frame. */
210 ui_out_text (uiout
, "#");
211 ui_out_field_fmt_int (uiout
, 2, ui_left
, "level", level
);
213 if (ui_out_is_mi_like_p (uiout
))
215 annotate_frame_address ();
216 ui_out_field_core_addr (uiout
, "addr", fi
->pc
);
217 annotate_frame_address_end ();
220 if (get_frame_type (fi
) == DUMMY_FRAME
)
222 annotate_function_call ();
223 ui_out_field_string (uiout
, "func", "<function called from gdb>");
225 else if (get_frame_type (fi
) == SIGTRAMP_FRAME
)
227 annotate_signal_handler_caller ();
228 ui_out_field_string (uiout
, "func", "<signal handler called>");
230 ui_out_text (uiout
, "\n");
231 annotate_frame_end ();
233 do_cleanups (uiout_cleanup
);
237 /* If fi is not the innermost frame, that normally means that fi->pc
238 points to *after* the call instruction, and we want to get the
239 line containing the call, never the next line. But if the next
240 frame is a SIGTRAMP_FRAME or a DUMMY_FRAME, then the next frame
241 was not entered as the result of a call, and we want to get the
242 line containing fi->pc. */
243 find_frame_sal (fi
, &sal
);
245 location_print
= (source
== LOCATION
246 || source
== LOC_AND_ADDRESS
247 || source
== SRC_AND_LOC
);
249 if (location_print
|| !sal
.symtab
)
250 print_frame (fi
, level
, source
, args
, sal
);
252 source_print
= (source
== SRC_LINE
|| source
== SRC_AND_LOC
);
255 set_current_source_symtab_and_line (&sal
);
257 if (source_print
&& sal
.symtab
)
259 struct symtab_and_line cursal
;
261 int mid_statement
= (source
== SRC_LINE
) && (get_frame_pc (fi
) != sal
.pc
);
263 if (annotation_level
)
264 done
= identify_source_line (sal
.symtab
, sal
.line
, mid_statement
,
268 if (print_frame_info_listing_hook
)
269 print_frame_info_listing_hook (sal
.symtab
, sal
.line
, sal
.line
+ 1, 0);
272 /* We used to do this earlier, but that is clearly
273 wrong. This function is used by many different
274 parts of gdb, including normal_stop in infrun.c,
275 which uses this to print out the current PC
276 when we stepi/nexti into the middle of a source
277 line. Only the command line really wants this
278 behavior. Other UIs probably would like the
279 ability to decide for themselves if it is desired. */
280 if (addressprint
&& mid_statement
)
282 ui_out_field_core_addr (uiout
, "addr", get_frame_pc (fi
));
283 ui_out_text (uiout
, "\t");
286 print_source_lines (sal
.symtab
, sal
.line
, sal
.line
+ 1, 0);
289 /* Make sure we have at least a default source file */
290 set_default_source_symtab_and_line ();
291 cursal
= get_current_source_symtab_and_line ();
292 cursal
.line
= max (sal
.line
- get_lines_to_list () / 2, 1);
293 set_current_source_symtab_and_line (&cursal
);
297 set_default_breakpoint (1, get_frame_pc (fi
), sal
.symtab
, sal
.line
);
299 annotate_frame_end ();
301 gdb_flush (gdb_stdout
);
305 print_frame (struct frame_info
*fi
,
309 struct symtab_and_line sal
)
312 register char *funname
= 0;
313 enum language funlang
= language_unknown
;
314 struct ui_stream
*stb
;
315 struct cleanup
*old_chain
;
316 struct cleanup
*list_chain
;
318 stb
= ui_out_stream_new (uiout
);
319 old_chain
= make_cleanup_ui_out_stream_delete (stb
);
321 func
= find_pc_function (frame_address_in_block (fi
));
324 /* In certain pathological cases, the symtabs give the wrong
325 function (when we are in the first function in a file which
326 is compiled without debugging symbols, the previous function
327 is compiled with debugging symbols, and the "foo.o" symbol
328 that is supposed to tell us where the file with debugging symbols
329 ends has been truncated by ar because it is longer than 15
330 characters). This also occurs if the user uses asm() to create
331 a function but not stabs for it (in a file compiled -g).
333 So look in the minimal symbol tables as well, and if it comes
334 up with a larger address for the function use that instead.
335 I don't think this can ever cause any problems; there shouldn't
336 be any minimal symbols in the middle of a function; if this is
337 ever changed many parts of GDB will need to be changed (and we'll
338 create a find_pc_minimal_function or some such). */
340 struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (frame_address_in_block (fi
));
342 && (SYMBOL_VALUE_ADDRESS (msymbol
)
343 > BLOCK_START (SYMBOL_BLOCK_VALUE (func
))))
346 /* There is no particular reason to think the line number
347 information is wrong. Someone might have just put in
348 a label with asm() but left the line numbers alone. */
349 /* In this case we have no way of knowing the source file
350 and line number, so don't print them. */
353 /* We also don't know anything about the function besides
354 its address and name. */
356 funname
= SYMBOL_NAME (msymbol
);
357 funlang
= SYMBOL_LANGUAGE (msymbol
);
361 /* I'd like to use SYMBOL_SOURCE_NAME() here, to display the
362 demangled name that we already have stored in the symbol
363 table, but we stored a version with DMGL_PARAMS turned
364 on, and here we don't want to display parameters. So call
365 the demangler again, with DMGL_ANSI only. (Yes, I know
366 that printf_symbol_filtered() will again try to demangle
367 the name on the fly, but the issue is that if
368 cplus_demangle() fails here, it'll fail there too. So we
369 want to catch the failure ("demangled==NULL" case below)
370 here, while we still have our hands on the function
373 funname
= SYMBOL_NAME (func
);
374 funlang
= SYMBOL_LANGUAGE (func
);
375 if (funlang
== language_cplus
)
377 demangled
= cplus_demangle (funname
, DMGL_ANSI
);
378 if (demangled
== NULL
)
379 /* If the demangler fails, try the demangled name from
380 the symbol table. This'll have parameters, but
381 that's preferable to diplaying a mangled name. */
382 funname
= SYMBOL_SOURCE_NAME (func
);
388 struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (frame_address_in_block (fi
));
391 funname
= SYMBOL_NAME (msymbol
);
392 funlang
= SYMBOL_LANGUAGE (msymbol
);
396 annotate_frame_begin (level
== -1 ? 0 : level
, get_frame_pc (fi
));
398 list_chain
= make_cleanup_ui_out_tuple_begin_end (uiout
, "frame");
402 ui_out_text (uiout
, "#");
403 ui_out_field_fmt_int (uiout
, 2, ui_left
, "level", level
);
406 if (get_frame_pc (fi
) != sal
.pc
408 || source
== LOC_AND_ADDRESS
)
410 annotate_frame_address ();
411 ui_out_field_core_addr (uiout
, "addr", get_frame_pc (fi
));
412 annotate_frame_address_end ();
413 ui_out_text (uiout
, " in ");
415 annotate_frame_function_name ();
416 fprintf_symbol_filtered (stb
->stream
, funname
? funname
: "??", funlang
,
418 ui_out_field_stream (uiout
, "func", stb
);
419 ui_out_wrap_hint (uiout
, " ");
420 annotate_frame_args ();
422 ui_out_text (uiout
, " (");
425 struct print_args_args args
;
426 struct cleanup
*args_list_chain
;
429 args
.stream
= gdb_stdout
;
430 args_list_chain
= make_cleanup_ui_out_list_begin_end (uiout
, "args");
431 catch_errors (print_args_stub
, &args
, "", RETURN_MASK_ALL
);
432 /* FIXME: args must be a list. If one argument is a string it will
433 have " that will not be properly escaped. */
434 /* Invoke ui_out_tuple_end. */
435 do_cleanups (args_list_chain
);
438 ui_out_text (uiout
, ")");
439 if (sal
.symtab
&& sal
.symtab
->filename
)
441 annotate_frame_source_begin ();
442 ui_out_wrap_hint (uiout
, " ");
443 ui_out_text (uiout
, " at ");
444 annotate_frame_source_file ();
445 ui_out_field_string (uiout
, "file", sal
.symtab
->filename
);
446 annotate_frame_source_file_end ();
447 ui_out_text (uiout
, ":");
448 annotate_frame_source_line ();
449 ui_out_field_int (uiout
, "line", sal
.line
);
450 annotate_frame_source_end ();
454 if (!funname
|| (!sal
.symtab
|| !sal
.symtab
->filename
))
456 char *lib
= PC_SOLIB (get_frame_pc (fi
));
459 annotate_frame_where ();
460 ui_out_wrap_hint (uiout
, " ");
461 ui_out_text (uiout
, " from ");
462 ui_out_field_string (uiout
, "from", lib
);
465 #endif /* PC_SOLIB */
467 /* do_cleanups will call ui_out_tuple_end() for us. */
468 do_cleanups (list_chain
);
469 ui_out_text (uiout
, "\n");
470 do_cleanups (old_chain
);
473 /* Show the frame info. If this is the tui, it will be shown in
474 the source display otherwise, nothing is done */
476 show_stack_frame (struct frame_info
*fi
)
481 /* Read a frame specification in whatever the appropriate format is.
482 Call error() if the specification is in any way invalid (i.e.
483 this function never returns NULL). */
486 parse_frame_specification (char *frame_exp
)
490 CORE_ADDR args
[MAXARGS
];
495 char *addr_string
, *p
;
496 struct cleanup
*tmp_cleanup
;
498 while (*frame_exp
== ' ')
503 if (numargs
> MAXARGS
)
504 error ("Too many args in frame specification");
505 /* Parse an argument. */
506 for (p
= frame_exp
; *p
&& *p
!= ' '; p
++)
508 addr_string
= savestring (frame_exp
, p
- frame_exp
);
513 tmp_cleanup
= make_cleanup (xfree
, addr_string
);
515 /* NOTE: we call parse_and_eval and then both
516 value_as_long and value_as_address rather than calling
517 parse_and_eval_long and parse_and_eval_address because
518 of the issue of potential side effects from evaluating
520 vp
= parse_and_eval (addr_string
);
522 level
= value_as_long (vp
);
524 args
[numargs
++] = value_as_address (vp
);
525 do_cleanups (tmp_cleanup
);
528 /* Skip spaces, move to possible next arg. */
538 if (deprecated_selected_frame
== NULL
)
539 error ("No selected frame.");
540 return deprecated_selected_frame
;
544 struct frame_info
*fid
=
545 find_relative_frame (get_current_frame (), &level
);
546 struct frame_info
*tfid
;
549 /* find_relative_frame was successful */
552 /* If SETUP_ARBITRARY_FRAME is defined, then frame specifications
553 take at least 2 addresses. It is important to detect this case
554 here so that "frame 100" does not give a confusing error message
555 like "frame specification requires two addresses". This of course
556 does not solve the "frame 100" problem for machines on which
557 a frame specification can be made with one address. To solve
558 that, we need a new syntax for a specifying a frame by address.
559 I think the cleanest syntax is $frame(0x45) ($frame(0x23,0x45) for
560 two args, etc.), but people might think that is too much typing,
561 so I guess *0x23,0x45 would be a possible alternative (commas
562 really should be used instead of spaces to delimit; using spaces
563 normally works in an expression). */
564 #ifdef SETUP_ARBITRARY_FRAME
565 error ("No frame %s", paddr_d (args
[0]));
568 /* If (s)he specifies the frame with an address, he deserves what
569 (s)he gets. Still, give the highest one that matches. */
571 for (fid
= get_current_frame ();
572 fid
&& get_frame_base (fid
) != args
[0];
573 fid
= get_prev_frame (fid
))
577 while ((tfid
= get_prev_frame (fid
)) &&
578 (get_frame_base (tfid
) == args
[0]))
581 /* We couldn't identify the frame as an existing frame, but
582 perhaps we can create one with a single argument. */
586 #ifdef SETUP_ARBITRARY_FRAME
587 return SETUP_ARBITRARY_FRAME (numargs
, args
);
589 /* Usual case. Do it here rather than have everyone supply
590 a SETUP_ARBITRARY_FRAME that does this. */
592 return create_new_frame (args
[0], 0);
593 error ("Too many args in frame specification");
600 /* FRAME_ARGS_ADDRESS_CORRECT is just like FRAME_ARGS_ADDRESS except
601 that if it is unsure about the answer, it returns 0
602 instead of guessing (this happens on the VAX and i960, for example).
604 On most machines, we never have to guess about the args address,
605 so FRAME_ARGS_ADDRESS{,_CORRECT} are the same. */
606 #if !defined (FRAME_ARGS_ADDRESS_CORRECT)
607 #define FRAME_ARGS_ADDRESS_CORRECT FRAME_ARGS_ADDRESS
610 /* Print verbosely the selected frame or the frame at address ADDR.
611 This means absolutely all information in the frame is printed. */
614 frame_info (char *addr_exp
, int from_tty
)
616 struct frame_info
*fi
;
617 struct symtab_and_line sal
;
620 struct frame_info
*calling_frame_info
;
621 int i
, count
, numregs
;
623 enum language funlang
= language_unknown
;
625 if (!target_has_stack
)
628 fi
= parse_frame_specification (addr_exp
);
630 error ("Invalid frame specified.");
632 find_frame_sal (fi
, &sal
);
633 func
= get_frame_function (fi
);
634 /* FIXME: cagney/2002-11-28: Why bother? Won't sal.symtab contain
636 s
= find_pc_symtab (get_frame_pc (fi
));
639 /* I'd like to use SYMBOL_SOURCE_NAME() here, to display
640 * the demangled name that we already have stored in
641 * the symbol table, but we stored a version with
642 * DMGL_PARAMS turned on, and here we don't want
643 * to display parameters. So call the demangler again,
644 * with DMGL_ANSI only. RT
645 * (Yes, I know that printf_symbol_filtered() will
646 * again try to demangle the name on the fly, but
647 * the issue is that if cplus_demangle() fails here,
648 * it'll fail there too. So we want to catch the failure
649 * ("demangled==NULL" case below) here, while we still
650 * have our hands on the function symbol.)
653 funname
= SYMBOL_NAME (func
);
654 funlang
= SYMBOL_LANGUAGE (func
);
655 if (funlang
== language_cplus
)
657 demangled
= cplus_demangle (funname
, DMGL_ANSI
);
658 /* If the demangler fails, try the demangled name
659 * from the symbol table. This'll have parameters,
660 * but that's preferable to diplaying a mangled name.
662 if (demangled
== NULL
)
663 funname
= SYMBOL_SOURCE_NAME (func
);
668 register struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (get_frame_pc (fi
));
671 funname
= SYMBOL_NAME (msymbol
);
672 funlang
= SYMBOL_LANGUAGE (msymbol
);
675 calling_frame_info
= get_prev_frame (fi
);
677 if (!addr_exp
&& frame_relative_level (deprecated_selected_frame
) >= 0)
679 printf_filtered ("Stack level %d, frame at ",
680 frame_relative_level (deprecated_selected_frame
));
681 print_address_numeric (get_frame_base (fi
), 1, gdb_stdout
);
682 printf_filtered (":\n");
686 printf_filtered ("Stack frame at ");
687 print_address_numeric (get_frame_base (fi
), 1, gdb_stdout
);
688 printf_filtered (":\n");
690 printf_filtered (" %s = ", REGISTER_NAME (PC_REGNUM
));
691 print_address_numeric (get_frame_pc (fi
), 1, gdb_stdout
);
696 printf_filtered (" in ");
697 fprintf_symbol_filtered (gdb_stdout
, funname
, funlang
,
698 DMGL_ANSI
| DMGL_PARAMS
);
702 printf_filtered (" (%s:%d)", sal
.symtab
->filename
, sal
.line
);
703 puts_filtered ("; ");
705 printf_filtered ("saved %s ", REGISTER_NAME (PC_REGNUM
));
706 print_address_numeric (frame_pc_unwind (fi
), 1, gdb_stdout
);
707 printf_filtered ("\n");
711 frameless
= FRAMELESS_FUNCTION_INVOCATION (fi
);
713 printf_filtered (" (FRAMELESS),");
716 if (calling_frame_info
)
718 printf_filtered (" called by frame at ");
719 print_address_numeric (get_frame_base (calling_frame_info
),
722 if (get_next_frame (fi
) && calling_frame_info
)
725 if (get_next_frame (fi
))
727 printf_filtered (" caller of frame at ");
728 print_address_numeric (get_frame_base (get_next_frame (fi
)), 1,
731 if (get_next_frame (fi
) || calling_frame_info
)
732 puts_filtered ("\n");
734 printf_filtered (" source language %s.\n",
735 language_str (s
->language
));
737 #ifdef PRINT_EXTRA_FRAME_INFO
738 PRINT_EXTRA_FRAME_INFO (fi
);
742 /* Address of the argument list for this frame, or 0. */
743 CORE_ADDR arg_list
= FRAME_ARGS_ADDRESS_CORRECT (fi
);
744 /* Number of args for this frame, or -1 if unknown. */
748 printf_filtered (" Arglist at unknown address.\n");
751 printf_filtered (" Arglist at ");
752 print_address_numeric (arg_list
, 1, gdb_stdout
);
753 printf_filtered (",");
755 numargs
= FRAME_NUM_ARGS (fi
);
757 puts_filtered (" args: ");
758 else if (numargs
== 0)
759 puts_filtered (" no args.");
760 else if (numargs
== 1)
761 puts_filtered (" 1 arg: ");
763 printf_filtered (" %d args: ", numargs
);
764 print_frame_args (func
, fi
, numargs
, gdb_stdout
);
765 puts_filtered ("\n");
769 /* Address of the local variables for this frame, or 0. */
770 CORE_ADDR arg_list
= FRAME_LOCALS_ADDRESS (fi
);
773 printf_filtered (" Locals at unknown address,");
776 printf_filtered (" Locals at ");
777 print_address_numeric (arg_list
, 1, gdb_stdout
);
778 printf_filtered (",");
782 if (FRAME_INIT_SAVED_REGS_P ()
783 && get_frame_saved_regs (fi
) == NULL
)
784 FRAME_INIT_SAVED_REGS (fi
);
785 /* Print as much information as possible on the location of all the
796 /* The sp is special; what's displayed isn't the save address, but
797 the value of the previous frame's sp. This is a legacy thing,
798 at one stage the frame cached the previous frame's SP instead
799 of its address, hence it was easiest to just display the cached
803 /* Find out the location of the saved stack pointer with out
804 actually evaluating it. */
805 frame_register_unwind (fi
, SP_REGNUM
, &optimized
, &lval
, &addr
,
807 if (!optimized
&& lval
== not_lval
)
809 void *value
= alloca (MAX_REGISTER_RAW_SIZE
);
811 frame_register_unwind (fi
, SP_REGNUM
, &optimized
, &lval
, &addr
,
813 sp
= extract_address (value
, REGISTER_RAW_SIZE (SP_REGNUM
));
814 printf_filtered (" Previous frame's sp is ");
815 print_address_numeric (sp
, 1, gdb_stdout
);
816 printf_filtered ("\n");
819 else if (!optimized
&& lval
== lval_memory
)
821 printf_filtered (" Previous frame's sp at ");
822 print_address_numeric (addr
, 1, gdb_stdout
);
823 printf_filtered ("\n");
826 else if (!optimized
&& lval
== lval_register
)
828 printf_filtered (" Previous frame's sp in %s\n",
829 REGISTER_NAME (realnum
));
832 /* else keep quiet. */
836 numregs
= NUM_REGS
+ NUM_PSEUDO_REGS
;
837 for (i
= 0; i
< numregs
; i
++)
840 /* Find out the location of the saved register without
841 fetching the corresponding value. */
842 frame_register_unwind (fi
, i
, &optimized
, &lval
, &addr
, &realnum
,
844 /* For moment, only display registers that were saved on the
846 if (!optimized
&& lval
== lval_memory
)
849 puts_filtered (" Saved registers:\n ");
853 printf_filtered (" %s at ", REGISTER_NAME (i
));
854 print_address_numeric (addr
, 1, gdb_stdout
);
858 if (count
|| need_nl
)
859 puts_filtered ("\n");
864 /* Set a limit on the number of frames printed by default in a
867 static int backtrace_limit
;
870 set_backtrace_limit_command (char *count_exp
, int from_tty
)
872 int count
= parse_and_eval_long (count_exp
);
875 error ("Negative argument not meaningful as backtrace limit.");
877 backtrace_limit
= count
;
881 backtrace_limit_info (char *arg
, int from_tty
)
884 error ("\"Info backtrace-limit\" takes no arguments.");
886 printf_unfiltered ("Backtrace limit: %d.\n", backtrace_limit
);
890 /* Print briefly all stack frames or just the innermost COUNT frames. */
892 static void backtrace_command_1 (char *count_exp
, int show_locals
,
895 backtrace_command_1 (char *count_exp
, int show_locals
, int from_tty
)
897 struct frame_info
*fi
;
900 register struct frame_info
*trailing
;
901 register int trailing_level
;
903 if (!target_has_stack
)
906 /* The following code must do two things. First, it must
907 set the variable TRAILING to the frame from which we should start
908 printing. Second, it must set the variable count to the number
909 of frames which we should print, or -1 if all of them. */
910 trailing
= get_current_frame ();
912 /* The target can be in a state where there is no valid frames
913 (e.g., just connected). */
914 if (trailing
== NULL
)
920 count
= parse_and_eval_long (count_exp
);
923 struct frame_info
*current
;
928 while (current
&& count
--)
931 current
= get_prev_frame (current
);
934 /* Will stop when CURRENT reaches the top of the stack. TRAILING
935 will be COUNT below it. */
939 trailing
= get_prev_frame (trailing
);
940 current
= get_prev_frame (current
);
952 struct partial_symtab
*ps
;
954 /* Read in symbols for all of the frames. Need to do this in
955 a separate pass so that "Reading in symbols for xxx" messages
956 don't screw up the appearance of the backtrace. Also
957 if people have strong opinions against reading symbols for
958 backtrace this may have to be an option. */
962 fi
= get_prev_frame (fi
))
965 ps
= find_pc_psymtab (frame_address_in_block (fi
));
967 PSYMTAB_TO_SYMTAB (ps
); /* Force syms to come in */
971 for (i
= 0, fi
= trailing
;
973 i
++, fi
= get_prev_frame (fi
))
977 /* Don't use print_stack_frame; if an error() occurs it probably
978 means further attempts to backtrace would fail (on the other
979 hand, perhaps the code does or could be fixed to make sure
980 the frame->prev field gets set to NULL in that case). */
981 print_frame_info (fi
, trailing_level
+ i
, 0, 1);
983 print_frame_local_vars (fi
, 1, gdb_stdout
);
986 /* If we've stopped before the end, mention that. */
988 printf_filtered ("(More stack frames follow...)\n");
992 backtrace_command (char *arg
, int from_tty
)
994 struct cleanup
*old_chain
= (struct cleanup
*) NULL
;
995 char **argv
= (char **) NULL
;
996 int argIndicatingFullTrace
= (-1), totArgLen
= 0, argc
= 0;
999 if (arg
!= (char *) NULL
)
1003 argv
= buildargv (arg
);
1004 old_chain
= make_cleanup_freeargv (argv
);
1006 for (i
= 0; (argv
[i
] != (char *) NULL
); i
++)
1010 for (j
= 0; (j
< strlen (argv
[i
])); j
++)
1011 argv
[i
][j
] = tolower (argv
[i
][j
]);
1013 if (argIndicatingFullTrace
< 0 && subset_compare (argv
[i
], "full"))
1014 argIndicatingFullTrace
= argc
;
1018 totArgLen
+= strlen (argv
[i
]);
1022 if (argIndicatingFullTrace
>= 0)
1026 argPtr
= (char *) xmalloc (totArgLen
+ 1);
1031 memset (argPtr
, 0, totArgLen
+ 1);
1032 for (i
= 0; (i
< (argc
+ 1)); i
++)
1034 if (i
!= argIndicatingFullTrace
)
1036 strcat (argPtr
, argv
[i
]);
1037 strcat (argPtr
, " ");
1043 argPtr
= (char *) NULL
;
1047 backtrace_command_1 (argPtr
, (argIndicatingFullTrace
>= 0), from_tty
);
1049 if (argIndicatingFullTrace
>= 0 && totArgLen
> 0)
1053 do_cleanups (old_chain
);
1056 static void backtrace_full_command (char *arg
, int from_tty
);
1058 backtrace_full_command (char *arg
, int from_tty
)
1060 backtrace_command_1 (arg
, 1, from_tty
);
1064 /* Print the local variables of a block B active in FRAME.
1065 Return 1 if any variables were printed; 0 otherwise. */
1068 print_block_frame_locals (struct block
*b
, register struct frame_info
*fi
,
1069 int num_tabs
, register struct ui_file
*stream
)
1072 register struct symbol
*sym
;
1073 register int values_printed
= 0;
1075 ALL_BLOCK_SYMBOLS (b
, i
, sym
)
1077 switch (SYMBOL_CLASS (sym
))
1084 for (j
= 0; j
< num_tabs
; j
++)
1085 fputs_filtered ("\t", stream
);
1086 fputs_filtered (SYMBOL_SOURCE_NAME (sym
), stream
);
1087 fputs_filtered (" = ", stream
);
1088 print_variable_value (sym
, fi
, stream
);
1089 fprintf_filtered (stream
, "\n");
1093 /* Ignore symbols which are not locals. */
1097 return values_printed
;
1100 /* Same, but print labels. */
1103 print_block_frame_labels (struct block
*b
, int *have_default
,
1104 register struct ui_file
*stream
)
1107 register struct symbol
*sym
;
1108 register int values_printed
= 0;
1110 ALL_BLOCK_SYMBOLS (b
, i
, sym
)
1112 if (STREQ (SYMBOL_NAME (sym
), "default"))
1118 if (SYMBOL_CLASS (sym
) == LOC_LABEL
)
1120 struct symtab_and_line sal
;
1121 sal
= find_pc_line (SYMBOL_VALUE_ADDRESS (sym
), 0);
1123 fputs_filtered (SYMBOL_SOURCE_NAME (sym
), stream
);
1126 fprintf_filtered (stream
, " ");
1127 print_address_numeric (SYMBOL_VALUE_ADDRESS (sym
), 1, stream
);
1129 fprintf_filtered (stream
, " in file %s, line %d\n",
1130 sal
.symtab
->filename
, sal
.line
);
1133 return values_printed
;
1136 /* Print on STREAM all the local variables in frame FRAME,
1137 including all the blocks active in that frame
1140 Returns 1 if the job was done,
1141 or 0 if nothing was printed because we have no info
1142 on the function running in FRAME. */
1145 print_frame_local_vars (register struct frame_info
*fi
, register int num_tabs
,
1146 register struct ui_file
*stream
)
1148 register struct block
*block
= get_frame_block (fi
, 0);
1149 register int values_printed
= 0;
1153 fprintf_filtered (stream
, "No symbol table info available.\n");
1159 if (print_block_frame_locals (block
, fi
, num_tabs
, stream
))
1161 /* After handling the function's top-level block, stop.
1162 Don't continue to its superblock, the block of
1163 per-file symbols. */
1164 if (BLOCK_FUNCTION (block
))
1166 block
= BLOCK_SUPERBLOCK (block
);
1169 if (!values_printed
)
1171 fprintf_filtered (stream
, "No locals.\n");
1175 /* Same, but print labels. */
1178 print_frame_label_vars (register struct frame_info
*fi
, int this_level_only
,
1179 register struct ui_file
*stream
)
1181 register struct blockvector
*bl
;
1182 register struct block
*block
= get_frame_block (fi
, 0);
1183 register int values_printed
= 0;
1184 int index
, have_default
= 0;
1185 char *blocks_printed
;
1186 CORE_ADDR pc
= get_frame_pc (fi
);
1190 fprintf_filtered (stream
, "No symbol table info available.\n");
1194 bl
= blockvector_for_pc (BLOCK_END (block
) - 4, &index
);
1195 blocks_printed
= (char *) alloca (BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
1196 memset (blocks_printed
, 0, BLOCKVECTOR_NBLOCKS (bl
) * sizeof (char));
1200 CORE_ADDR end
= BLOCK_END (block
) - 4;
1203 if (bl
!= blockvector_for_pc (end
, &index
))
1204 error ("blockvector blotch");
1205 if (BLOCKVECTOR_BLOCK (bl
, index
) != block
)
1206 error ("blockvector botch");
1207 last_index
= BLOCKVECTOR_NBLOCKS (bl
);
1210 /* Don't print out blocks that have gone by. */
1211 while (index
< last_index
1212 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < pc
)
1215 while (index
< last_index
1216 && BLOCK_END (BLOCKVECTOR_BLOCK (bl
, index
)) < end
)
1218 if (blocks_printed
[index
] == 0)
1220 if (print_block_frame_labels (BLOCKVECTOR_BLOCK (bl
, index
), &have_default
, stream
))
1222 blocks_printed
[index
] = 1;
1228 if (values_printed
&& this_level_only
)
1231 /* After handling the function's top-level block, stop.
1232 Don't continue to its superblock, the block of
1233 per-file symbols. */
1234 if (BLOCK_FUNCTION (block
))
1236 block
= BLOCK_SUPERBLOCK (block
);
1239 if (!values_printed
&& !this_level_only
)
1241 fprintf_filtered (stream
, "No catches.\n");
1247 locals_info (char *args
, int from_tty
)
1249 if (!deprecated_selected_frame
)
1250 error ("No frame selected.");
1251 print_frame_local_vars (deprecated_selected_frame
, 0, gdb_stdout
);
1255 catch_info (char *ignore
, int from_tty
)
1257 struct symtab_and_line
*sal
;
1259 /* Check for target support for exception handling */
1260 sal
= target_enable_exception_callback (EX_EVENT_CATCH
, 1);
1263 /* Currently not handling this */
1264 /* Ideally, here we should interact with the C++ runtime
1265 system to find the list of active handlers, etc. */
1266 fprintf_filtered (gdb_stdout
, "Info catch not supported with this target/compiler combination.\n");
1268 if (!deprecated_selected_frame
)
1269 error ("No frame selected.");
1274 /* Assume g++ compiled code -- old v 4.16 behaviour */
1275 if (!deprecated_selected_frame
)
1276 error ("No frame selected.");
1278 print_frame_label_vars (deprecated_selected_frame
, 0, gdb_stdout
);
1283 print_frame_arg_vars (register struct frame_info
*fi
,
1284 register struct ui_file
*stream
)
1286 struct symbol
*func
= get_frame_function (fi
);
1287 register struct block
*b
;
1289 register struct symbol
*sym
, *sym2
;
1290 register int values_printed
= 0;
1294 fprintf_filtered (stream
, "No symbol table info available.\n");
1298 b
= SYMBOL_BLOCK_VALUE (func
);
1299 ALL_BLOCK_SYMBOLS (b
, i
, sym
)
1301 switch (SYMBOL_CLASS (sym
))
1307 case LOC_REGPARM_ADDR
:
1308 case LOC_BASEREG_ARG
:
1310 fputs_filtered (SYMBOL_SOURCE_NAME (sym
), stream
);
1311 fputs_filtered (" = ", stream
);
1313 /* We have to look up the symbol because arguments can have
1314 two entries (one a parameter, one a local) and the one we
1315 want is the local, which lookup_symbol will find for us.
1316 This includes gcc1 (not gcc2) on the sparc when passing a
1317 small structure and gcc2 when the argument type is float
1318 and it is passed as a double and converted to float by
1319 the prologue (in the latter case the type of the LOC_ARG
1320 symbol is double and the type of the LOC_LOCAL symbol is
1321 float). There are also LOC_ARG/LOC_REGISTER pairs which
1322 are not combined in symbol-reading. */
1324 sym2
= lookup_symbol (SYMBOL_NAME (sym
),
1325 b
, VAR_NAMESPACE
, (int *) NULL
, (struct symtab
**) NULL
);
1326 print_variable_value (sym2
, fi
, stream
);
1327 fprintf_filtered (stream
, "\n");
1331 /* Don't worry about things which aren't arguments. */
1335 if (!values_printed
)
1337 fprintf_filtered (stream
, "No arguments.\n");
1342 args_info (char *ignore
, int from_tty
)
1344 if (!deprecated_selected_frame
)
1345 error ("No frame selected.");
1346 print_frame_arg_vars (deprecated_selected_frame
, gdb_stdout
);
1351 args_plus_locals_info (char *ignore
, int from_tty
)
1353 args_info (ignore
, from_tty
);
1354 locals_info (ignore
, from_tty
);
1358 /* Select frame FI. Also print the stack frame and show the source if
1359 this is the tui version. */
1361 select_and_print_frame (struct frame_info
*fi
)
1366 print_stack_frame (fi
, frame_relative_level (fi
), 1);
1370 /* Return the symbol-block in which the selected frame is executing.
1371 Can return zero under various legitimate circumstances.
1373 If ADDR_IN_BLOCK is non-zero, set *ADDR_IN_BLOCK to the relevant
1374 code address within the block returned. We use this to decide
1375 which macros are in scope. */
1378 get_selected_block (CORE_ADDR
*addr_in_block
)
1380 if (!target_has_stack
)
1383 /* NOTE: cagney/2002-11-28: Why go to all this effort to not create
1384 a selected/current frame? Perhaphs this function is called,
1385 indirectly, by WFI in "infrun.c" where avoiding the creation of
1386 an inner most frame is very important (it slows down single
1387 step). I suspect, though that this was true in the deep dark
1388 past but is no longer the case. A mindless look at all the
1389 callers tends to support this theory. I think we should be able
1390 to assume that there is always a selcted frame. */
1391 /* gdb_assert (deprecated_selected_frame != NULL); So, do you feel
1393 if (!deprecated_selected_frame
)
1395 CORE_ADDR pc
= read_pc ();
1396 if (addr_in_block
!= NULL
)
1397 *addr_in_block
= pc
;
1398 return block_for_pc (pc
);
1400 return get_frame_block (deprecated_selected_frame
, addr_in_block
);
1403 /* Find a frame a certain number of levels away from FRAME.
1404 LEVEL_OFFSET_PTR points to an int containing the number of levels.
1405 Positive means go to earlier frames (up); negative, the reverse.
1406 The int that contains the number of levels is counted toward
1407 zero as the frames for those levels are found.
1408 If the top or bottom frame is reached, that frame is returned,
1409 but the final value of *LEVEL_OFFSET_PTR is nonzero and indicates
1410 how much farther the original request asked to go. */
1413 find_relative_frame (register struct frame_info
*frame
,
1414 register int *level_offset_ptr
)
1416 register struct frame_info
*prev
;
1417 register struct frame_info
*frame1
;
1419 /* Going up is simple: just do get_prev_frame enough times
1420 or until initial frame is reached. */
1421 while (*level_offset_ptr
> 0)
1423 prev
= get_prev_frame (frame
);
1426 (*level_offset_ptr
)--;
1429 /* Going down is just as simple. */
1430 if (*level_offset_ptr
< 0)
1432 while (*level_offset_ptr
< 0)
1434 frame1
= get_next_frame (frame
);
1438 (*level_offset_ptr
)++;
1444 /* The "select_frame" command. With no arg, NOP.
1445 With arg LEVEL_EXP, select the frame at level LEVEL if it is a
1446 valid level. Otherwise, treat level_exp as an address expression
1447 and select it. See parse_frame_specification for more info on proper
1448 frame expressions. */
1452 select_frame_command_wrapper (char *level_exp
, int from_tty
)
1454 select_frame_command (level_exp
, from_tty
);
1458 select_frame_command (char *level_exp
, int from_tty
)
1460 struct frame_info
*frame
;
1461 int level
= frame_relative_level (deprecated_selected_frame
);
1463 if (!target_has_stack
)
1464 error ("No stack.");
1466 frame
= parse_frame_specification (level_exp
);
1468 select_frame (frame
);
1469 if (level
!= frame_relative_level (deprecated_selected_frame
))
1470 selected_frame_level_changed_event (frame_relative_level (deprecated_selected_frame
));
1473 /* The "frame" command. With no arg, print selected frame briefly.
1474 With arg, behaves like select_frame and then prints the selected
1478 frame_command (char *level_exp
, int from_tty
)
1480 select_frame_command (level_exp
, from_tty
);
1481 print_stack_frame (deprecated_selected_frame
,
1482 frame_relative_level (deprecated_selected_frame
), 1);
1485 /* The XDB Compatibility command to print the current frame. */
1488 current_frame_command (char *level_exp
, int from_tty
)
1490 if (target_has_stack
== 0 || deprecated_selected_frame
== 0)
1491 error ("No stack.");
1492 print_stack_frame (deprecated_selected_frame
,
1493 frame_relative_level (deprecated_selected_frame
), 1);
1496 /* Select the frame up one or COUNT stack levels
1497 from the previously selected frame, and print it briefly. */
1501 up_silently_base (char *count_exp
)
1503 register struct frame_info
*fi
;
1504 int count
= 1, count1
;
1506 count
= parse_and_eval_long (count_exp
);
1509 if (target_has_stack
== 0 || deprecated_selected_frame
== 0)
1510 error ("No stack.");
1512 fi
= find_relative_frame (deprecated_selected_frame
, &count1
);
1513 if (count1
!= 0 && count_exp
== 0)
1514 error ("Initial frame selected; you cannot go up.");
1516 selected_frame_level_changed_event (frame_relative_level (deprecated_selected_frame
));
1520 up_silently_command (char *count_exp
, int from_tty
)
1522 up_silently_base (count_exp
);
1526 up_command (char *count_exp
, int from_tty
)
1528 up_silently_base (count_exp
);
1529 print_stack_frame (deprecated_selected_frame
,
1530 frame_relative_level (deprecated_selected_frame
), 1);
1533 /* Select the frame down one or COUNT stack levels
1534 from the previously selected frame, and print it briefly. */
1538 down_silently_base (char *count_exp
)
1540 register struct frame_info
*frame
;
1541 int count
= -1, count1
;
1543 count
= -parse_and_eval_long (count_exp
);
1546 if (target_has_stack
== 0 || deprecated_selected_frame
== 0)
1547 error ("No stack.");
1549 frame
= find_relative_frame (deprecated_selected_frame
, &count1
);
1550 if (count1
!= 0 && count_exp
== 0)
1553 /* We only do this if count_exp is not specified. That way "down"
1554 means to really go down (and let me know if that is
1555 impossible), but "down 9999" can be used to mean go all the way
1556 down without getting an error. */
1558 error ("Bottom (i.e., innermost) frame selected; you cannot go down.");
1561 select_frame (frame
);
1562 selected_frame_level_changed_event (frame_relative_level (deprecated_selected_frame
));
1567 down_silently_command (char *count_exp
, int from_tty
)
1569 down_silently_base (count_exp
);
1573 down_command (char *count_exp
, int from_tty
)
1575 down_silently_base (count_exp
);
1576 print_stack_frame (deprecated_selected_frame
,
1577 frame_relative_level (deprecated_selected_frame
), 1);
1581 return_command (char *retval_exp
, int from_tty
)
1583 struct symbol
*thisfun
;
1584 CORE_ADDR selected_frame_addr
;
1585 CORE_ADDR selected_frame_pc
;
1586 struct frame_info
*frame
;
1587 struct value
*return_value
= NULL
;
1589 if (deprecated_selected_frame
== NULL
)
1590 error ("No selected frame.");
1591 thisfun
= get_frame_function (deprecated_selected_frame
);
1592 selected_frame_addr
= get_frame_base (deprecated_selected_frame
);
1593 selected_frame_pc
= get_frame_pc (deprecated_selected_frame
);
1595 /* Compute the return value (if any -- possibly getting errors here). */
1599 struct type
*return_type
= NULL
;
1601 return_value
= parse_and_eval (retval_exp
);
1603 /* Cast return value to the return type of the function. */
1604 if (thisfun
!= NULL
)
1605 return_type
= TYPE_TARGET_TYPE (SYMBOL_TYPE (thisfun
));
1606 if (return_type
== NULL
)
1607 return_type
= builtin_type_int
;
1608 return_value
= value_cast (return_type
, return_value
);
1610 /* Make sure we have fully evaluated it, since
1611 it might live in the stack frame we're about to pop. */
1612 if (VALUE_LAZY (return_value
))
1613 value_fetch_lazy (return_value
);
1616 /* If interactive, require confirmation. */
1622 if (!query ("Make %s return now? ", SYMBOL_SOURCE_NAME (thisfun
)))
1624 error ("Not confirmed.");
1628 else if (!query ("Make selected stack frame return now? "))
1629 error ("Not confirmed.");
1632 /* FIXME: cagney/2003-01-18: Rather than pop each frame in turn,
1633 this code should just go straight to the relevant frame and pop
1636 /* Do the real work. Pop until the specified frame is current. We
1637 use this method because the deprecated_selected_frame is not valid after
1638 a POP_FRAME. The pc comparison makes this work even if the
1639 selected frame shares its fp with another frame. */
1641 while (selected_frame_addr
!= get_frame_base (frame
= get_current_frame ())
1642 || selected_frame_pc
!= get_frame_pc (frame
))
1643 frame_pop (get_current_frame ());
1645 /* Then pop that frame. */
1647 frame_pop (get_current_frame ());
1649 /* Compute the return value (if any) and store in the place
1650 for return values. */
1653 set_return_value (return_value
);
1655 /* If we are at the end of a call dummy now, pop the dummy frame too. */
1657 /* FIXME: cagney/2003-01-18: This is silly. Instead of popping all
1658 the frames except the dummy, and then, as an afterthought,
1659 popping the dummy frame, this code should just pop through to the
1662 if (CALL_DUMMY_HAS_COMPLETED (read_pc(), read_sp (),
1663 get_frame_base (get_current_frame ())))
1664 frame_pop (get_current_frame ());
1666 /* If interactive, print the frame that is now current. */
1669 frame_command ("0", 1);
1671 select_frame_command ("0", 0);
1674 /* Sets the scope to input function name, provided that the
1675 function is within the current stack frame */
1677 struct function_bounds
1679 CORE_ADDR low
, high
;
1682 static void func_command (char *arg
, int from_tty
);
1684 func_command (char *arg
, int from_tty
)
1686 struct frame_info
*fp
;
1688 struct symtabs_and_lines sals
;
1691 struct function_bounds
*func_bounds
= (struct function_bounds
*) NULL
;
1693 if (arg
!= (char *) NULL
)
1696 fp
= parse_frame_specification ("0");
1697 sals
= decode_line_spec (arg
, 1);
1698 func_bounds
= (struct function_bounds
*) xmalloc (
1699 sizeof (struct function_bounds
) * sals
.nelts
);
1700 for (i
= 0; (i
< sals
.nelts
&& !found
); i
++)
1702 if (sals
.sals
[i
].pc
== (CORE_ADDR
) 0 ||
1703 find_pc_partial_function (sals
.sals
[i
].pc
,
1705 &func_bounds
[i
].low
,
1706 &func_bounds
[i
].high
) == 0)
1708 func_bounds
[i
].low
=
1709 func_bounds
[i
].high
= (CORE_ADDR
) NULL
;
1715 for (i
= 0; (i
< sals
.nelts
&& !found
); i
++)
1716 found
= (get_frame_pc (fp
) >= func_bounds
[i
].low
&&
1717 get_frame_pc (fp
) < func_bounds
[i
].high
);
1721 fp
= find_relative_frame (fp
, &level
);
1724 while (!found
&& level
== 0);
1727 xfree (func_bounds
);
1730 printf_filtered ("'%s' not within current stack frame.\n", arg
);
1731 else if (fp
!= deprecated_selected_frame
)
1732 select_and_print_frame (fp
);
1735 /* Gets the language of the current frame. */
1738 get_frame_language (void)
1740 register struct symtab
*s
;
1741 enum language flang
; /* The language of the current frame */
1743 if (deprecated_selected_frame
)
1745 s
= find_pc_symtab (get_frame_pc (deprecated_selected_frame
));
1747 flang
= s
->language
;
1749 flang
= language_unknown
;
1752 flang
= language_unknown
;
1758 _initialize_stack (void)
1761 backtrace_limit
= 30;
1764 add_com ("return", class_stack
, return_command
,
1765 "Make selected stack frame return to its caller.\n\
1766 Control remains in the debugger, but when you continue\n\
1767 execution will resume in the frame above the one now selected.\n\
1768 If an argument is given, it is an expression for the value to return.");
1770 add_com ("up", class_stack
, up_command
,
1771 "Select and print stack frame that called this one.\n\
1772 An argument says how many frames up to go.");
1773 add_com ("up-silently", class_support
, up_silently_command
,
1774 "Same as the `up' command, but does not print anything.\n\
1775 This is useful in command scripts.");
1777 add_com ("down", class_stack
, down_command
,
1778 "Select and print stack frame called by this one.\n\
1779 An argument says how many frames down to go.");
1780 add_com_alias ("do", "down", class_stack
, 1);
1781 add_com_alias ("dow", "down", class_stack
, 1);
1782 add_com ("down-silently", class_support
, down_silently_command
,
1783 "Same as the `down' command, but does not print anything.\n\
1784 This is useful in command scripts.");
1786 add_com ("frame", class_stack
, frame_command
,
1787 "Select and print a stack frame.\n\
1788 With no argument, print the selected stack frame. (See also \"info frame\").\n\
1789 An argument specifies the frame to select.\n\
1790 It can be a stack frame number or the address of the frame.\n\
1791 With argument, nothing is printed if input is coming from\n\
1792 a command file or a user-defined command.");
1794 add_com_alias ("f", "frame", class_stack
, 1);
1798 add_com ("L", class_stack
, current_frame_command
,
1799 "Print the current stack frame.\n");
1800 add_com_alias ("V", "frame", class_stack
, 1);
1802 add_com ("select-frame", class_stack
, select_frame_command
,
1803 "Select a stack frame without printing anything.\n\
1804 An argument specifies the frame to select.\n\
1805 It can be a stack frame number or the address of the frame.\n");
1807 add_com ("backtrace", class_stack
, backtrace_command
,
1808 "Print backtrace of all stack frames, or innermost COUNT frames.\n\
1809 With a negative argument, print outermost -COUNT frames.\n\
1810 Use of the 'full' qualifier also prints the values of the local variables.\n");
1811 add_com_alias ("bt", "backtrace", class_stack
, 0);
1814 add_com_alias ("t", "backtrace", class_stack
, 0);
1815 add_com ("T", class_stack
, backtrace_full_command
,
1816 "Print backtrace of all stack frames, or innermost COUNT frames \n\
1817 and the values of the local variables.\n\
1818 With a negative argument, print outermost -COUNT frames.\n\
1819 Usage: T <count>\n");
1822 add_com_alias ("where", "backtrace", class_alias
, 0);
1823 add_info ("stack", backtrace_command
,
1824 "Backtrace of the stack, or innermost COUNT frames.");
1825 add_info_alias ("s", "stack", 1);
1826 add_info ("frame", frame_info
,
1827 "All about selected stack frame, or frame at ADDR.");
1828 add_info_alias ("f", "frame", 1);
1829 add_info ("locals", locals_info
,
1830 "Local variables of current stack frame.");
1831 add_info ("args", args_info
,
1832 "Argument variables of current stack frame.");
1834 add_com ("l", class_info
, args_plus_locals_info
,
1835 "Argument and local variables of current stack frame.");
1838 add_com ("func", class_stack
, func_command
,
1839 "Select the stack frame that contains <func>.\nUsage: func <name>\n");
1841 add_info ("catch", catch_info
,
1842 "Exceptions that can be caught in the current stack frame.");
1845 add_cmd ("backtrace-limit", class_stack
, set_backtrace_limit_command
,
1846 "Specify maximum number of frames for \"backtrace\" to print by default.",
1848 add_info ("backtrace-limit", backtrace_limit_info
,
1849 "The maximum number of frames for \"backtrace\" to print by default.");