1 /* Cache and manage frames for GDB, the GNU debugger.
3 Copyright 1986, 1987, 1989, 1991, 1994, 1995, 1996, 1998, 2000,
4 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
27 #include "inferior.h" /* for inferior_ptid */
29 #include "gdb_assert.h"
30 #include "gdb_string.h"
31 #include "user-regs.h"
32 #include "gdb_obstack.h"
33 #include "dummy-frame.h"
34 #include "sentinel-frame.h"
38 #include "frame-unwind.h"
39 #include "frame-base.h"
44 #include "exceptions.h"
46 static struct frame_info *get_prev_frame_1 (struct frame_info *this_frame);
48 /* We keep a cache of stack frames, each of which is a "struct
49 frame_info". The innermost one gets allocated (in
50 wait_for_inferior) each time the inferior stops; current_frame
51 points to it. Additional frames get allocated (in get_prev_frame)
52 as needed, and are chained through the next and prev fields. Any
53 time that the frame cache becomes invalid (most notably when we
54 execute something, but also if we change how we interpret the
55 frames (e.g. "set heuristic-fence-post" in mips-tdep.c, or anything
56 which reads new symbols)), we should call reinit_frame_cache. */
60 /* Level of this frame. The inner-most (youngest) frame is at level
61 0. As you move towards the outer-most (oldest) frame, the level
62 increases. This is a cached value. It could just as easily be
63 computed by counting back from the selected frame to the inner
65 /* NOTE: cagney/2002-04-05: Perhaps a level of ``-1'' should be
66 reserved to indicate a bogus frame - one that has been created
67 just to keep GDB happy (GDB always needs a frame). For the
68 moment leave this as speculation. */
71 /* The frame's low-level unwinder and corresponding cache. The
72 low-level unwinder is responsible for unwinding register values
73 for the previous frame. The low-level unwind methods are
74 selected based on the presence, or otherwise, of register unwind
75 information such as CFI. */
77 const struct frame_unwind *unwind;
79 /* Cached copy of the previous frame's resume address. */
85 /* Cached copy of the previous frame's function address. */
92 /* This frame's ID. */
96 struct frame_id value;
99 /* The frame's high-level base methods, and corresponding cache.
100 The high level base methods are selected based on the frame's
102 const struct frame_base *base;
105 /* Pointers to the next (down, inner, younger) and previous (up,
106 outer, older) frame_info's in the frame cache. */
107 struct frame_info *next; /* down, inner, younger */
109 struct frame_info *prev; /* up, outer, older */
112 /* Flag to control debugging. */
114 static int frame_debug;
116 /* Flag to indicate whether backtraces should stop at main et.al. */
118 static int backtrace_past_main;
119 static int backtrace_past_entry;
120 static unsigned int backtrace_limit = UINT_MAX;
123 fprint_field (struct ui_file *file, const char *name, int p, CORE_ADDR addr)
126 fprintf_unfiltered (file, "%s=0x%s", name, paddr_nz (addr));
128 fprintf_unfiltered (file, "!%s", name);
132 fprint_frame_id (struct ui_file *file, struct frame_id id)
134 fprintf_unfiltered (file, "{");
135 fprint_field (file, "stack", id.stack_addr_p, id.stack_addr);
136 fprintf_unfiltered (file, ",");
137 fprint_field (file, "code", id.code_addr_p, id.code_addr);
138 fprintf_unfiltered (file, ",");
139 fprint_field (file, "special", id.special_addr_p, id.special_addr);
140 fprintf_unfiltered (file, "}");
144 fprint_frame_type (struct ui_file *file, enum frame_type type)
149 fprintf_unfiltered (file, "NORMAL_FRAME");
152 fprintf_unfiltered (file, "DUMMY_FRAME");
155 fprintf_unfiltered (file, "SIGTRAMP_FRAME");
158 fprintf_unfiltered (file, "<unknown type>");
164 fprint_frame (struct ui_file *file, struct frame_info *fi)
168 fprintf_unfiltered (file, "<NULL frame>");
171 fprintf_unfiltered (file, "{");
172 fprintf_unfiltered (file, "level=%d", fi->level);
173 fprintf_unfiltered (file, ",");
174 fprintf_unfiltered (file, "type=");
175 if (fi->unwind != NULL)
176 fprint_frame_type (file, fi->unwind->type);
178 fprintf_unfiltered (file, "<unknown>");
179 fprintf_unfiltered (file, ",");
180 fprintf_unfiltered (file, "unwind=");
181 if (fi->unwind != NULL)
182 gdb_print_host_address (fi->unwind, file);
184 fprintf_unfiltered (file, "<unknown>");
185 fprintf_unfiltered (file, ",");
186 fprintf_unfiltered (file, "pc=");
187 if (fi->next != NULL && fi->next->prev_pc.p)
188 fprintf_unfiltered (file, "0x%s", paddr_nz (fi->next->prev_pc.value));
190 fprintf_unfiltered (file, "<unknown>");
191 fprintf_unfiltered (file, ",");
192 fprintf_unfiltered (file, "id=");
194 fprint_frame_id (file, fi->this_id.value);
196 fprintf_unfiltered (file, "<unknown>");
197 fprintf_unfiltered (file, ",");
198 fprintf_unfiltered (file, "func=");
199 if (fi->next != NULL && fi->next->prev_func.p)
200 fprintf_unfiltered (file, "0x%s", paddr_nz (fi->next->prev_func.addr));
202 fprintf_unfiltered (file, "<unknown>");
203 fprintf_unfiltered (file, "}");
206 /* Return a frame uniq ID that can be used to, later, re-find the
210 get_frame_id (struct frame_info *fi)
214 return null_frame_id;
219 fprintf_unfiltered (gdb_stdlog, "{ get_frame_id (fi=%d) ",
221 /* Find the unwinder. */
222 if (fi->unwind == NULL)
223 fi->unwind = frame_unwind_find_by_frame (fi->next,
224 &fi->prologue_cache);
225 /* Find THIS frame's ID. */
226 fi->unwind->this_id (fi->next, &fi->prologue_cache, &fi->this_id.value);
230 fprintf_unfiltered (gdb_stdlog, "-> ");
231 fprint_frame_id (gdb_stdlog, fi->this_id.value);
232 fprintf_unfiltered (gdb_stdlog, " }\n");
235 return fi->this_id.value;
239 frame_unwind_id (struct frame_info *next_frame)
241 /* Use prev_frame, and not get_prev_frame. The latter will truncate
242 the frame chain, leading to this function unintentionally
243 returning a null_frame_id (e.g., when a caller requests the frame
244 ID of "main()"s caller. */
245 return get_frame_id (get_prev_frame_1 (next_frame));
248 const struct frame_id null_frame_id; /* All zeros. */
251 frame_id_build_special (CORE_ADDR stack_addr, CORE_ADDR code_addr,
252 CORE_ADDR special_addr)
254 struct frame_id id = null_frame_id;
255 id.stack_addr = stack_addr;
257 id.code_addr = code_addr;
259 id.special_addr = special_addr;
260 id.special_addr_p = 1;
265 frame_id_build (CORE_ADDR stack_addr, CORE_ADDR code_addr)
267 struct frame_id id = null_frame_id;
268 id.stack_addr = stack_addr;
270 id.code_addr = code_addr;
276 frame_id_build_wild (CORE_ADDR stack_addr)
278 struct frame_id id = null_frame_id;
279 id.stack_addr = stack_addr;
285 frame_id_p (struct frame_id l)
288 /* The frame is valid iff it has a valid stack address. */
292 fprintf_unfiltered (gdb_stdlog, "{ frame_id_p (l=");
293 fprint_frame_id (gdb_stdlog, l);
294 fprintf_unfiltered (gdb_stdlog, ") -> %d }\n", p);
300 frame_id_eq (struct frame_id l, struct frame_id r)
303 if (!l.stack_addr_p || !r.stack_addr_p)
304 /* Like a NaN, if either ID is invalid, the result is false.
305 Note that a frame ID is invalid iff it is the null frame ID. */
307 else if (l.stack_addr != r.stack_addr)
308 /* If .stack addresses are different, the frames are different. */
310 else if (!l.code_addr_p || !r.code_addr_p)
311 /* An invalid code addr is a wild card, always succeed. */
313 else if (l.code_addr != r.code_addr)
314 /* If .code addresses are different, the frames are different. */
316 else if (!l.special_addr_p || !r.special_addr_p)
317 /* An invalid special addr is a wild card (or unused), always succeed. */
319 else if (l.special_addr == r.special_addr)
320 /* Frames are equal. */
327 fprintf_unfiltered (gdb_stdlog, "{ frame_id_eq (l=");
328 fprint_frame_id (gdb_stdlog, l);
329 fprintf_unfiltered (gdb_stdlog, ",r=");
330 fprint_frame_id (gdb_stdlog, r);
331 fprintf_unfiltered (gdb_stdlog, ") -> %d }\n", eq);
337 frame_id_inner (struct frame_id l, struct frame_id r)
340 if (!l.stack_addr_p || !r.stack_addr_p)
341 /* Like NaN, any operation involving an invalid ID always fails. */
344 /* Only return non-zero when strictly inner than. Note that, per
345 comment in "frame.h", there is some fuzz here. Frameless
346 functions are not strictly inner than (same .stack but
347 different .code and/or .special address). */
348 inner = INNER_THAN (l.stack_addr, r.stack_addr);
351 fprintf_unfiltered (gdb_stdlog, "{ frame_id_inner (l=");
352 fprint_frame_id (gdb_stdlog, l);
353 fprintf_unfiltered (gdb_stdlog, ",r=");
354 fprint_frame_id (gdb_stdlog, r);
355 fprintf_unfiltered (gdb_stdlog, ") -> %d }\n", inner);
361 frame_find_by_id (struct frame_id id)
363 struct frame_info *frame;
365 /* ZERO denotes the null frame, let the caller decide what to do
366 about it. Should it instead return get_current_frame()? */
367 if (!frame_id_p (id))
370 for (frame = get_current_frame ();
372 frame = get_prev_frame (frame))
374 struct frame_id this = get_frame_id (frame);
375 if (frame_id_eq (id, this))
376 /* An exact match. */
378 if (frame_id_inner (id, this))
381 /* Either we're not yet gone far enough out along the frame
382 chain (inner(this,id)), or we're comparing frameless functions
383 (same .base, different .func, no test available). Struggle
384 on until we've definitly gone to far. */
390 frame_pc_unwind (struct frame_info *this_frame)
392 if (!this_frame->prev_pc.p)
395 if (this_frame->unwind == NULL)
397 = frame_unwind_find_by_frame (this_frame->next,
398 &this_frame->prologue_cache);
399 if (this_frame->unwind->prev_pc != NULL)
400 /* A per-frame unwinder, prefer it. */
401 pc = this_frame->unwind->prev_pc (this_frame->next,
402 &this_frame->prologue_cache);
403 else if (gdbarch_unwind_pc_p (current_gdbarch))
405 /* The right way. The `pure' way. The one true way. This
406 method depends solely on the register-unwind code to
407 determine the value of registers in THIS frame, and hence
408 the value of this frame's PC (resume address). A typical
409 implementation is no more than:
411 frame_unwind_register (this_frame, ISA_PC_REGNUM, buf);
412 return extract_unsigned_integer (buf, size of ISA_PC_REGNUM);
414 Note: this method is very heavily dependent on a correct
415 register-unwind implementation, it pays to fix that
416 method first; this method is frame type agnostic, since
417 it only deals with register values, it works with any
418 frame. This is all in stark contrast to the old
419 FRAME_SAVED_PC which would try to directly handle all the
420 different ways that a PC could be unwound. */
421 pc = gdbarch_unwind_pc (current_gdbarch, this_frame);
424 internal_error (__FILE__, __LINE__, "No unwind_pc method");
425 this_frame->prev_pc.value = pc;
426 this_frame->prev_pc.p = 1;
428 fprintf_unfiltered (gdb_stdlog,
429 "{ frame_pc_unwind (this_frame=%d) -> 0x%s }\n",
431 paddr_nz (this_frame->prev_pc.value));
433 return this_frame->prev_pc.value;
437 frame_func_unwind (struct frame_info *fi)
439 if (!fi->prev_func.p)
441 /* Make certain that this, and not the adjacent, function is
443 CORE_ADDR addr_in_block = frame_unwind_address_in_block (fi);
445 fi->prev_func.addr = get_pc_function_start (addr_in_block);
447 fprintf_unfiltered (gdb_stdlog,
448 "{ frame_func_unwind (fi=%d) -> 0x%s }\n",
449 fi->level, paddr_nz (fi->prev_func.addr));
451 return fi->prev_func.addr;
455 get_frame_func (struct frame_info *fi)
457 return frame_func_unwind (fi->next);
461 do_frame_register_read (void *src, int regnum, void *buf)
463 frame_register_read (src, regnum, buf);
468 frame_save_as_regcache (struct frame_info *this_frame)
470 struct regcache *regcache = regcache_xmalloc (current_gdbarch);
471 struct cleanup *cleanups = make_cleanup_regcache_xfree (regcache);
472 regcache_save (regcache, do_frame_register_read, this_frame);
473 discard_cleanups (cleanups);
478 frame_pop (struct frame_info *this_frame)
480 /* Make a copy of all the register values unwound from this frame.
481 Save them in a scratch buffer so that there isn't a race between
482 trying to extract the old values from the current_regcache while
483 at the same time writing new values into that same cache. */
484 struct regcache *scratch
485 = frame_save_as_regcache (get_prev_frame_1 (this_frame));
486 struct cleanup *cleanups = make_cleanup_regcache_xfree (scratch);
488 /* FIXME: cagney/2003-03-16: It should be possible to tell the
489 target's register cache that it is about to be hit with a burst
490 register transfer and that the sequence of register writes should
491 be batched. The pair target_prepare_to_store() and
492 target_store_registers() kind of suggest this functionality.
493 Unfortunately, they don't implement it. Their lack of a formal
494 definition can lead to targets writing back bogus values
495 (arguably a bug in the target code mind). */
496 /* Now copy those saved registers into the current regcache.
497 Here, regcache_cpy() calls regcache_restore(). */
498 regcache_cpy (current_regcache, scratch);
499 do_cleanups (cleanups);
501 /* We've made right mess of GDB's local state, just discard
503 flush_cached_frames ();
507 frame_register_unwind (struct frame_info *frame, int regnum,
508 int *optimizedp, enum lval_type *lvalp,
509 CORE_ADDR *addrp, int *realnump, void *bufferp)
511 struct frame_unwind_cache *cache;
515 fprintf_unfiltered (gdb_stdlog, "\
516 { frame_register_unwind (frame=%d,regnum=%d(%s),...) ",
517 frame->level, regnum,
518 frame_map_regnum_to_name (frame, regnum));
521 /* Require all but BUFFERP to be valid. A NULL BUFFERP indicates
522 that the value proper does not need to be fetched. */
523 gdb_assert (optimizedp != NULL);
524 gdb_assert (lvalp != NULL);
525 gdb_assert (addrp != NULL);
526 gdb_assert (realnump != NULL);
527 /* gdb_assert (bufferp != NULL); */
529 /* NOTE: cagney/2002-11-27: A program trying to unwind a NULL frame
530 is broken. There is always a frame. If there, for some reason,
531 isn't a frame, there is some pretty busted code as it should have
532 detected the problem before calling here. */
533 gdb_assert (frame != NULL);
535 /* Find the unwinder. */
536 if (frame->unwind == NULL)
537 frame->unwind = frame_unwind_find_by_frame (frame->next,
538 &frame->prologue_cache);
540 /* Ask this frame to unwind its register. See comment in
541 "frame-unwind.h" for why NEXT frame and this unwind cache are
543 frame->unwind->prev_register (frame->next, &frame->prologue_cache, regnum,
544 optimizedp, lvalp, addrp, realnump, bufferp);
548 fprintf_unfiltered (gdb_stdlog, "->");
549 fprintf_unfiltered (gdb_stdlog, " *optimizedp=%d", (*optimizedp));
550 fprintf_unfiltered (gdb_stdlog, " *lvalp=%d", (int) (*lvalp));
551 fprintf_unfiltered (gdb_stdlog, " *addrp=0x%s", paddr_nz ((*addrp)));
552 fprintf_unfiltered (gdb_stdlog, " *bufferp=");
554 fprintf_unfiltered (gdb_stdlog, "<NULL>");
558 const unsigned char *buf = bufferp;
559 fprintf_unfiltered (gdb_stdlog, "[");
560 for (i = 0; i < register_size (current_gdbarch, regnum); i++)
561 fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]);
562 fprintf_unfiltered (gdb_stdlog, "]");
564 fprintf_unfiltered (gdb_stdlog, " }\n");
569 frame_register (struct frame_info *frame, int regnum,
570 int *optimizedp, enum lval_type *lvalp,
571 CORE_ADDR *addrp, int *realnump, void *bufferp)
573 /* Require all but BUFFERP to be valid. A NULL BUFFERP indicates
574 that the value proper does not need to be fetched. */
575 gdb_assert (optimizedp != NULL);
576 gdb_assert (lvalp != NULL);
577 gdb_assert (addrp != NULL);
578 gdb_assert (realnump != NULL);
579 /* gdb_assert (bufferp != NULL); */
581 /* Obtain the register value by unwinding the register from the next
582 (more inner frame). */
583 gdb_assert (frame != NULL && frame->next != NULL);
584 frame_register_unwind (frame->next, regnum, optimizedp, lvalp, addrp,
589 frame_unwind_register (struct frame_info *frame, int regnum, void *buf)
595 frame_register_unwind (frame, regnum, &optimized, &lval, &addr,
600 get_frame_register (struct frame_info *frame,
601 int regnum, void *buf)
603 frame_unwind_register (frame->next, regnum, buf);
607 frame_unwind_register_signed (struct frame_info *frame, int regnum)
609 char buf[MAX_REGISTER_SIZE];
610 frame_unwind_register (frame, regnum, buf);
611 return extract_signed_integer (buf, register_size (get_frame_arch (frame),
616 get_frame_register_signed (struct frame_info *frame, int regnum)
618 return frame_unwind_register_signed (frame->next, regnum);
622 frame_unwind_register_unsigned (struct frame_info *frame, int regnum)
624 char buf[MAX_REGISTER_SIZE];
625 frame_unwind_register (frame, regnum, buf);
626 return extract_unsigned_integer (buf, register_size (get_frame_arch (frame),
631 get_frame_register_unsigned (struct frame_info *frame, int regnum)
633 return frame_unwind_register_unsigned (frame->next, regnum);
637 frame_unwind_unsigned_register (struct frame_info *frame, int regnum,
640 char buf[MAX_REGISTER_SIZE];
641 frame_unwind_register (frame, regnum, buf);
642 (*val) = extract_unsigned_integer (buf,
643 register_size (get_frame_arch (frame),
648 put_frame_register (struct frame_info *frame, int regnum, const void *buf)
650 struct gdbarch *gdbarch = get_frame_arch (frame);
655 frame_register (frame, regnum, &optim, &lval, &addr, &realnum, NULL);
657 error ("Attempt to assign to a value that was optimized out.");
662 /* FIXME: write_memory doesn't yet take constant buffers.
664 char tmp[MAX_REGISTER_SIZE];
665 memcpy (tmp, buf, register_size (gdbarch, regnum));
666 write_memory (addr, tmp, register_size (gdbarch, regnum));
670 regcache_cooked_write (current_regcache, realnum, buf);
673 error ("Attempt to assign to an unmodifiable value.");
677 /* frame_register_read ()
679 Find and return the value of REGNUM for the specified stack frame.
680 The number of bytes copied is REGISTER_SIZE (REGNUM).
682 Returns 0 if the register value could not be found. */
685 frame_register_read (struct frame_info *frame, int regnum, void *myaddr)
691 frame_register (frame, regnum, &optimized, &lval, &addr, &realnum, myaddr);
693 /* FIXME: cagney/2002-05-15: This test is just bogus.
695 It indicates that the target failed to supply a value for a
696 register because it was "not available" at this time. Problem
697 is, the target still has the register and so get saved_register()
698 may be returning a value saved on the stack. */
700 if (register_cached (regnum) < 0)
701 return 0; /* register value not available */
707 /* Map between a frame register number and its name. A frame register
708 space is a superset of the cooked register space --- it also
709 includes builtin registers. */
712 frame_map_name_to_regnum (struct frame_info *frame, const char *name, int len)
714 return user_reg_map_name_to_regnum (get_frame_arch (frame), name, len);
718 frame_map_regnum_to_name (struct frame_info *frame, int regnum)
720 return user_reg_map_regnum_to_name (get_frame_arch (frame), regnum);
723 /* Create a sentinel frame. */
725 static struct frame_info *
726 create_sentinel_frame (struct regcache *regcache)
728 struct frame_info *frame = FRAME_OBSTACK_ZALLOC (struct frame_info);
730 /* Explicitly initialize the sentinel frame's cache. Provide it
731 with the underlying regcache. In the future additional
732 information, such as the frame's thread will be added. */
733 frame->prologue_cache = sentinel_frame_cache (regcache);
734 /* For the moment there is only one sentinel frame implementation. */
735 frame->unwind = sentinel_frame_unwind;
736 /* Link this frame back to itself. The frame is self referential
737 (the unwound PC is the same as the pc), so make it so. */
739 /* Make the sentinel frame's ID valid, but invalid. That way all
740 comparisons with it should fail. */
741 frame->this_id.p = 1;
742 frame->this_id.value = null_frame_id;
745 fprintf_unfiltered (gdb_stdlog, "{ create_sentinel_frame (...) -> ");
746 fprint_frame (gdb_stdlog, frame);
747 fprintf_unfiltered (gdb_stdlog, " }\n");
752 /* Info about the innermost stack frame (contents of FP register) */
754 static struct frame_info *current_frame;
756 /* Cache for frame addresses already read by gdb. Valid only while
757 inferior is stopped. Control variables for the frame cache should
758 be local to this module. */
760 static struct obstack frame_cache_obstack;
763 frame_obstack_zalloc (unsigned long size)
765 void *data = obstack_alloc (&frame_cache_obstack, size);
766 memset (data, 0, size);
770 /* Return the innermost (currently executing) stack frame. This is
771 split into two functions. The function unwind_to_current_frame()
772 is wrapped in catch exceptions so that, even when the unwind of the
773 sentinel frame fails, the function still returns a stack frame. */
776 unwind_to_current_frame (struct ui_out *ui_out, void *args)
778 struct frame_info *frame = get_prev_frame (args);
779 /* A sentinel frame can fail to unwind, e.g., because its PC value
780 lands in somewhere like start. */
783 current_frame = frame;
788 get_current_frame (void)
790 /* First check, and report, the lack of registers. Having GDB
791 report "No stack!" or "No memory" when the target doesn't even
792 have registers is very confusing. Besides, "printcmd.exp"
793 explicitly checks that ``print $pc'' with no registers prints "No
795 if (!target_has_registers)
796 error ("No registers.");
797 if (!target_has_stack)
799 if (!target_has_memory)
800 error ("No memory.");
801 if (current_frame == NULL)
803 struct frame_info *sentinel_frame =
804 create_sentinel_frame (current_regcache);
805 if (catch_exceptions (uiout, unwind_to_current_frame, sentinel_frame,
806 NULL, RETURN_MASK_ERROR) != 0)
808 /* Oops! Fake a current frame? Is this useful? It has a PC
809 of zero, for instance. */
810 current_frame = sentinel_frame;
813 return current_frame;
816 /* The "selected" stack frame is used by default for local and arg
817 access. May be zero, for no selected frame. */
819 struct frame_info *deprecated_selected_frame;
821 /* Return the selected frame. Always non-NULL (unless there isn't an
822 inferior sufficient for creating a frame) in which case an error is
826 get_selected_frame (const char *message)
828 if (deprecated_selected_frame == NULL)
830 if (message != NULL && (!target_has_registers
832 || !target_has_memory))
833 error ("%s", message);
834 /* Hey! Don't trust this. It should really be re-finding the
835 last selected frame of the currently selected thread. This,
836 though, is better than nothing. */
837 select_frame (get_current_frame ());
839 /* There is always a frame. */
840 gdb_assert (deprecated_selected_frame != NULL);
841 return deprecated_selected_frame;
844 /* This is a variant of get_selected_frame() which can be called when
845 the inferior does not have a frame; in that case it will return
846 NULL instead of calling error(). */
849 deprecated_safe_get_selected_frame (void)
851 if (!target_has_registers || !target_has_stack || !target_has_memory)
853 return get_selected_frame (NULL);
856 /* Select frame FI (or NULL - to invalidate the current frame). */
859 select_frame (struct frame_info *fi)
863 deprecated_selected_frame = fi;
864 /* NOTE: cagney/2002-05-04: FI can be NULL. This occurs when the
865 frame is being invalidated. */
866 if (deprecated_selected_frame_level_changed_hook)
867 deprecated_selected_frame_level_changed_hook (frame_relative_level (fi));
869 /* FIXME: kseitz/2002-08-28: It would be nice to call
870 selected_frame_level_changed_event() right here, but due to limitations
871 in the current interfaces, we would end up flooding UIs with events
872 because select_frame() is used extensively internally.
874 Once we have frame-parameterized frame (and frame-related) commands,
875 the event notification can be moved here, since this function will only
876 be called when the user's selected frame is being changed. */
878 /* Ensure that symbols for this frame are read in. Also, determine the
879 source language of this frame, and switch to it if desired. */
882 /* We retrieve the frame's symtab by using the frame PC. However
883 we cannot use the frame PC as-is, because it usually points to
884 the instruction following the "call", which is sometimes the
885 first instruction of another function. So we rely on
886 get_frame_address_in_block() which provides us with a PC which
887 is guaranteed to be inside the frame's code block. */
888 s = find_pc_symtab (get_frame_address_in_block (fi));
890 && s->language != current_language->la_language
891 && s->language != language_unknown
892 && language_mode == language_mode_auto)
894 set_language (s->language);
899 /* Create an arbitrary (i.e. address specified by user) or innermost frame.
900 Always returns a non-NULL value. */
903 create_new_frame (CORE_ADDR addr, CORE_ADDR pc)
905 struct frame_info *fi;
909 fprintf_unfiltered (gdb_stdlog,
910 "{ create_new_frame (addr=0x%s, pc=0x%s) ",
911 paddr_nz (addr), paddr_nz (pc));
914 fi = frame_obstack_zalloc (sizeof (struct frame_info));
916 fi->next = create_sentinel_frame (current_regcache);
918 /* Select/initialize both the unwind function and the frame's type
920 fi->unwind = frame_unwind_find_by_frame (fi->next, &fi->prologue_cache);
923 deprecated_update_frame_base_hack (fi, addr);
924 deprecated_update_frame_pc_hack (fi, pc);
928 fprintf_unfiltered (gdb_stdlog, "-> ");
929 fprint_frame (gdb_stdlog, fi);
930 fprintf_unfiltered (gdb_stdlog, " }\n");
936 /* Return the frame that THIS_FRAME calls (NULL if THIS_FRAME is the
937 innermost frame). Be careful to not fall off the bottom of the
938 frame chain and onto the sentinel frame. */
941 get_next_frame (struct frame_info *this_frame)
943 if (this_frame->level > 0)
944 return this_frame->next;
949 /* Observer for the target_changed event. */
952 frame_observer_target_changed (struct target_ops *target)
954 flush_cached_frames ();
957 /* Flush the entire frame cache. */
960 flush_cached_frames (void)
962 /* Since we can't really be sure what the first object allocated was */
963 obstack_free (&frame_cache_obstack, 0);
964 obstack_init (&frame_cache_obstack);
966 current_frame = NULL; /* Invalidate cache */
968 annotate_frames_invalid ();
970 fprintf_unfiltered (gdb_stdlog, "{ flush_cached_frames () }\n");
973 /* Flush the frame cache, and start a new one if necessary. */
976 reinit_frame_cache (void)
978 flush_cached_frames ();
980 /* FIXME: The inferior_ptid test is wrong if there is a corefile. */
981 if (PIDGET (inferior_ptid) != 0)
983 select_frame (get_current_frame ());
987 /* Return a "struct frame_info" corresponding to the frame that called
988 THIS_FRAME. Returns NULL if there is no such frame.
990 Unlike get_prev_frame, this function always tries to unwind the
993 static struct frame_info *
994 get_prev_frame_1 (struct frame_info *this_frame)
996 struct frame_info *prev_frame;
997 struct frame_id this_id;
999 gdb_assert (this_frame != NULL);
1003 fprintf_unfiltered (gdb_stdlog, "{ get_prev_frame_1 (this_frame=");
1004 if (this_frame != NULL)
1005 fprintf_unfiltered (gdb_stdlog, "%d", this_frame->level);
1007 fprintf_unfiltered (gdb_stdlog, "<NULL>");
1008 fprintf_unfiltered (gdb_stdlog, ") ");
1011 /* Only try to do the unwind once. */
1012 if (this_frame->prev_p)
1016 fprintf_unfiltered (gdb_stdlog, "-> ");
1017 fprint_frame (gdb_stdlog, this_frame->prev);
1018 fprintf_unfiltered (gdb_stdlog, " // cached \n");
1020 return this_frame->prev;
1022 this_frame->prev_p = 1;
1024 /* Check that this frame's ID was valid. If it wasn't, don't try to
1025 unwind to the prev frame. Be careful to not apply this test to
1026 the sentinel frame. */
1027 this_id = get_frame_id (this_frame);
1028 if (this_frame->level >= 0 && !frame_id_p (this_id))
1032 fprintf_unfiltered (gdb_stdlog, "-> ");
1033 fprint_frame (gdb_stdlog, NULL);
1034 fprintf_unfiltered (gdb_stdlog, " // this ID is NULL }\n");
1039 /* Check that this frame's ID isn't inner to (younger, below, next)
1040 the next frame. This happens when a frame unwind goes backwards.
1041 Exclude signal trampolines (due to sigaltstack the frame ID can
1042 go backwards) and sentinel frames (the test is meaningless). */
1043 if (this_frame->next->level >= 0
1044 && this_frame->next->unwind->type != SIGTRAMP_FRAME
1045 && frame_id_inner (this_id, get_frame_id (this_frame->next)))
1046 error ("Previous frame inner to this frame (corrupt stack?)");
1048 /* Check that this and the next frame are not identical. If they
1049 are, there is most likely a stack cycle. As with the inner-than
1050 test above, avoid comparing the inner-most and sentinel frames. */
1051 if (this_frame->level > 0
1052 && frame_id_eq (this_id, get_frame_id (this_frame->next)))
1053 error ("Previous frame identical to this frame (corrupt stack?)");
1055 /* Allocate the new frame but do not wire it in to the frame chain.
1056 Some (bad) code in INIT_FRAME_EXTRA_INFO tries to look along
1057 frame->next to pull some fancy tricks (of course such code is, by
1058 definition, recursive). Try to prevent it.
1060 There is no reason to worry about memory leaks, should the
1061 remainder of the function fail. The allocated memory will be
1062 quickly reclaimed when the frame cache is flushed, and the `we've
1063 been here before' check above will stop repeated memory
1064 allocation calls. */
1065 prev_frame = FRAME_OBSTACK_ZALLOC (struct frame_info);
1066 prev_frame->level = this_frame->level + 1;
1068 /* Don't yet compute ->unwind (and hence ->type). It is computed
1069 on-demand in get_frame_type, frame_register_unwind, and
1072 /* Don't yet compute the frame's ID. It is computed on-demand by
1075 /* The unwound frame ID is validate at the start of this function,
1076 as part of the logic to decide if that frame should be further
1077 unwound, and not here while the prev frame is being created.
1078 Doing this makes it possible for the user to examine a frame that
1079 has an invalid frame ID.
1081 Some very old VAX code noted: [...] For the sake of argument,
1082 suppose that the stack is somewhat trashed (which is one reason
1083 that "info frame" exists). So, return 0 (indicating we don't
1084 know the address of the arglist) if we don't know what frame this
1088 this_frame->prev = prev_frame;
1089 prev_frame->next = this_frame;
1093 fprintf_unfiltered (gdb_stdlog, "-> ");
1094 fprint_frame (gdb_stdlog, prev_frame);
1095 fprintf_unfiltered (gdb_stdlog, " }\n");
1101 /* Debug routine to print a NULL frame being returned. */
1104 frame_debug_got_null_frame (struct ui_file *file,
1105 struct frame_info *this_frame,
1110 fprintf_unfiltered (gdb_stdlog, "{ get_prev_frame (this_frame=");
1111 if (this_frame != NULL)
1112 fprintf_unfiltered (gdb_stdlog, "%d", this_frame->level);
1114 fprintf_unfiltered (gdb_stdlog, "<NULL>");
1115 fprintf_unfiltered (gdb_stdlog, ") -> // %s}\n", reason);
1119 /* Is this (non-sentinel) frame in the "main"() function? */
1122 inside_main_func (struct frame_info *this_frame)
1124 struct minimal_symbol *msymbol;
1127 if (symfile_objfile == 0)
1129 msymbol = lookup_minimal_symbol (main_name (), NULL, symfile_objfile);
1130 if (msymbol == NULL)
1132 /* Make certain that the code, and not descriptor, address is
1134 maddr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
1135 SYMBOL_VALUE_ADDRESS (msymbol),
1137 return maddr == get_frame_func (this_frame);
1140 /* Test whether THIS_FRAME is inside the process entry point function. */
1143 inside_entry_func (struct frame_info *this_frame)
1145 return (get_frame_func (this_frame) == entry_point_address ());
1148 /* Return a structure containing various interesting information about
1149 the frame that called THIS_FRAME. Returns NULL if there is entier
1150 no such frame or the frame fails any of a set of target-independent
1151 condition that should terminate the frame chain (e.g., as unwinding
1154 This function should not contain target-dependent tests, such as
1155 checking whether the program-counter is zero. */
1158 get_prev_frame (struct frame_info *this_frame)
1160 struct frame_info *prev_frame;
1162 /* Return the inner-most frame, when the caller passes in NULL. */
1163 /* NOTE: cagney/2002-11-09: Not sure how this would happen. The
1164 caller should have previously obtained a valid frame using
1165 get_selected_frame() and then called this code - only possibility
1166 I can think of is code behaving badly.
1168 NOTE: cagney/2003-01-10: Talk about code behaving badly. Check
1169 block_innermost_frame(). It does the sequence: frame = NULL;
1170 while (1) { frame = get_prev_frame (frame); .... }. Ulgh! Why
1171 it couldn't be written better, I don't know.
1173 NOTE: cagney/2003-01-11: I suspect what is happening in
1174 block_innermost_frame() is, when the target has no state
1175 (registers, memory, ...), it is still calling this function. The
1176 assumption being that this function will return NULL indicating
1177 that a frame isn't possible, rather than checking that the target
1178 has state and then calling get_current_frame() and
1179 get_prev_frame(). This is a guess mind. */
1180 if (this_frame == NULL)
1182 /* NOTE: cagney/2002-11-09: There was a code segment here that
1183 would error out when CURRENT_FRAME was NULL. The comment
1184 that went with it made the claim ...
1186 ``This screws value_of_variable, which just wants a nice
1187 clean NULL return from block_innermost_frame if there are no
1188 frames. I don't think I've ever seen this message happen
1189 otherwise. And returning NULL here is a perfectly legitimate
1192 Per the above, this code shouldn't even be called with a NULL
1194 frame_debug_got_null_frame (gdb_stdlog, this_frame, "this_frame NULL");
1195 return current_frame;
1198 /* There is always a frame. If this assertion fails, suspect that
1199 something should be calling get_selected_frame() or
1200 get_current_frame(). */
1201 gdb_assert (this_frame != NULL);
1203 /* tausq/2004-12-07: Dummy frames are skipped because it doesn't make much
1204 sense to stop unwinding at a dummy frame. One place where a dummy
1205 frame may have an address "inside_main_func" is on HPUX. On HPUX, the
1206 pcsqh register (space register for the instruction at the head of the
1207 instruction queue) cannot be written directly; the only way to set it
1208 is to branch to code that is in the target space. In order to implement
1209 frame dummies on HPUX, the called function is made to jump back to where
1210 the inferior was when the user function was called. If gdb was inside
1211 the main function when we created the dummy frame, the dummy frame will
1212 point inside the main function. */
1213 if (this_frame->level >= 0
1214 && get_frame_type (this_frame) != DUMMY_FRAME
1215 && !backtrace_past_main
1216 && inside_main_func (this_frame))
1217 /* Don't unwind past main(). Note, this is done _before_ the
1218 frame has been marked as previously unwound. That way if the
1219 user later decides to enable unwinds past main(), that will
1220 automatically happen. */
1222 frame_debug_got_null_frame (gdb_stdlog, this_frame, "inside main func");
1226 if (this_frame->level > backtrace_limit)
1228 error ("Backtrace limit of %d exceeded", backtrace_limit);
1231 /* If we're already inside the entry function for the main objfile,
1232 then it isn't valid. Don't apply this test to a dummy frame -
1233 dummy frame PCs typically land in the entry func. Don't apply
1234 this test to the sentinel frame. Sentinel frames should always
1235 be allowed to unwind. */
1236 /* NOTE: cagney/2003-07-07: Fixed a bug in inside_main_func() -
1237 wasn't checking for "main" in the minimal symbols. With that
1238 fixed asm-source tests now stop in "main" instead of halting the
1239 backtrace in weird and wonderful ways somewhere inside the entry
1240 file. Suspect that tests for inside the entry file/func were
1241 added to work around that (now fixed) case. */
1242 /* NOTE: cagney/2003-07-15: danielj (if I'm reading it right)
1243 suggested having the inside_entry_func test use the
1244 inside_main_func() msymbol trick (along with entry_point_address()
1245 I guess) to determine the address range of the start function.
1246 That should provide a far better stopper than the current
1248 /* NOTE: tausq/2004-10-09: this is needed if, for example, the compiler
1249 applied tail-call optimizations to main so that a function called
1250 from main returns directly to the caller of main. Since we don't
1251 stop at main, we should at least stop at the entry point of the
1253 if (!backtrace_past_entry
1254 && get_frame_type (this_frame) != DUMMY_FRAME && this_frame->level >= 0
1255 && inside_entry_func (this_frame))
1257 frame_debug_got_null_frame (gdb_stdlog, this_frame, "inside entry func");
1261 /* Assume that the only way to get a zero PC is through something
1262 like a SIGSEGV or a dummy frame, and hence that NORMAL frames
1263 will never unwind a zero PC. */
1264 if (this_frame->level > 0
1265 && get_frame_type (this_frame) == NORMAL_FRAME
1266 && get_frame_type (get_next_frame (this_frame)) == NORMAL_FRAME
1267 && get_frame_pc (this_frame) == 0)
1269 frame_debug_got_null_frame (gdb_stdlog, this_frame, "zero PC");
1273 return get_prev_frame_1 (this_frame);
1277 get_frame_pc (struct frame_info *frame)
1279 gdb_assert (frame->next != NULL);
1280 return frame_pc_unwind (frame->next);
1283 /* Return an address of that falls within the frame's code block. */
1286 frame_unwind_address_in_block (struct frame_info *next_frame)
1288 /* A draft address. */
1289 CORE_ADDR pc = frame_pc_unwind (next_frame);
1291 /* If THIS frame is not inner most (i.e., NEXT isn't the sentinel),
1292 and NEXT is `normal' (i.e., not a sigtramp, dummy, ....) THIS
1293 frame's PC ends up pointing at the instruction fallowing the
1294 "call". Adjust that PC value so that it falls on the call
1295 instruction (which, hopefully, falls within THIS frame's code
1296 block. So far it's proved to be a very good approximation. See
1297 get_frame_type() for why ->type can't be used. */
1298 if (next_frame->level >= 0
1299 && get_frame_type (next_frame) == NORMAL_FRAME)
1305 get_frame_address_in_block (struct frame_info *this_frame)
1307 return frame_unwind_address_in_block (this_frame->next);
1311 pc_notcurrent (struct frame_info *frame)
1313 /* If FRAME is not the innermost frame, that normally means that
1314 FRAME->pc points at the return instruction (which is *after* the
1315 call instruction), and we want to get the line containing the
1316 call (because the call is where the user thinks the program is).
1317 However, if the next frame is either a SIGTRAMP_FRAME or a
1318 DUMMY_FRAME, then the next frame will contain a saved interrupt
1319 PC and such a PC indicates the current (rather than next)
1320 instruction/line, consequently, for such cases, want to get the
1321 line containing fi->pc. */
1322 struct frame_info *next = get_next_frame (frame);
1323 int notcurrent = (next != NULL && get_frame_type (next) == NORMAL_FRAME);
1328 find_frame_sal (struct frame_info *frame, struct symtab_and_line *sal)
1330 (*sal) = find_pc_line (get_frame_pc (frame), pc_notcurrent (frame));
1333 /* Per "frame.h", return the ``address'' of the frame. Code should
1334 really be using get_frame_id(). */
1336 get_frame_base (struct frame_info *fi)
1338 return get_frame_id (fi).stack_addr;
1341 /* High-level offsets into the frame. Used by the debug info. */
1344 get_frame_base_address (struct frame_info *fi)
1346 if (get_frame_type (fi) != NORMAL_FRAME)
1348 if (fi->base == NULL)
1349 fi->base = frame_base_find_by_frame (fi->next);
1350 /* Sneaky: If the low-level unwind and high-level base code share a
1351 common unwinder, let them share the prologue cache. */
1352 if (fi->base->unwind == fi->unwind)
1353 return fi->base->this_base (fi->next, &fi->prologue_cache);
1354 return fi->base->this_base (fi->next, &fi->base_cache);
1358 get_frame_locals_address (struct frame_info *fi)
1361 if (get_frame_type (fi) != NORMAL_FRAME)
1363 /* If there isn't a frame address method, find it. */
1364 if (fi->base == NULL)
1365 fi->base = frame_base_find_by_frame (fi->next);
1366 /* Sneaky: If the low-level unwind and high-level base code share a
1367 common unwinder, let them share the prologue cache. */
1368 if (fi->base->unwind == fi->unwind)
1369 cache = &fi->prologue_cache;
1371 cache = &fi->base_cache;
1372 return fi->base->this_locals (fi->next, cache);
1376 get_frame_args_address (struct frame_info *fi)
1379 if (get_frame_type (fi) != NORMAL_FRAME)
1381 /* If there isn't a frame address method, find it. */
1382 if (fi->base == NULL)
1383 fi->base = frame_base_find_by_frame (fi->next);
1384 /* Sneaky: If the low-level unwind and high-level base code share a
1385 common unwinder, let them share the prologue cache. */
1386 if (fi->base->unwind == fi->unwind)
1387 cache = &fi->prologue_cache;
1389 cache = &fi->base_cache;
1390 return fi->base->this_args (fi->next, cache);
1393 /* Level of the selected frame: 0 for innermost, 1 for its caller, ...
1394 or -1 for a NULL frame. */
1397 frame_relative_level (struct frame_info *fi)
1406 get_frame_type (struct frame_info *frame)
1408 if (frame->unwind == NULL)
1409 /* Initialize the frame's unwinder because that's what
1410 provides the frame's type. */
1411 frame->unwind = frame_unwind_find_by_frame (frame->next,
1412 &frame->prologue_cache);
1413 return frame->unwind->type;
1417 deprecated_update_frame_pc_hack (struct frame_info *frame, CORE_ADDR pc)
1420 fprintf_unfiltered (gdb_stdlog,
1421 "{ deprecated_update_frame_pc_hack (frame=%d,pc=0x%s) }\n",
1422 frame->level, paddr_nz (pc));
1423 /* NOTE: cagney/2003-03-11: Some architectures (e.g., Arm) are
1424 maintaining a locally allocated frame object. Since such frames
1425 are not in the frame chain, it isn't possible to assume that the
1426 frame has a next. Sigh. */
1427 if (frame->next != NULL)
1429 /* While we're at it, update this frame's cached PC value, found
1430 in the next frame. Oh for the day when "struct frame_info"
1431 is opaque and this hack on hack can just go away. */
1432 frame->next->prev_pc.value = pc;
1433 frame->next->prev_pc.p = 1;
1438 deprecated_update_frame_base_hack (struct frame_info *frame, CORE_ADDR base)
1441 fprintf_unfiltered (gdb_stdlog,
1442 "{ deprecated_update_frame_base_hack (frame=%d,base=0x%s) }\n",
1443 frame->level, paddr_nz (base));
1444 /* See comment in "frame.h". */
1445 frame->this_id.value.stack_addr = base;
1448 /* Memory access methods. */
1451 get_frame_memory (struct frame_info *this_frame, CORE_ADDR addr, void *buf,
1454 read_memory (addr, buf, len);
1458 get_frame_memory_signed (struct frame_info *this_frame, CORE_ADDR addr,
1461 return read_memory_integer (addr, len);
1465 get_frame_memory_unsigned (struct frame_info *this_frame, CORE_ADDR addr,
1468 return read_memory_unsigned_integer (addr, len);
1472 safe_frame_unwind_memory (struct frame_info *this_frame,
1473 CORE_ADDR addr, void *buf, int len)
1475 /* NOTE: deprecated_read_memory_nobpt returns zero on success! */
1476 return !deprecated_read_memory_nobpt (addr, buf, len);
1479 /* Architecture method. */
1482 get_frame_arch (struct frame_info *this_frame)
1484 return current_gdbarch;
1487 /* Stack pointer methods. */
1490 get_frame_sp (struct frame_info *this_frame)
1492 return frame_sp_unwind (this_frame->next);
1496 frame_sp_unwind (struct frame_info *next_frame)
1498 /* Normality - an architecture that provides a way of obtaining any
1499 frame inner-most address. */
1500 if (gdbarch_unwind_sp_p (current_gdbarch))
1501 return gdbarch_unwind_sp (current_gdbarch, next_frame);
1502 /* Things are looking grim. If it's the inner-most frame and there
1503 is a TARGET_READ_SP, then that can be used. */
1504 if (next_frame->level < 0 && TARGET_READ_SP_P ())
1505 return TARGET_READ_SP ();
1506 /* Now things are really are grim. Hope that the value returned by
1507 the SP_REGNUM register is meaningful. */
1511 frame_unwind_unsigned_register (next_frame, SP_REGNUM, &sp);
1514 internal_error (__FILE__, __LINE__, "Missing unwind SP method");
1517 extern initialize_file_ftype _initialize_frame; /* -Wmissing-prototypes */
1519 static struct cmd_list_element *set_backtrace_cmdlist;
1520 static struct cmd_list_element *show_backtrace_cmdlist;
1523 set_backtrace_cmd (char *args, int from_tty)
1525 help_list (set_backtrace_cmdlist, "set backtrace ", -1, gdb_stdout);
1529 show_backtrace_cmd (char *args, int from_tty)
1531 cmd_show_list (show_backtrace_cmdlist, from_tty, "");
1535 _initialize_frame (void)
1537 obstack_init (&frame_cache_obstack);
1539 observer_attach_target_changed (frame_observer_target_changed);
1541 add_prefix_cmd ("backtrace", class_maintenance, set_backtrace_cmd, "\
1542 Set backtrace specific variables.\n\
1543 Configure backtrace variables such as the backtrace limit",
1544 &set_backtrace_cmdlist, "set backtrace ",
1545 0/*allow-unknown*/, &setlist);
1546 add_prefix_cmd ("backtrace", class_maintenance, show_backtrace_cmd, "\
1547 Show backtrace specific variables\n\
1548 Show backtrace variables such as the backtrace limit",
1549 &show_backtrace_cmdlist, "show backtrace ",
1550 0/*allow-unknown*/, &showlist);
1552 add_setshow_boolean_cmd ("past-main", class_obscure,
1553 &backtrace_past_main, "\
1554 Set whether backtraces should continue past \"main\".", "\
1555 Show whether backtraces should continue past \"main\".", "\
1556 Normally the caller of \"main\" is not of interest, so GDB will terminate\n\
1557 the backtrace at \"main\". Set this variable if you need to see the rest\n\
1558 of the stack trace.", "\
1559 Whether backtraces should continue past \"main\" is %s.",
1560 NULL, NULL, &set_backtrace_cmdlist,
1561 &show_backtrace_cmdlist);
1563 add_setshow_boolean_cmd ("past-entry", class_obscure,
1564 &backtrace_past_entry, "\
1565 Set whether backtraces should continue past the entry point of a program.", "\
1566 Show whether backtraces should continue past the entry point of a program.", "\
1567 Normally there are no callers beyond the entry point of a program, so GDB\n\
1568 will terminate the backtrace there. Set this variable if you need to see \n\
1569 the rest of the stack trace.", "\
1570 Whether backtraces should continue past the entry point is %s.",
1571 NULL, NULL, &set_backtrace_cmdlist,
1572 &show_backtrace_cmdlist);
1574 add_setshow_uinteger_cmd ("limit", class_obscure,
1575 &backtrace_limit, "\
1576 Set an upper bound on the number of backtrace levels.", "\
1577 Show the upper bound on the number of backtrace levels.", "\
1578 No more than the specified number of frames can be displayed or examined.\n\
1579 Zero is unlimited.", "\
1580 An upper bound on the number of backtrace levels is %s.",
1581 NULL, NULL, &set_backtrace_cmdlist,
1582 &show_backtrace_cmdlist);
1584 /* Debug this files internals. */
1585 deprecated_add_show_from_set
1586 (add_set_cmd ("frame", class_maintenance, var_zinteger,
1587 &frame_debug, "Set frame debugging.\n\
1588 When non-zero, frame specific internal debugging is enabled.", &setdebuglist),