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 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 "builtin-regs.h"
32 #include "gdb_obstack.h"
33 #include "dummy-frame.h"
34 #include "sentinel-frame.h"
38 #include "frame-unwind.h"
42 /* Flag to control debugging. */
44 static int frame_debug
;
46 /* Flag to indicate whether backtraces should stop at main. */
48 static int backtrace_below_main
;
50 /* Return a frame uniq ID that can be used to, later, re-find the
54 get_frame_id (struct frame_info
*fi
)
69 const struct frame_id null_frame_id
; /* All zeros. */
72 frame_id_build (CORE_ADDR base
, CORE_ADDR func_or_pc
)
81 frame_id_p (struct frame_id l
)
83 /* The .func can be NULL but the .base cannot. */
88 frame_id_eq (struct frame_id l
, struct frame_id r
)
90 /* If .base is different, the frames are different. */
93 /* Add a test to check that the frame ID's are for the same function
99 frame_id_inner (struct frame_id l
, struct frame_id r
)
101 /* Only return non-zero when strictly inner than. Note that, per
102 comment in "frame.h", there is some fuzz here. Frameless
103 functions are not strictly inner than (same .base but different
105 return INNER_THAN (l
.base
, r
.base
);
109 frame_find_by_id (struct frame_id id
)
111 struct frame_info
*frame
;
113 /* ZERO denotes the null frame, let the caller decide what to do
114 about it. Should it instead return get_current_frame()? */
115 if (!frame_id_p (id
))
118 for (frame
= get_current_frame ();
120 frame
= get_prev_frame (frame
))
122 struct frame_id
this = get_frame_id (frame
);
123 if (frame_id_eq (id
, this))
124 /* An exact match. */
126 if (frame_id_inner (id
, this))
129 /* Either, we're not yet gone far enough out along the frame
130 chain (inner(this,id), or we're comparing frameless functions
131 (same .base, different .func, no test available). Struggle
132 on until we've definitly gone to far. */
138 frame_pc_unwind (struct frame_info
*frame
)
140 if (!frame
->pc_unwind_cache_p
)
142 frame
->pc_unwind_cache
= frame
->unwind
->pc (frame
, &frame
->unwind_cache
);
143 frame
->pc_unwind_cache_p
= 1;
145 return frame
->pc_unwind_cache
;
149 frame_id_unwind (struct frame_info
*frame
)
151 if (!frame
->id_unwind_cache_p
)
153 frame
->unwind
->id (frame
, &frame
->unwind_cache
, &frame
->id_unwind_cache
);
154 frame
->id_unwind_cache_p
= 1;
156 return frame
->id_unwind_cache
;
160 frame_pop (struct frame_info
*frame
)
162 /* FIXME: cagney/2003-01-18: There is probably a chicken-egg problem
163 with passing in current_regcache. The pop function needs to be
164 written carefully so as to not overwrite registers whose [old]
165 values are needed to restore other registers. Instead, this code
166 should pass in a scratch cache and, as a second step, restore the
167 registers using that. */
168 frame
->unwind
->pop (frame
, &frame
->unwind_cache
, current_regcache
);
169 flush_cached_frames ();
173 frame_register_unwind (struct frame_info
*frame
, int regnum
,
174 int *optimizedp
, enum lval_type
*lvalp
,
175 CORE_ADDR
*addrp
, int *realnump
, void *bufferp
)
177 struct frame_unwind_cache
*cache
;
179 /* Require all but BUFFERP to be valid. A NULL BUFFERP indicates
180 that the value proper does not need to be fetched. */
181 gdb_assert (optimizedp
!= NULL
);
182 gdb_assert (lvalp
!= NULL
);
183 gdb_assert (addrp
!= NULL
);
184 gdb_assert (realnump
!= NULL
);
185 /* gdb_assert (bufferp != NULL); */
187 /* NOTE: cagney/2002-11-27: A program trying to unwind a NULL frame
188 is broken. There is always a frame. If there, for some reason,
189 isn't, there is some pretty busted code as it should have
190 detected the problem before calling here. */
191 gdb_assert (frame
!= NULL
);
193 /* Ask this frame to unwind its register. */
194 frame
->unwind
->reg (frame
, &frame
->unwind_cache
, regnum
,
195 optimizedp
, lvalp
, addrp
, realnump
, bufferp
);
199 frame_register (struct frame_info
*frame
, int regnum
,
200 int *optimizedp
, enum lval_type
*lvalp
,
201 CORE_ADDR
*addrp
, int *realnump
, void *bufferp
)
203 /* Require all but BUFFERP to be valid. A NULL BUFFERP indicates
204 that the value proper does not need to be fetched. */
205 gdb_assert (optimizedp
!= NULL
);
206 gdb_assert (lvalp
!= NULL
);
207 gdb_assert (addrp
!= NULL
);
208 gdb_assert (realnump
!= NULL
);
209 /* gdb_assert (bufferp != NULL); */
211 /* Ulgh! Old code that, for lval_register, sets ADDRP to the offset
212 of the register in the register cache. It should instead return
213 the REGNUM corresponding to that register. Translate the . */
214 if (GET_SAVED_REGISTER_P ())
216 GET_SAVED_REGISTER (bufferp
, optimizedp
, addrp
, frame
, regnum
, lvalp
);
217 /* Compute the REALNUM if the caller wants it. */
218 if (*lvalp
== lval_register
)
221 for (regnum
= 0; regnum
< NUM_REGS
+ NUM_PSEUDO_REGS
; regnum
++)
223 if (*addrp
== register_offset_hack (current_gdbarch
, regnum
))
229 internal_error (__FILE__
, __LINE__
,
230 "Failed to compute the register number corresponding"
231 " to 0x%s", paddr_d (*addrp
));
237 /* Obtain the register value by unwinding the register from the next
238 (more inner frame). */
239 gdb_assert (frame
!= NULL
&& frame
->next
!= NULL
);
240 frame_register_unwind (frame
->next
, regnum
, optimizedp
, lvalp
, addrp
,
245 frame_unwind_register (struct frame_info
*frame
, int regnum
, void *buf
)
251 frame_register_unwind (frame
, regnum
, &optimized
, &lval
, &addr
,
256 frame_unwind_signed_register (struct frame_info
*frame
, int regnum
,
259 void *buf
= alloca (MAX_REGISTER_RAW_SIZE
);
260 frame_unwind_register (frame
, regnum
, buf
);
261 (*val
) = extract_signed_integer (buf
, REGISTER_VIRTUAL_SIZE (regnum
));
265 frame_unwind_unsigned_register (struct frame_info
*frame
, int regnum
,
268 void *buf
= alloca (MAX_REGISTER_RAW_SIZE
);
269 frame_unwind_register (frame
, regnum
, buf
);
270 (*val
) = extract_unsigned_integer (buf
, REGISTER_VIRTUAL_SIZE (regnum
));
274 frame_read_register (struct frame_info
*frame
, int regnum
, void *buf
)
276 gdb_assert (frame
!= NULL
&& frame
->next
!= NULL
);
277 frame_unwind_register (frame
->next
, regnum
, buf
);
281 frame_read_unsigned_register (struct frame_info
*frame
, int regnum
,
284 /* NOTE: cagney/2002-10-31: There is a bit of dogma here - there is
285 always a frame. Both this, and the equivalent
286 frame_read_signed_register() function, can only be called with a
287 valid frame. If, for some reason, this function is called
288 without a frame then the problem isn't here, but rather in the
289 caller. It should of first created a frame and then passed that
291 /* NOTE: cagney/2002-10-31: As a side bar, keep in mind that the
292 ``current_frame'' should not be treated as a special case. While
293 ``get_next_frame (current_frame) == NULL'' currently holds, it
294 should, as far as possible, not be relied upon. In the future,
295 ``get_next_frame (current_frame)'' may instead simply return a
296 normal frame object that simply always gets register values from
297 the register cache. Consequently, frame code should try to avoid
298 tests like ``if get_next_frame() == NULL'' and instead just rely
299 on recursive frame calls (like the below code) when manipulating
301 gdb_assert (frame
!= NULL
&& frame
->next
!= NULL
);
302 frame_unwind_unsigned_register (frame
->next
, regnum
, val
);
306 frame_read_signed_register (struct frame_info
*frame
, int regnum
,
309 /* See note above in frame_read_unsigned_register(). */
310 gdb_assert (frame
!= NULL
&& frame
->next
!= NULL
);
311 frame_unwind_signed_register (frame
->next
, regnum
, val
);
315 generic_unwind_get_saved_register (char *raw_buffer
,
318 struct frame_info
*frame
,
320 enum lval_type
*lvalp
)
325 enum lval_type lvalx
;
327 if (!target_has_registers
)
328 error ("No registers.");
330 /* Keep things simple, ensure that all the pointers (except valuep)
332 if (optimizedp
== NULL
)
333 optimizedp
= &optimizedx
;
339 gdb_assert (frame
!= NULL
&& frame
->next
!= NULL
);
340 frame_register_unwind (frame
->next
, regnum
, optimizedp
, lvalp
, addrp
,
341 &realnumx
, raw_buffer
);
345 get_saved_register (char *raw_buffer
,
348 struct frame_info
*frame
,
350 enum lval_type
*lval
)
352 if (GET_SAVED_REGISTER_P ())
354 GET_SAVED_REGISTER (raw_buffer
, optimized
, addrp
, frame
, regnum
, lval
);
357 generic_unwind_get_saved_register (raw_buffer
, optimized
, addrp
, frame
,
361 /* frame_register_read ()
363 Find and return the value of REGNUM for the specified stack frame.
364 The number of bytes copied is REGISTER_RAW_SIZE (REGNUM).
366 Returns 0 if the register value could not be found. */
369 frame_register_read (struct frame_info
*frame
, int regnum
, void *myaddr
)
375 frame_register (frame
, regnum
, &optimized
, &lval
, &addr
, &realnum
, myaddr
);
377 /* FIXME: cagney/2002-05-15: This test, is just bogus.
379 It indicates that the target failed to supply a value for a
380 register because it was "not available" at this time. Problem
381 is, the target still has the register and so get saved_register()
382 may be returning a value saved on the stack. */
384 if (register_cached (regnum
) < 0)
385 return 0; /* register value not available */
391 /* Map between a frame register number and its name. A frame register
392 space is a superset of the cooked register space --- it also
393 includes builtin registers. */
396 frame_map_name_to_regnum (const char *name
, int len
)
403 /* Search register name space. */
404 for (i
= 0; i
< NUM_REGS
+ NUM_PSEUDO_REGS
; i
++)
405 if (REGISTER_NAME (i
) && len
== strlen (REGISTER_NAME (i
))
406 && strncmp (name
, REGISTER_NAME (i
), len
) == 0)
411 /* Try builtin registers. */
412 i
= builtin_reg_map_name_to_regnum (name
, len
);
415 /* A builtin register doesn't fall into the architecture's
417 gdb_assert (i
>= NUM_REGS
+ NUM_PSEUDO_REGS
);
425 frame_map_regnum_to_name (int regnum
)
429 if (regnum
< NUM_REGS
+ NUM_PSEUDO_REGS
)
430 return REGISTER_NAME (regnum
);
431 return builtin_reg_map_regnum_to_name (regnum
);
434 /* Create a sentinel frame. */
437 create_sentinel_frame (struct regcache
*regcache
)
439 struct frame_info
*frame
= FRAME_OBSTACK_ZALLOC (struct frame_info
);
440 frame
->type
= NORMAL_FRAME
;
442 /* Explicitly initialize the sentinel frame's cache. Provide it
443 with the underlying regcache. In the future additional
444 information, such as the frame's thread will be added. */
445 frame
->unwind_cache
= sentinel_frame_cache (regcache
);
446 /* For the moment there is only one sentinel frame implementation. */
447 frame
->unwind
= sentinel_frame_unwind
;
448 /* Link this frame back to itself. The frame is self referential
449 (the unwound PC is the same as the pc), so make it so. */
451 /* Always unwind the PC as part of creating this frame. This
452 ensures that the frame's PC points at something valid. */
453 /* FIXME: cagney/2003-01-10: Problem here. Unwinding a sentinel
454 frame's PC may require information such as the frame's thread's
455 stop reason. Is it possible to get to that? */
456 frame
->pc
= frame_pc_unwind (frame
);
460 /* Info about the innermost stack frame (contents of FP register) */
462 static struct frame_info
*current_frame
;
464 /* Cache for frame addresses already read by gdb. Valid only while
465 inferior is stopped. Control variables for the frame cache should
466 be local to this module. */
468 static struct obstack frame_cache_obstack
;
471 frame_obstack_zalloc (unsigned long size
)
473 void *data
= obstack_alloc (&frame_cache_obstack
, size
);
474 memset (data
, 0, size
);
479 frame_saved_regs_zalloc (struct frame_info
*fi
)
481 fi
->saved_regs
= (CORE_ADDR
*)
482 frame_obstack_zalloc (SIZEOF_FRAME_SAVED_REGS
);
483 return fi
->saved_regs
;
487 get_frame_saved_regs (struct frame_info
*fi
)
489 return fi
->saved_regs
;
492 /* Return the innermost (currently executing) stack frame. This is
493 split into two functions. The function unwind_to_current_frame()
494 is wrapped in catch exceptions so that, even when the unwind of the
495 sentinel frame fails, the function still returns a stack frame. */
498 unwind_to_current_frame (struct ui_out
*ui_out
, void *args
)
500 struct frame_info
*frame
= get_prev_frame (args
);
501 /* A sentinel frame can fail to unwind, eg, because it's PC value
502 lands in somewhere like start. */
505 current_frame
= frame
;
510 get_current_frame (void)
512 if (!target_has_stack
)
514 if (!target_has_registers
)
515 error ("No registers.");
516 if (!target_has_memory
)
517 error ("No memory.");
518 if (current_frame
== NULL
)
520 struct frame_info
*sentinel_frame
=
521 create_sentinel_frame (current_regcache
);
522 if (catch_exceptions (uiout
, unwind_to_current_frame
, sentinel_frame
,
523 NULL
, RETURN_MASK_ERROR
) != 0)
525 /* Oops! Fake a current frame? Is this useful? It has a PC
526 of zero, for instance. */
527 current_frame
= sentinel_frame
;
530 return current_frame
;
533 /* The "selected" stack frame is used by default for local and arg
534 access. May be zero, for no selected frame. */
536 struct frame_info
*deprecated_selected_frame
;
538 /* Return the selected frame. Always non-null (unless there isn't an
539 inferior sufficient for creating a frame) in which case an error is
543 get_selected_frame (void)
545 if (deprecated_selected_frame
== NULL
)
546 /* Hey! Don't trust this. It should really be re-finding the
547 last selected frame of the currently selected thread. This,
548 though, is better than nothing. */
549 select_frame (get_current_frame ());
550 /* There is always a frame. */
551 gdb_assert (deprecated_selected_frame
!= NULL
);
552 return deprecated_selected_frame
;
555 /* Select frame FI (or NULL - to invalidate the current frame). */
558 select_frame (struct frame_info
*fi
)
560 register struct symtab
*s
;
562 deprecated_selected_frame
= fi
;
563 /* NOTE: cagney/2002-05-04: FI can be NULL. This occures when the
564 frame is being invalidated. */
565 if (selected_frame_level_changed_hook
)
566 selected_frame_level_changed_hook (frame_relative_level (fi
));
568 /* FIXME: kseitz/2002-08-28: It would be nice to call
569 selected_frame_level_changed_event right here, but due to limitations
570 in the current interfaces, we would end up flooding UIs with events
571 because select_frame is used extensively internally.
573 Once we have frame-parameterized frame (and frame-related) commands,
574 the event notification can be moved here, since this function will only
575 be called when the users selected frame is being changed. */
577 /* Ensure that symbols for this frame are read in. Also, determine the
578 source language of this frame, and switch to it if desired. */
581 s
= find_pc_symtab (fi
->pc
);
583 && s
->language
!= current_language
->la_language
584 && s
->language
!= language_unknown
585 && language_mode
== language_mode_auto
)
587 set_language (s
->language
);
592 /* Return the register saved in the simplistic ``saved_regs'' cache.
593 If the value isn't here AND a value is needed, try the next inner
597 frame_saved_regs_register_unwind (struct frame_info
*frame
, void **cache
,
598 int regnum
, int *optimizedp
,
599 enum lval_type
*lvalp
, CORE_ADDR
*addrp
,
600 int *realnump
, void *bufferp
)
602 /* There is always a frame at this point. And THIS is the frame
603 we're interested in. */
604 gdb_assert (frame
!= NULL
);
605 /* If we're using generic dummy frames, we'd better not be in a call
606 dummy. (generic_call_dummy_register_unwind ought to have been called
608 gdb_assert (!(DEPRECATED_USE_GENERIC_DUMMY_FRAMES
609 && (get_frame_type (frame
) == DUMMY_FRAME
)));
611 /* Only (older) architectures that implement the
612 FRAME_INIT_SAVED_REGS method should be using this function. */
613 gdb_assert (FRAME_INIT_SAVED_REGS_P ());
615 /* Load the saved_regs register cache. */
616 if (get_frame_saved_regs (frame
) == NULL
)
617 FRAME_INIT_SAVED_REGS (frame
);
619 if (get_frame_saved_regs (frame
) != NULL
620 && get_frame_saved_regs (frame
)[regnum
] != 0)
622 if (regnum
== SP_REGNUM
)
624 /* SP register treated specially. */
630 store_address (bufferp
, REGISTER_RAW_SIZE (regnum
),
631 get_frame_saved_regs (frame
)[regnum
]);
635 /* Any other register is saved in memory, fetch it but cache
636 a local copy of its value. */
638 *lvalp
= lval_memory
;
639 *addrp
= get_frame_saved_regs (frame
)[regnum
];
644 /* Save each register value, as it is read in, in a
645 frame based cache. */
646 void **regs
= (*cache
);
649 int sizeof_cache
= ((NUM_REGS
+ NUM_PSEUDO_REGS
)
651 regs
= frame_obstack_zalloc (sizeof_cache
);
654 if (regs
[regnum
] == NULL
)
657 = frame_obstack_zalloc (REGISTER_RAW_SIZE (regnum
));
658 read_memory (get_frame_saved_regs (frame
)[regnum
], regs
[regnum
],
659 REGISTER_RAW_SIZE (regnum
));
661 memcpy (bufferp
, regs
[regnum
], REGISTER_RAW_SIZE (regnum
));
663 /* Read the value in from memory. */
664 read_memory (get_frame_saved_regs (frame
)[regnum
], bufferp
,
665 REGISTER_RAW_SIZE (regnum
));
672 /* No luck, assume this and the next frame have the same register
673 value. Pass the request down the frame chain to the next frame.
674 Hopefully that will find the register's location, either in a
675 register or in memory. */
676 frame_register (frame
, regnum
, optimizedp
, lvalp
, addrp
, realnump
,
681 frame_saved_regs_pc_unwind (struct frame_info
*frame
, void **cache
)
683 gdb_assert (FRAME_SAVED_PC_P ());
684 return FRAME_SAVED_PC (frame
);
688 frame_saved_regs_id_unwind (struct frame_info
*next_frame
, void **cache
,
695 /* Start out by assuming it's NULL. */
696 (*id
) = null_frame_id
;
698 if (frame_relative_level (next_frame
) <= 0)
699 /* FIXME: 2002-11-09: Frameless functions can occure anywhere in
700 the frame chain, not just the inner most frame! The generic,
701 per-architecture, frame code should handle this and the below
702 should simply be removed. */
703 fromleaf
= FRAMELESS_FUNCTION_INVOCATION (next_frame
);
708 /* A frameless inner-most frame. The `FP' (which isn't an
709 architecture frame-pointer register!) of the caller is the same
711 /* FIXME: 2002-11-09: There isn't any reason to special case this
712 edge condition. Instead the per-architecture code should hande
714 base
= get_frame_base (next_frame
);
717 /* Two macros defined in tm.h specify the machine-dependent
718 actions to be performed here.
720 First, get the frame's chain-pointer.
722 If that is zero, the frame is the outermost frame or a leaf
723 called by the outermost frame. This means that if start
724 calls main without a frame, we'll return 0 (which is fine
727 Nope; there's a problem. This also returns when the current
728 routine is a leaf of main. This is unacceptable. We move
729 this to after the ffi test; I'd rather have backtraces from
730 start go curfluy than have an abort called from main not show
732 gdb_assert (FRAME_CHAIN_P ());
733 base
= FRAME_CHAIN (next_frame
);
735 if (!frame_chain_valid (base
, next_frame
))
741 /* FIXME: cagney/2002-06-08: This should probably return the frame's
742 function and not the PC (a.k.a. resume address). */
743 pc
= frame_pc_unwind (next_frame
);
749 frame_saved_regs_pop (struct frame_info
*fi
, void **cache
,
750 struct regcache
*regcache
)
752 gdb_assert (POP_FRAME_P ());
756 const struct frame_unwind trad_frame_unwinder
= {
757 frame_saved_regs_pop
,
758 frame_saved_regs_pc_unwind
,
759 frame_saved_regs_id_unwind
,
760 frame_saved_regs_register_unwind
762 const struct frame_unwind
*trad_frame_unwind
= &trad_frame_unwinder
;
765 /* Function: get_saved_register
766 Find register number REGNUM relative to FRAME and put its (raw,
767 target format) contents in *RAW_BUFFER.
769 Set *OPTIMIZED if the variable was optimized out (and thus can't be
770 fetched). Note that this is never set to anything other than zero
771 in this implementation.
773 Set *LVAL to lval_memory, lval_register, or not_lval, depending on
774 whether the value was fetched from memory, from a register, or in a
775 strange and non-modifiable way (e.g. a frame pointer which was
776 calculated rather than fetched). We will use not_lval for values
777 fetched from generic dummy frames.
779 Set *ADDRP to the address, either in memory or as a REGISTER_BYTE
780 offset into the registers array. If the value is stored in a dummy
781 frame, set *ADDRP to zero.
783 To use this implementation, define a function called
784 "get_saved_register" in your target code, which simply passes all
785 of its arguments to this function.
787 The argument RAW_BUFFER must point to aligned memory. */
790 deprecated_generic_get_saved_register (char *raw_buffer
, int *optimized
,
792 struct frame_info
*frame
, int regnum
,
793 enum lval_type
*lval
)
795 if (!target_has_registers
)
796 error ("No registers.");
798 gdb_assert (FRAME_INIT_SAVED_REGS_P ());
800 /* Normal systems don't optimize out things with register numbers. */
801 if (optimized
!= NULL
)
804 if (addrp
) /* default assumption: not found in memory */
807 /* Note: since the current frame's registers could only have been
808 saved by frames INTERIOR TO the current frame, we skip examining
809 the current frame itself: otherwise, we would be getting the
810 previous frame's registers which were saved by the current frame. */
814 for (frame
= get_next_frame (frame
);
815 frame_relative_level (frame
) >= 0;
816 frame
= get_next_frame (frame
))
818 if (get_frame_type (frame
) == DUMMY_FRAME
)
820 if (lval
) /* found it in a CALL_DUMMY frame */
823 /* FIXME: cagney/2002-06-26: This should be via the
824 gdbarch_register_read() method so that it, on the
825 fly, constructs either a raw or pseudo register
826 from the raw register cache. */
828 (generic_find_dummy_frame (get_frame_pc (frame
),
829 get_frame_base (frame
)),
834 FRAME_INIT_SAVED_REGS (frame
);
835 if (get_frame_saved_regs (frame
) != NULL
836 && get_frame_saved_regs (frame
)[regnum
] != 0)
838 if (lval
) /* found it saved on the stack */
840 if (regnum
== SP_REGNUM
)
842 if (raw_buffer
) /* SP register treated specially */
843 store_address (raw_buffer
, REGISTER_RAW_SIZE (regnum
),
844 get_frame_saved_regs (frame
)[regnum
]);
848 if (addrp
) /* any other register */
849 *addrp
= get_frame_saved_regs (frame
)[regnum
];
851 read_memory (get_frame_saved_regs (frame
)[regnum
], raw_buffer
,
852 REGISTER_RAW_SIZE (regnum
));
859 /* If we get thru the loop to this point, it means the register was
860 not saved in any frame. Return the actual live-register value. */
862 if (lval
) /* found it in a live register */
863 *lval
= lval_register
;
865 *addrp
= REGISTER_BYTE (regnum
);
867 deprecated_read_register_gen (regnum
, raw_buffer
);
870 /* Determine the frame's type based on its PC. */
872 static enum frame_type
873 frame_type_from_pc (CORE_ADDR pc
)
875 /* FIXME: cagney/2002-11-24: Can't yet directly call
876 pc_in_dummy_frame() as some architectures don't set
877 PC_IN_CALL_DUMMY() to generic_pc_in_call_dummy() (remember the
878 latter is implemented by simply calling pc_in_dummy_frame). */
879 if (DEPRECATED_USE_GENERIC_DUMMY_FRAMES
880 && DEPRECATED_PC_IN_CALL_DUMMY (pc
, 0, 0))
885 find_pc_partial_function (pc
, &name
, NULL
, NULL
);
886 if (PC_IN_SIGTRAMP (pc
, name
))
887 return SIGTRAMP_FRAME
;
893 /* Create an arbitrary (i.e. address specified by user) or innermost frame.
894 Always returns a non-NULL value. */
897 create_new_frame (CORE_ADDR addr
, CORE_ADDR pc
)
899 struct frame_info
*fi
;
901 fi
= frame_obstack_zalloc (sizeof (struct frame_info
));
905 fi
->next
= create_sentinel_frame (current_regcache
);
906 fi
->type
= frame_type_from_pc (pc
);
908 if (INIT_EXTRA_FRAME_INFO_P ())
909 INIT_EXTRA_FRAME_INFO (0, fi
);
911 /* Select/initialize an unwind function. */
912 fi
->unwind
= frame_unwind_find_by_pc (current_gdbarch
, fi
->pc
);
917 /* Return the frame that FRAME calls (NULL if FRAME is the innermost
918 frame). Be careful to not fall off the bottom of the frame chain
919 and onto the sentinel frame. */
922 get_next_frame (struct frame_info
*frame
)
924 if (frame
->level
> 0)
930 /* Flush the entire frame cache. */
933 flush_cached_frames (void)
935 /* Since we can't really be sure what the first object allocated was */
936 obstack_free (&frame_cache_obstack
, 0);
937 obstack_init (&frame_cache_obstack
);
939 current_frame
= NULL
; /* Invalidate cache */
941 annotate_frames_invalid ();
944 /* Flush the frame cache, and start a new one if necessary. */
947 reinit_frame_cache (void)
949 flush_cached_frames ();
951 /* FIXME: The inferior_ptid test is wrong if there is a corefile. */
952 if (PIDGET (inferior_ptid
) != 0)
954 select_frame (get_current_frame ());
958 /* Create the previous frame using the deprecated methods
959 INIT_EXTRA_INFO, INIT_FRAME_PC and INIT_FRAME_PC_FIRST. */
961 static struct frame_info
*
962 legacy_get_prev_frame (struct frame_info
*next_frame
)
964 CORE_ADDR address
= 0;
965 struct frame_info
*prev
;
968 /* This code only works on normal frames. A sentinel frame, where
969 the level is -1, should never reach this code. */
970 gdb_assert (next_frame
->level
>= 0);
972 /* On some machines it is possible to call a function without
973 setting up a stack frame for it. On these machines, we
974 define this macro to take two args; a frameinfo pointer
975 identifying a frame and a variable to set or clear if it is
976 or isn't leafless. */
978 /* Still don't want to worry about this except on the innermost
979 frame. This macro will set FROMLEAF if NEXT_FRAME is a frameless
980 function invocation. */
981 if (next_frame
->level
== 0)
982 /* FIXME: 2002-11-09: Frameless functions can occure anywhere in
983 the frame chain, not just the inner most frame! The generic,
984 per-architecture, frame code should handle this and the below
985 should simply be removed. */
986 fromleaf
= FRAMELESS_FUNCTION_INVOCATION (next_frame
);
991 /* A frameless inner-most frame. The `FP' (which isn't an
992 architecture frame-pointer register!) of the caller is the same
994 /* FIXME: 2002-11-09: There isn't any reason to special case this
995 edge condition. Instead the per-architecture code should hande
997 address
= get_frame_base (next_frame
);
1000 /* Two macros defined in tm.h specify the machine-dependent
1001 actions to be performed here.
1003 First, get the frame's chain-pointer.
1005 If that is zero, the frame is the outermost frame or a leaf
1006 called by the outermost frame. This means that if start
1007 calls main without a frame, we'll return 0 (which is fine
1010 Nope; there's a problem. This also returns when the current
1011 routine is a leaf of main. This is unacceptable. We move
1012 this to after the ffi test; I'd rather have backtraces from
1013 start go curfluy than have an abort called from main not show
1015 gdb_assert (FRAME_CHAIN_P ());
1016 address
= FRAME_CHAIN (next_frame
);
1018 if (!frame_chain_valid (address
, next_frame
))
1024 /* Create an initially zero previous frame. */
1025 prev
= frame_obstack_zalloc (sizeof (struct frame_info
));
1028 next_frame
->prev
= prev
;
1029 prev
->next
= next_frame
;
1030 prev
->frame
= address
;
1031 prev
->level
= next_frame
->level
+ 1;
1032 /* FIXME: cagney/2002-11-18: Should be setting the frame's type
1033 here, before anything else, and not last. Various INIT functions
1034 are full of work-arounds for the frames type not being set
1035 correctly from the word go. Ulgh! */
1036 prev
->type
= NORMAL_FRAME
;
1038 /* This change should not be needed, FIXME! We should determine
1039 whether any targets *need* DEPRECATED_INIT_FRAME_PC to happen
1040 after INIT_EXTRA_FRAME_INFO and come up with a simple way to
1041 express what goes on here.
1043 INIT_EXTRA_FRAME_INFO is called from two places: create_new_frame
1044 (where the PC is already set up) and here (where it isn't).
1045 DEPRECATED_INIT_FRAME_PC is only called from here, always after
1046 INIT_EXTRA_FRAME_INFO.
1048 The catch is the MIPS, where INIT_EXTRA_FRAME_INFO requires the
1049 PC value (which hasn't been set yet). Some other machines appear
1050 to require INIT_EXTRA_FRAME_INFO before they can do
1051 DEPRECATED_INIT_FRAME_PC. Phoo.
1053 We shouldn't need DEPRECATED_INIT_FRAME_PC_FIRST to add more
1054 complication to an already overcomplicated part of GDB.
1055 gnu@cygnus.com, 15Sep92.
1057 Assuming that some machines need DEPRECATED_INIT_FRAME_PC after
1058 INIT_EXTRA_FRAME_INFO, one possible scheme:
1060 SETUP_INNERMOST_FRAME(): Default version is just create_new_frame
1061 (read_fp ()), read_pc ()). Machines with extra frame info would
1062 do that (or the local equivalent) and then set the extra fields.
1064 SETUP_ARBITRARY_FRAME(argc, argv): Only change here is that
1065 create_new_frame would no longer init extra frame info;
1066 SETUP_ARBITRARY_FRAME would have to do that.
1068 INIT_PREV_FRAME(fromleaf, prev) Replace INIT_EXTRA_FRAME_INFO and
1069 DEPRECATED_INIT_FRAME_PC. This should also return a flag saying
1070 whether to keep the new frame, or whether to discard it, because
1071 on some machines (e.g. mips) it is really awkward to have
1072 FRAME_CHAIN_VALID called *before* INIT_EXTRA_FRAME_INFO (there is
1073 no good way to get information deduced in FRAME_CHAIN_VALID into
1074 the extra fields of the new frame). std_frame_pc(fromleaf, prev)
1076 This is the default setting for INIT_PREV_FRAME. It just does
1077 what the default DEPRECATED_INIT_FRAME_PC does. Some machines
1078 will call it from INIT_PREV_FRAME (either at the beginning, the
1079 end, or in the middle). Some machines won't use it.
1081 kingdon@cygnus.com, 13Apr93, 31Jan94, 14Dec94. */
1083 /* NOTE: cagney/2002-11-09: Just ignore the above! There is no
1084 reason for things to be this complicated.
1086 The trick is to assume that there is always a frame. Instead of
1087 special casing the inner-most frame, create fake frame
1088 (containing the hardware registers) that is inner to the
1089 user-visible inner-most frame (...) and then unwind from that.
1090 That way architecture code can use use the standard
1091 frame_XX_unwind() functions and not differentiate between the
1092 inner most and any other case.
1094 Since there is always a frame to unwind from, there is always
1095 somewhere (NEXT_FRAME) to store all the info needed to construct
1096 a new (previous) frame without having to first create it. This
1097 means that the convolution below - needing to carefully order a
1098 frame's initialization - isn't needed.
1100 The irony here though, is that FRAME_CHAIN(), at least for a more
1101 up-to-date architecture, always calls FRAME_SAVED_PC(), and
1102 FRAME_SAVED_PC() computes the PC but without first needing the
1103 frame! Instead of the convolution below, we could have simply
1104 called FRAME_SAVED_PC() and been done with it! Note that
1105 FRAME_SAVED_PC() is being superseed by frame_pc_unwind() and that
1106 function does have somewhere to cache that PC value. */
1108 if (DEPRECATED_INIT_FRAME_PC_FIRST_P ())
1109 prev
->pc
= (DEPRECATED_INIT_FRAME_PC_FIRST (fromleaf
, prev
));
1111 if (INIT_EXTRA_FRAME_INFO_P ())
1112 INIT_EXTRA_FRAME_INFO (fromleaf
, prev
);
1114 /* This entry is in the frame queue now, which is good since
1115 FRAME_SAVED_PC may use that queue to figure out its value (see
1116 tm-sparc.h). We want the pc saved in the inferior frame. */
1117 if (DEPRECATED_INIT_FRAME_PC_P ())
1118 prev
->pc
= DEPRECATED_INIT_FRAME_PC (fromleaf
, prev
);
1120 /* If ->frame and ->pc are unchanged, we are in the process of
1121 getting ourselves into an infinite backtrace. Some architectures
1122 check this in FRAME_CHAIN or thereabouts, but it seems like there
1123 is no reason this can't be an architecture-independent check. */
1124 if (prev
->frame
== next_frame
->frame
1125 && prev
->pc
== next_frame
->pc
)
1127 next_frame
->prev
= NULL
;
1128 obstack_free (&frame_cache_obstack
, prev
);
1132 /* Initialize the code used to unwind the frame PREV based on the PC
1133 (and probably other architectural information). The PC lets you
1134 check things like the debug info at that point (dwarf2cfi?) and
1135 use that to decide how the frame should be unwound. */
1136 prev
->unwind
= frame_unwind_find_by_pc (current_gdbarch
, prev
->pc
);
1138 /* NOTE: cagney/2002-11-18: The code segments, found in
1139 create_new_frame and get_prev_frame(), that initializes the
1140 frames type is subtly different. The latter only updates ->type
1141 when it encounters a SIGTRAMP_FRAME or DUMMY_FRAME. This stops
1142 get_prev_frame() overriding the frame's type when the INIT code
1143 has previously set it. This is really somewhat bogus. The
1144 initialization, as seen in create_new_frame(), should occur
1145 before the INIT function has been called. */
1146 if (DEPRECATED_USE_GENERIC_DUMMY_FRAMES
1147 && (DEPRECATED_PC_IN_CALL_DUMMY_P ()
1148 ? DEPRECATED_PC_IN_CALL_DUMMY (prev
->pc
, 0, 0)
1149 : pc_in_dummy_frame (prev
->pc
)))
1150 prev
->type
= DUMMY_FRAME
;
1153 /* FIXME: cagney/2002-11-10: This should be moved to before the
1154 INIT code above so that the INIT code knows what the frame's
1155 type is (in fact, for a [generic] dummy-frame, the type can
1156 be set and then the entire initialization can be skipped.
1157 Unforunatly, its the INIT code that sets the PC (Hmm, catch
1160 find_pc_partial_function (prev
->pc
, &name
, NULL
, NULL
);
1161 if (PC_IN_SIGTRAMP (prev
->pc
, name
))
1162 prev
->type
= SIGTRAMP_FRAME
;
1163 /* FIXME: cagney/2002-11-11: Leave prev->type alone. Some
1164 architectures are forcing the frame's type in INIT so we
1165 don't want to override it here. Remember, NORMAL_FRAME == 0,
1166 so it all works (just :-/). Once this initialization is
1167 moved to the start of this function, all this nastness will
1174 /* Return a structure containing various interesting information
1175 about the frame that called NEXT_FRAME. Returns NULL
1176 if there is no such frame. */
1179 get_prev_frame (struct frame_info
*next_frame
)
1181 struct frame_info
*prev_frame
;
1183 /* Return the inner-most frame, when the caller passes in NULL. */
1184 /* NOTE: cagney/2002-11-09: Not sure how this would happen. The
1185 caller should have previously obtained a valid frame using
1186 get_selected_frame() and then called this code - only possibility
1187 I can think of is code behaving badly.
1189 NOTE: cagney/2003-01-10: Talk about code behaving badly. Check
1190 block_innermost_frame(). It does the sequence: frame = NULL;
1191 while (1) { frame = get_prev_frame (frame); .... }. Ulgh! Why
1192 it couldn't be written better, I don't know.
1194 NOTE: cagney/2003-01-11: I suspect what is happening is
1195 block_innermost_frame() is, when the target has no state
1196 (registers, memory, ...), still calling this function. The
1197 assumption being that this function will return NULL indicating
1198 that a frame isn't possible, rather than checking that the target
1199 has state and then calling get_current_frame() and
1200 get_prev_frame(). This is a guess mind. */
1201 if (next_frame
== NULL
)
1203 /* NOTE: cagney/2002-11-09: There was a code segment here that
1204 would error out when CURRENT_FRAME was NULL. The comment
1205 that went with it made the claim ...
1207 ``This screws value_of_variable, which just wants a nice
1208 clean NULL return from block_innermost_frame if there are no
1209 frames. I don't think I've ever seen this message happen
1210 otherwise. And returning NULL here is a perfectly legitimate
1213 Per the above, this code shouldn't even be called with a NULL
1215 return current_frame
;
1218 /* There is always a frame. If this assertion fails, suspect that
1219 something should be calling get_selected_frame() or
1220 get_current_frame(). */
1221 gdb_assert (next_frame
!= NULL
);
1223 if (next_frame
->level
>= 0
1224 && !backtrace_below_main
1225 && inside_main_func (get_frame_pc (next_frame
)))
1226 /* Don't unwind past main(), bug always unwind the sentinel frame.
1227 Note, this is done _before_ the frame has been marked as
1228 previously unwound. That way if the user later decides to
1229 allow unwinds past main(), that just happens. */
1232 fprintf_unfiltered (gdb_stdlog
,
1233 "Outermost frame - inside main func.\n");
1237 /* Only try to do the unwind once. */
1238 if (next_frame
->prev_p
)
1239 return next_frame
->prev
;
1240 next_frame
->prev_p
= 1;
1242 /* If we're inside the entry file, it isn't valid. */
1243 /* NOTE: drow/2002-12-25: should there be a way to disable this
1244 check? It assumes a single small entry file, and the way some
1245 debug readers (e.g. dbxread) figure out which object is the
1246 entry file is somewhat hokey. */
1247 /* NOTE: cagney/2003-01-10: If there is a way of disabling this test
1248 then it should probably be moved to before the ->prev_p test,
1250 if (inside_entry_file (get_frame_pc (next_frame
)))
1253 fprintf_unfiltered (gdb_stdlog
,
1254 "Outermost frame - inside entry file\n");
1258 /* If any of the old frame initialization methods are around, use
1259 the legacy get_prev_frame method. Just don't try to unwind a
1260 sentinel frame using that method - it doesn't work. All sentinal
1261 frames use the new unwind code. */
1262 if ((DEPRECATED_INIT_FRAME_PC_P ()
1263 || DEPRECATED_INIT_FRAME_PC_FIRST_P ()
1264 || INIT_EXTRA_FRAME_INFO_P ()
1265 || FRAME_CHAIN_P ())
1266 && next_frame
->level
>= 0)
1268 prev_frame
= legacy_get_prev_frame (next_frame
);
1269 if (frame_debug
&& prev_frame
== NULL
)
1270 fprintf_unfiltered (gdb_stdlog
,
1271 "Outermost frame - legacy_get_prev_frame NULL.\n");
1275 /* Allocate the new frame but do not wire it in to the frame chain.
1276 Some (bad) code in INIT_FRAME_EXTRA_INFO tries to look along
1277 frame->next to pull some fancy tricks (of course such code is, by
1278 definition, recursive). Try to prevent it.
1280 There is no reason to worry about memory leaks, should the
1281 remainder of the function fail. The allocated memory will be
1282 quickly reclaimed when the frame cache is flushed, and the `we've
1283 been here before' check above will stop repeated memory
1284 allocation calls. */
1285 prev_frame
= FRAME_OBSTACK_ZALLOC (struct frame_info
);
1286 prev_frame
->level
= next_frame
->level
+ 1;
1288 /* Try to unwind the PC. If that doesn't work, assume we've reached
1289 the oldest frame and simply return. Is there a better sentinal
1290 value? The unwound PC value is then used to initialize the new
1291 previous frame's type.
1293 Note that the pc-unwind is intentionally performed before the
1294 frame chain. This is ok since, for old targets, both
1295 frame_pc_unwind (nee, FRAME_SAVED_PC) and FRAME_CHAIN()) assume
1296 NEXT_FRAME's data structures have already been initialized (using
1297 INIT_EXTRA_FRAME_INFO) and hence the call order doesn't matter.
1299 By unwinding the PC first, it becomes possible to, in the case of
1300 a dummy frame, avoid also unwinding the frame ID. This is
1301 because (well ignoring the PPC) a dummy frame can be located
1302 using NEXT_FRAME's frame ID. */
1304 prev_frame
->pc
= frame_pc_unwind (next_frame
);
1305 if (prev_frame
->pc
== 0)
1307 /* The allocated PREV_FRAME will be reclaimed when the frame
1308 obstack is next purged. */
1310 fprintf_unfiltered (gdb_stdlog
,
1311 "Outermost frame - unwound PC zero\n");
1314 prev_frame
->type
= frame_type_from_pc (prev_frame
->pc
);
1316 /* Set the unwind functions based on that identified PC. */
1317 prev_frame
->unwind
= frame_unwind_find_by_pc (current_gdbarch
,
1320 /* FIXME: cagney/2003-01-13: A dummy frame doesn't need to unwind
1321 the frame ID because the frame ID comes from the previous frame.
1322 The other frames do though. True? */
1324 /* FIXME: cagney/2002-12-18: Instead of this hack, should just
1325 save the frame ID directly. */
1326 struct frame_id id
= frame_id_unwind (next_frame
);
1327 if (!frame_id_p (id
))
1330 fprintf_unfiltered (gdb_stdlog
,
1331 "Outermost frame - unwound frame ID invalid\n");
1334 prev_frame
->frame
= id
.base
;
1338 next_frame
->prev
= prev_frame
;
1339 prev_frame
->next
= next_frame
;
1341 /* FIXME: cagney/2002-01-19: This call will go away. Instead of
1342 initializing extra info, all frames will use the frame_cache
1343 (passed to the unwind functions) to store additional frame info.
1344 Unfortunatly legacy targets can't use legacy_get_prev_frame() to
1345 unwind the sentinel frame and, consequently, are forced to take
1346 this code path and rely on the below call to INIT_EXTR_FRAME_INFO
1347 to initialize the inner-most frame. */
1348 if (INIT_EXTRA_FRAME_INFO_P ())
1350 gdb_assert (prev_frame
->level
== 0);
1351 INIT_EXTRA_FRAME_INFO (0, prev_frame
);
1358 get_frame_pc (struct frame_info
*frame
)
1364 pc_notcurrent (struct frame_info
*frame
)
1366 /* If FRAME is not the innermost frame, that normally means that
1367 FRAME->pc points at the return instruction (which is *after* the
1368 call instruction), and we want to get the line containing the
1369 call (because the call is where the user thinks the program is).
1370 However, if the next frame is either a SIGTRAMP_FRAME or a
1371 DUMMY_FRAME, then the next frame will contain a saved interrupt
1372 PC and such a PC indicates the current (rather than next)
1373 instruction/line, consequently, for such cases, want to get the
1374 line containing fi->pc. */
1375 struct frame_info
*next
= get_next_frame (frame
);
1376 int notcurrent
= (next
!= NULL
&& get_frame_type (next
) == NORMAL_FRAME
);
1381 find_frame_sal (struct frame_info
*frame
, struct symtab_and_line
*sal
)
1383 (*sal
) = find_pc_line (frame
->pc
, pc_notcurrent (frame
));
1386 /* Per "frame.h", return the ``address'' of the frame. Code should
1387 really be using get_frame_id(). */
1389 get_frame_base (struct frame_info
*fi
)
1394 /* Level of the selected frame: 0 for innermost, 1 for its caller, ...
1395 or -1 for a NULL frame. */
1398 frame_relative_level (struct frame_info
*fi
)
1407 get_frame_type (struct frame_info
*frame
)
1409 /* Some targets still don't use [generic] dummy frames. Catch them
1411 if (!DEPRECATED_USE_GENERIC_DUMMY_FRAMES
1412 && deprecated_frame_in_dummy (frame
))
1418 deprecated_set_frame_type (struct frame_info
*frame
, enum frame_type type
)
1420 /* Arrrg! See comment in "frame.h". */
1424 #ifdef FRAME_FIND_SAVED_REGS
1425 /* XXX - deprecated. This is a compatibility function for targets
1426 that do not yet implement FRAME_INIT_SAVED_REGS. */
1427 /* Find the addresses in which registers are saved in FRAME. */
1430 deprecated_get_frame_saved_regs (struct frame_info
*frame
,
1431 struct frame_saved_regs
*saved_regs_addr
)
1433 if (frame
->saved_regs
== NULL
)
1435 frame
->saved_regs
= (CORE_ADDR
*)
1436 frame_obstack_zalloc (SIZEOF_FRAME_SAVED_REGS
);
1438 if (saved_regs_addr
== NULL
)
1440 struct frame_saved_regs saved_regs
;
1441 FRAME_FIND_SAVED_REGS (frame
, saved_regs
);
1442 memcpy (frame
->saved_regs
, &saved_regs
, SIZEOF_FRAME_SAVED_REGS
);
1446 FRAME_FIND_SAVED_REGS (frame
, *saved_regs_addr
);
1447 memcpy (frame
->saved_regs
, saved_regs_addr
, SIZEOF_FRAME_SAVED_REGS
);
1452 struct frame_extra_info
*
1453 get_frame_extra_info (struct frame_info
*fi
)
1455 return fi
->extra_info
;
1458 struct frame_extra_info
*
1459 frame_extra_info_zalloc (struct frame_info
*fi
, long size
)
1461 fi
->extra_info
= frame_obstack_zalloc (size
);
1462 return fi
->extra_info
;
1466 deprecated_update_frame_pc_hack (struct frame_info
*frame
, CORE_ADDR pc
)
1468 /* See comment in "frame.h". */
1469 gdb_assert (frame
->next
!= NULL
);
1474 deprecated_update_frame_base_hack (struct frame_info
*frame
, CORE_ADDR base
)
1476 /* See comment in "frame.h". */
1477 frame
->frame
= base
;
1481 deprecated_set_frame_saved_regs_hack (struct frame_info
*frame
,
1482 CORE_ADDR
*saved_regs
)
1484 frame
->saved_regs
= saved_regs
;
1488 deprecated_set_frame_extra_info_hack (struct frame_info
*frame
,
1489 struct frame_extra_info
*extra_info
)
1491 frame
->extra_info
= extra_info
;
1495 deprecated_set_frame_next_hack (struct frame_info
*fi
,
1496 struct frame_info
*next
)
1502 deprecated_set_frame_prev_hack (struct frame_info
*fi
,
1503 struct frame_info
*prev
)
1509 deprecated_get_frame_context (struct frame_info
*fi
)
1515 deprecated_set_frame_context (struct frame_info
*fi
,
1516 struct context
*context
)
1518 fi
->context
= context
;
1522 deprecated_frame_xmalloc (void)
1524 struct frame_info
*frame
= XMALLOC (struct frame_info
);
1525 memset (frame
, 0, sizeof (struct frame_info
));
1530 deprecated_frame_xmalloc_with_cleanup (long sizeof_saved_regs
,
1531 long sizeof_extra_info
)
1533 struct frame_info
*frame
= deprecated_frame_xmalloc ();
1534 make_cleanup (xfree
, frame
);
1535 if (sizeof_saved_regs
> 0)
1537 frame
->saved_regs
= xcalloc (1, sizeof_saved_regs
);
1538 make_cleanup (xfree
, frame
->saved_regs
);
1540 if (sizeof_extra_info
> 0)
1542 frame
->extra_info
= xcalloc (1, sizeof_extra_info
);
1543 make_cleanup (xfree
, frame
->extra_info
);
1549 _initialize_frame (void)
1551 obstack_init (&frame_cache_obstack
);
1553 /* FIXME: cagney/2003-01-19: This command needs a rename. Suggest
1554 `set backtrace {past,beyond,...}-main'. Also suggest adding `set
1555 backtrace ...-start' to control backtraces past start. The
1556 problem with `below' is that it stops the `up' command. */
1558 add_setshow_boolean_cmd ("backtrace-below-main", class_obscure
,
1559 &backtrace_below_main
, "\
1560 Set whether backtraces should continue past \"main\".\n\
1561 Normally the caller of \"main\" is not of interest, so GDB will terminate\n\
1562 the backtrace at \"main\". Set this variable if you need to see the rest\n\
1563 of the stack trace.", "\
1564 Show whether backtraces should continue past \"main\".\n\
1565 Normally the caller of \"main\" is not of interest, so GDB will terminate\n\
1566 the backtrace at \"main\". Set this variable if you need to see the rest\n\
1567 of the stack trace.",
1568 NULL
, NULL
, &setlist
, &showlist
);
1571 /* Debug this files internals. */
1572 add_show_from_set (add_set_cmd ("frame", class_maintenance
, var_zinteger
,
1573 &frame_debug
, "Set frame debugging.\n\
1574 When non-zero, frame specific internal debugging is enabled.", &setdebuglist
),