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 DEPRECATED_FRAME_INIT_SAVED_REGS method should be using this
614 gdb_assert (DEPRECATED_FRAME_INIT_SAVED_REGS_P ());
616 /* Load the saved_regs register cache. */
617 if (get_frame_saved_regs (frame
) == NULL
)
618 DEPRECATED_FRAME_INIT_SAVED_REGS (frame
);
620 if (get_frame_saved_regs (frame
) != NULL
621 && get_frame_saved_regs (frame
)[regnum
] != 0)
623 if (regnum
== SP_REGNUM
)
625 /* SP register treated specially. */
631 store_address (bufferp
, REGISTER_RAW_SIZE (regnum
),
632 get_frame_saved_regs (frame
)[regnum
]);
636 /* Any other register is saved in memory, fetch it but cache
637 a local copy of its value. */
639 *lvalp
= lval_memory
;
640 *addrp
= get_frame_saved_regs (frame
)[regnum
];
645 /* Save each register value, as it is read in, in a
646 frame based cache. */
647 void **regs
= (*cache
);
650 int sizeof_cache
= ((NUM_REGS
+ NUM_PSEUDO_REGS
)
652 regs
= frame_obstack_zalloc (sizeof_cache
);
655 if (regs
[regnum
] == NULL
)
658 = frame_obstack_zalloc (REGISTER_RAW_SIZE (regnum
));
659 read_memory (get_frame_saved_regs (frame
)[regnum
], regs
[regnum
],
660 REGISTER_RAW_SIZE (regnum
));
662 memcpy (bufferp
, regs
[regnum
], REGISTER_RAW_SIZE (regnum
));
664 /* Read the value in from memory. */
665 read_memory (get_frame_saved_regs (frame
)[regnum
], bufferp
,
666 REGISTER_RAW_SIZE (regnum
));
673 /* No luck, assume this and the next frame have the same register
674 value. Pass the request down the frame chain to the next frame.
675 Hopefully that will find the register's location, either in a
676 register or in memory. */
677 frame_register (frame
, regnum
, optimizedp
, lvalp
, addrp
, realnump
,
682 frame_saved_regs_pc_unwind (struct frame_info
*frame
, void **cache
)
684 gdb_assert (FRAME_SAVED_PC_P ());
685 return FRAME_SAVED_PC (frame
);
689 frame_saved_regs_id_unwind (struct frame_info
*next_frame
, void **cache
,
696 /* Start out by assuming it's NULL. */
697 (*id
) = null_frame_id
;
699 if (frame_relative_level (next_frame
) <= 0)
700 /* FIXME: 2002-11-09: Frameless functions can occure anywhere in
701 the frame chain, not just the inner most frame! The generic,
702 per-architecture, frame code should handle this and the below
703 should simply be removed. */
704 fromleaf
= FRAMELESS_FUNCTION_INVOCATION (next_frame
);
709 /* A frameless inner-most frame. The `FP' (which isn't an
710 architecture frame-pointer register!) of the caller is the same
712 /* FIXME: 2002-11-09: There isn't any reason to special case this
713 edge condition. Instead the per-architecture code should hande
715 base
= get_frame_base (next_frame
);
718 /* Two macros defined in tm.h specify the machine-dependent
719 actions to be performed here.
721 First, get the frame's chain-pointer.
723 If that is zero, the frame is the outermost frame or a leaf
724 called by the outermost frame. This means that if start
725 calls main without a frame, we'll return 0 (which is fine
728 Nope; there's a problem. This also returns when the current
729 routine is a leaf of main. This is unacceptable. We move
730 this to after the ffi test; I'd rather have backtraces from
731 start go curfluy than have an abort called from main not show
733 gdb_assert (FRAME_CHAIN_P ());
734 base
= FRAME_CHAIN (next_frame
);
736 if (!frame_chain_valid (base
, next_frame
))
742 /* FIXME: cagney/2002-06-08: This should probably return the frame's
743 function and not the PC (a.k.a. resume address). */
744 pc
= frame_pc_unwind (next_frame
);
750 frame_saved_regs_pop (struct frame_info
*fi
, void **cache
,
751 struct regcache
*regcache
)
753 gdb_assert (POP_FRAME_P ());
757 const struct frame_unwind trad_frame_unwinder
= {
758 frame_saved_regs_pop
,
759 frame_saved_regs_pc_unwind
,
760 frame_saved_regs_id_unwind
,
761 frame_saved_regs_register_unwind
763 const struct frame_unwind
*trad_frame_unwind
= &trad_frame_unwinder
;
766 /* Function: get_saved_register
767 Find register number REGNUM relative to FRAME and put its (raw,
768 target format) contents in *RAW_BUFFER.
770 Set *OPTIMIZED if the variable was optimized out (and thus can't be
771 fetched). Note that this is never set to anything other than zero
772 in this implementation.
774 Set *LVAL to lval_memory, lval_register, or not_lval, depending on
775 whether the value was fetched from memory, from a register, or in a
776 strange and non-modifiable way (e.g. a frame pointer which was
777 calculated rather than fetched). We will use not_lval for values
778 fetched from generic dummy frames.
780 Set *ADDRP to the address, either in memory or as a REGISTER_BYTE
781 offset into the registers array. If the value is stored in a dummy
782 frame, set *ADDRP to zero.
784 To use this implementation, define a function called
785 "get_saved_register" in your target code, which simply passes all
786 of its arguments to this function.
788 The argument RAW_BUFFER must point to aligned memory. */
791 deprecated_generic_get_saved_register (char *raw_buffer
, int *optimized
,
793 struct frame_info
*frame
, int regnum
,
794 enum lval_type
*lval
)
796 if (!target_has_registers
)
797 error ("No registers.");
799 gdb_assert (DEPRECATED_FRAME_INIT_SAVED_REGS_P ());
801 /* Normal systems don't optimize out things with register numbers. */
802 if (optimized
!= NULL
)
805 if (addrp
) /* default assumption: not found in memory */
808 /* Note: since the current frame's registers could only have been
809 saved by frames INTERIOR TO the current frame, we skip examining
810 the current frame itself: otherwise, we would be getting the
811 previous frame's registers which were saved by the current frame. */
815 for (frame
= get_next_frame (frame
);
816 frame_relative_level (frame
) >= 0;
817 frame
= get_next_frame (frame
))
819 if (get_frame_type (frame
) == DUMMY_FRAME
)
821 if (lval
) /* found it in a CALL_DUMMY frame */
824 /* FIXME: cagney/2002-06-26: This should be via the
825 gdbarch_register_read() method so that it, on the
826 fly, constructs either a raw or pseudo register
827 from the raw register cache. */
829 (generic_find_dummy_frame (get_frame_pc (frame
),
830 get_frame_base (frame
)),
835 DEPRECATED_FRAME_INIT_SAVED_REGS (frame
);
836 if (get_frame_saved_regs (frame
) != NULL
837 && get_frame_saved_regs (frame
)[regnum
] != 0)
839 if (lval
) /* found it saved on the stack */
841 if (regnum
== SP_REGNUM
)
843 if (raw_buffer
) /* SP register treated specially */
844 store_address (raw_buffer
, REGISTER_RAW_SIZE (regnum
),
845 get_frame_saved_regs (frame
)[regnum
]);
849 if (addrp
) /* any other register */
850 *addrp
= get_frame_saved_regs (frame
)[regnum
];
852 read_memory (get_frame_saved_regs (frame
)[regnum
], raw_buffer
,
853 REGISTER_RAW_SIZE (regnum
));
860 /* If we get thru the loop to this point, it means the register was
861 not saved in any frame. Return the actual live-register value. */
863 if (lval
) /* found it in a live register */
864 *lval
= lval_register
;
866 *addrp
= REGISTER_BYTE (regnum
);
868 deprecated_read_register_gen (regnum
, raw_buffer
);
871 /* Determine the frame's type based on its PC. */
873 static enum frame_type
874 frame_type_from_pc (CORE_ADDR pc
)
876 /* FIXME: cagney/2002-11-24: Can't yet directly call
877 pc_in_dummy_frame() as some architectures don't set
878 PC_IN_CALL_DUMMY() to generic_pc_in_call_dummy() (remember the
879 latter is implemented by simply calling pc_in_dummy_frame). */
880 if (DEPRECATED_USE_GENERIC_DUMMY_FRAMES
881 && DEPRECATED_PC_IN_CALL_DUMMY (pc
, 0, 0))
886 find_pc_partial_function (pc
, &name
, NULL
, NULL
);
887 if (PC_IN_SIGTRAMP (pc
, name
))
888 return SIGTRAMP_FRAME
;
894 /* Create an arbitrary (i.e. address specified by user) or innermost frame.
895 Always returns a non-NULL value. */
898 create_new_frame (CORE_ADDR addr
, CORE_ADDR pc
)
900 struct frame_info
*fi
;
902 fi
= frame_obstack_zalloc (sizeof (struct frame_info
));
906 fi
->next
= create_sentinel_frame (current_regcache
);
907 fi
->type
= frame_type_from_pc (pc
);
909 if (DEPRECATED_INIT_EXTRA_FRAME_INFO_P ())
910 DEPRECATED_INIT_EXTRA_FRAME_INFO (0, fi
);
912 /* Select/initialize an unwind function. */
913 fi
->unwind
= frame_unwind_find_by_pc (current_gdbarch
, fi
->pc
);
918 /* Return the frame that FRAME calls (NULL if FRAME is the innermost
919 frame). Be careful to not fall off the bottom of the frame chain
920 and onto the sentinel frame. */
923 get_next_frame (struct frame_info
*frame
)
925 if (frame
->level
> 0)
931 /* Flush the entire frame cache. */
934 flush_cached_frames (void)
936 /* Since we can't really be sure what the first object allocated was */
937 obstack_free (&frame_cache_obstack
, 0);
938 obstack_init (&frame_cache_obstack
);
940 current_frame
= NULL
; /* Invalidate cache */
942 annotate_frames_invalid ();
945 /* Flush the frame cache, and start a new one if necessary. */
948 reinit_frame_cache (void)
950 flush_cached_frames ();
952 /* FIXME: The inferior_ptid test is wrong if there is a corefile. */
953 if (PIDGET (inferior_ptid
) != 0)
955 select_frame (get_current_frame ());
959 /* Create the previous frame using the deprecated methods
960 INIT_EXTRA_INFO, INIT_FRAME_PC and INIT_FRAME_PC_FIRST. */
962 static struct frame_info
*
963 legacy_get_prev_frame (struct frame_info
*next_frame
)
965 CORE_ADDR address
= 0;
966 struct frame_info
*prev
;
969 /* This code only works on normal frames. A sentinel frame, where
970 the level is -1, should never reach this code. */
971 gdb_assert (next_frame
->level
>= 0);
973 /* On some machines it is possible to call a function without
974 setting up a stack frame for it. On these machines, we
975 define this macro to take two args; a frameinfo pointer
976 identifying a frame and a variable to set or clear if it is
977 or isn't leafless. */
979 /* Still don't want to worry about this except on the innermost
980 frame. This macro will set FROMLEAF if NEXT_FRAME is a frameless
981 function invocation. */
982 if (next_frame
->level
== 0)
983 /* FIXME: 2002-11-09: Frameless functions can occure anywhere in
984 the frame chain, not just the inner most frame! The generic,
985 per-architecture, frame code should handle this and the below
986 should simply be removed. */
987 fromleaf
= FRAMELESS_FUNCTION_INVOCATION (next_frame
);
992 /* A frameless inner-most frame. The `FP' (which isn't an
993 architecture frame-pointer register!) of the caller is the same
995 /* FIXME: 2002-11-09: There isn't any reason to special case this
996 edge condition. Instead the per-architecture code should hande
998 address
= get_frame_base (next_frame
);
1001 /* Two macros defined in tm.h specify the machine-dependent
1002 actions to be performed here.
1004 First, get the frame's chain-pointer.
1006 If that is zero, the frame is the outermost frame or a leaf
1007 called by the outermost frame. This means that if start
1008 calls main without a frame, we'll return 0 (which is fine
1011 Nope; there's a problem. This also returns when the current
1012 routine is a leaf of main. This is unacceptable. We move
1013 this to after the ffi test; I'd rather have backtraces from
1014 start go curfluy than have an abort called from main not show
1016 gdb_assert (FRAME_CHAIN_P ());
1017 address
= FRAME_CHAIN (next_frame
);
1019 if (!frame_chain_valid (address
, next_frame
))
1025 /* Create an initially zero previous frame. */
1026 prev
= frame_obstack_zalloc (sizeof (struct frame_info
));
1029 next_frame
->prev
= prev
;
1030 prev
->next
= next_frame
;
1031 prev
->frame
= address
;
1032 prev
->level
= next_frame
->level
+ 1;
1033 /* FIXME: cagney/2002-11-18: Should be setting the frame's type
1034 here, before anything else, and not last. Various INIT functions
1035 are full of work-arounds for the frames type not being set
1036 correctly from the word go. Ulgh! */
1037 prev
->type
= NORMAL_FRAME
;
1039 /* This change should not be needed, FIXME! We should determine
1040 whether any targets *need* DEPRECATED_INIT_FRAME_PC to happen
1041 after DEPRECATED_INIT_EXTRA_FRAME_INFO and come up with a simple
1042 way to express what goes on here.
1044 DEPRECATED_INIT_EXTRA_FRAME_INFO is called from two places:
1045 create_new_frame (where the PC is already set up) and here (where
1046 it isn't). DEPRECATED_INIT_FRAME_PC is only called from here,
1047 always after DEPRECATED_INIT_EXTRA_FRAME_INFO.
1049 The catch is the MIPS, where DEPRECATED_INIT_EXTRA_FRAME_INFO
1050 requires the PC value (which hasn't been set yet). Some other
1051 machines appear to require DEPRECATED_INIT_EXTRA_FRAME_INFO
1052 before they can do DEPRECATED_INIT_FRAME_PC. Phoo.
1054 We shouldn't need DEPRECATED_INIT_FRAME_PC_FIRST to add more
1055 complication to an already overcomplicated part of GDB.
1056 gnu@cygnus.com, 15Sep92.
1058 Assuming that some machines need DEPRECATED_INIT_FRAME_PC after
1059 DEPRECATED_INIT_EXTRA_FRAME_INFO, one possible scheme:
1061 SETUP_INNERMOST_FRAME(): Default version is just create_new_frame
1062 (read_fp ()), read_pc ()). Machines with extra frame info would
1063 do that (or the local equivalent) and then set the extra fields.
1065 SETUP_ARBITRARY_FRAME(argc, argv): Only change here is that
1066 create_new_frame would no longer init extra frame info;
1067 SETUP_ARBITRARY_FRAME would have to do that.
1069 INIT_PREV_FRAME(fromleaf, prev) Replace
1070 DEPRECATED_INIT_EXTRA_FRAME_INFO and DEPRECATED_INIT_FRAME_PC.
1071 This should also return a flag saying whether to keep the new
1072 frame, or whether to discard it, because on some machines (e.g.
1073 mips) it is really awkward to have FRAME_CHAIN_VALID called
1074 BEFORE DEPRECATED_INIT_EXTRA_FRAME_INFO (there is no good way to
1075 get information deduced in FRAME_CHAIN_VALID into the extra
1076 fields of the new frame). std_frame_pc(fromleaf, prev)
1078 This is the default setting for INIT_PREV_FRAME. It just does
1079 what the default DEPRECATED_INIT_FRAME_PC does. Some machines
1080 will call it from INIT_PREV_FRAME (either at the beginning, the
1081 end, or in the middle). Some machines won't use it.
1083 kingdon@cygnus.com, 13Apr93, 31Jan94, 14Dec94. */
1085 /* NOTE: cagney/2002-11-09: Just ignore the above! There is no
1086 reason for things to be this complicated.
1088 The trick is to assume that there is always a frame. Instead of
1089 special casing the inner-most frame, create fake frame
1090 (containing the hardware registers) that is inner to the
1091 user-visible inner-most frame (...) and then unwind from that.
1092 That way architecture code can use use the standard
1093 frame_XX_unwind() functions and not differentiate between the
1094 inner most and any other case.
1096 Since there is always a frame to unwind from, there is always
1097 somewhere (NEXT_FRAME) to store all the info needed to construct
1098 a new (previous) frame without having to first create it. This
1099 means that the convolution below - needing to carefully order a
1100 frame's initialization - isn't needed.
1102 The irony here though, is that FRAME_CHAIN(), at least for a more
1103 up-to-date architecture, always calls FRAME_SAVED_PC(), and
1104 FRAME_SAVED_PC() computes the PC but without first needing the
1105 frame! Instead of the convolution below, we could have simply
1106 called FRAME_SAVED_PC() and been done with it! Note that
1107 FRAME_SAVED_PC() is being superseed by frame_pc_unwind() and that
1108 function does have somewhere to cache that PC value. */
1110 if (DEPRECATED_INIT_FRAME_PC_FIRST_P ())
1111 prev
->pc
= (DEPRECATED_INIT_FRAME_PC_FIRST (fromleaf
, prev
));
1113 if (DEPRECATED_INIT_EXTRA_FRAME_INFO_P ())
1114 DEPRECATED_INIT_EXTRA_FRAME_INFO (fromleaf
, prev
);
1116 /* This entry is in the frame queue now, which is good since
1117 FRAME_SAVED_PC may use that queue to figure out its value (see
1118 tm-sparc.h). We want the pc saved in the inferior frame. */
1119 if (DEPRECATED_INIT_FRAME_PC_P ())
1120 prev
->pc
= DEPRECATED_INIT_FRAME_PC (fromleaf
, prev
);
1122 /* If ->frame and ->pc are unchanged, we are in the process of
1123 getting ourselves into an infinite backtrace. Some architectures
1124 check this in FRAME_CHAIN or thereabouts, but it seems like there
1125 is no reason this can't be an architecture-independent check. */
1126 if (prev
->frame
== next_frame
->frame
1127 && prev
->pc
== next_frame
->pc
)
1129 next_frame
->prev
= NULL
;
1130 obstack_free (&frame_cache_obstack
, prev
);
1134 /* Initialize the code used to unwind the frame PREV based on the PC
1135 (and probably other architectural information). The PC lets you
1136 check things like the debug info at that point (dwarf2cfi?) and
1137 use that to decide how the frame should be unwound. */
1138 prev
->unwind
= frame_unwind_find_by_pc (current_gdbarch
, prev
->pc
);
1140 /* NOTE: cagney/2002-11-18: The code segments, found in
1141 create_new_frame and get_prev_frame(), that initializes the
1142 frames type is subtly different. The latter only updates ->type
1143 when it encounters a SIGTRAMP_FRAME or DUMMY_FRAME. This stops
1144 get_prev_frame() overriding the frame's type when the INIT code
1145 has previously set it. This is really somewhat bogus. The
1146 initialization, as seen in create_new_frame(), should occur
1147 before the INIT function has been called. */
1148 if (DEPRECATED_USE_GENERIC_DUMMY_FRAMES
1149 && (DEPRECATED_PC_IN_CALL_DUMMY_P ()
1150 ? DEPRECATED_PC_IN_CALL_DUMMY (prev
->pc
, 0, 0)
1151 : pc_in_dummy_frame (prev
->pc
)))
1152 prev
->type
= DUMMY_FRAME
;
1155 /* FIXME: cagney/2002-11-10: This should be moved to before the
1156 INIT code above so that the INIT code knows what the frame's
1157 type is (in fact, for a [generic] dummy-frame, the type can
1158 be set and then the entire initialization can be skipped.
1159 Unforunatly, its the INIT code that sets the PC (Hmm, catch
1162 find_pc_partial_function (prev
->pc
, &name
, NULL
, NULL
);
1163 if (PC_IN_SIGTRAMP (prev
->pc
, name
))
1164 prev
->type
= SIGTRAMP_FRAME
;
1165 /* FIXME: cagney/2002-11-11: Leave prev->type alone. Some
1166 architectures are forcing the frame's type in INIT so we
1167 don't want to override it here. Remember, NORMAL_FRAME == 0,
1168 so it all works (just :-/). Once this initialization is
1169 moved to the start of this function, all this nastness will
1176 /* Return a structure containing various interesting information
1177 about the frame that called NEXT_FRAME. Returns NULL
1178 if there is no such frame. */
1181 get_prev_frame (struct frame_info
*next_frame
)
1183 struct frame_info
*prev_frame
;
1185 /* Return the inner-most frame, when the caller passes in NULL. */
1186 /* NOTE: cagney/2002-11-09: Not sure how this would happen. The
1187 caller should have previously obtained a valid frame using
1188 get_selected_frame() and then called this code - only possibility
1189 I can think of is code behaving badly.
1191 NOTE: cagney/2003-01-10: Talk about code behaving badly. Check
1192 block_innermost_frame(). It does the sequence: frame = NULL;
1193 while (1) { frame = get_prev_frame (frame); .... }. Ulgh! Why
1194 it couldn't be written better, I don't know.
1196 NOTE: cagney/2003-01-11: I suspect what is happening is
1197 block_innermost_frame() is, when the target has no state
1198 (registers, memory, ...), still calling this function. The
1199 assumption being that this function will return NULL indicating
1200 that a frame isn't possible, rather than checking that the target
1201 has state and then calling get_current_frame() and
1202 get_prev_frame(). This is a guess mind. */
1203 if (next_frame
== NULL
)
1205 /* NOTE: cagney/2002-11-09: There was a code segment here that
1206 would error out when CURRENT_FRAME was NULL. The comment
1207 that went with it made the claim ...
1209 ``This screws value_of_variable, which just wants a nice
1210 clean NULL return from block_innermost_frame if there are no
1211 frames. I don't think I've ever seen this message happen
1212 otherwise. And returning NULL here is a perfectly legitimate
1215 Per the above, this code shouldn't even be called with a NULL
1217 return current_frame
;
1220 /* There is always a frame. If this assertion fails, suspect that
1221 something should be calling get_selected_frame() or
1222 get_current_frame(). */
1223 gdb_assert (next_frame
!= NULL
);
1225 if (next_frame
->level
>= 0
1226 && !backtrace_below_main
1227 && inside_main_func (get_frame_pc (next_frame
)))
1228 /* Don't unwind past main(), bug always unwind the sentinel frame.
1229 Note, this is done _before_ the frame has been marked as
1230 previously unwound. That way if the user later decides to
1231 allow unwinds past main(), that just happens. */
1234 fprintf_unfiltered (gdb_stdlog
,
1235 "Outermost frame - inside main func.\n");
1239 /* Only try to do the unwind once. */
1240 if (next_frame
->prev_p
)
1241 return next_frame
->prev
;
1242 next_frame
->prev_p
= 1;
1244 /* If we're inside the entry file, it isn't valid. Don't apply this
1245 test to a dummy frame - dummy frame PC's typically land in the
1246 entry file. Don't apply this test to the sentinel frame.
1247 Sentinel frames should always be allowed to unwind. */
1248 /* NOTE: drow/2002-12-25: should there be a way to disable this
1249 check? It assumes a single small entry file, and the way some
1250 debug readers (e.g. dbxread) figure out which object is the
1251 entry file is somewhat hokey. */
1252 /* NOTE: cagney/2003-01-10: If there is a way of disabling this test
1253 then it should probably be moved to before the ->prev_p test,
1255 if (next_frame
->type
!= DUMMY_FRAME
&& next_frame
->level
>= 0
1256 && inside_entry_file (get_frame_pc (next_frame
)))
1259 fprintf_unfiltered (gdb_stdlog
,
1260 "Outermost frame - inside entry file\n");
1264 /* If we're already inside the entry function for the main objfile,
1265 then it isn't valid. Don't apply this test to a dummy frame -
1266 dummy frame PC's typically land in the entry func. Don't apply
1267 this test to the sentinel frame. Sentinel frames should always
1268 be allowed to unwind. */
1269 /* NOTE: cagney/2003-02-25: Don't enable until someone has found
1270 hard evidence that this is needed. */
1272 && next_frame
->type
!= DUMMY_FRAME
&& next_frame
->level
>= 0
1273 && inside_entry_func (get_frame_pc (next_frame
)))
1276 fprintf_unfiltered (gdb_stdlog
,
1277 "Outermost frame - inside entry func\n");
1281 /* If any of the old frame initialization methods are around, use
1282 the legacy get_prev_frame method. Just don't try to unwind a
1283 sentinel frame using that method - it doesn't work. All sentinal
1284 frames use the new unwind code. */
1285 if ((DEPRECATED_INIT_FRAME_PC_P ()
1286 || DEPRECATED_INIT_FRAME_PC_FIRST_P ()
1287 || DEPRECATED_INIT_EXTRA_FRAME_INFO_P ()
1288 || FRAME_CHAIN_P ())
1289 && next_frame
->level
>= 0)
1291 prev_frame
= legacy_get_prev_frame (next_frame
);
1292 if (frame_debug
&& prev_frame
== NULL
)
1293 fprintf_unfiltered (gdb_stdlog
,
1294 "Outermost frame - legacy_get_prev_frame NULL.\n");
1298 /* Allocate the new frame but do not wire it in to the frame chain.
1299 Some (bad) code in INIT_FRAME_EXTRA_INFO tries to look along
1300 frame->next to pull some fancy tricks (of course such code is, by
1301 definition, recursive). Try to prevent it.
1303 There is no reason to worry about memory leaks, should the
1304 remainder of the function fail. The allocated memory will be
1305 quickly reclaimed when the frame cache is flushed, and the `we've
1306 been here before' check above will stop repeated memory
1307 allocation calls. */
1308 prev_frame
= FRAME_OBSTACK_ZALLOC (struct frame_info
);
1309 prev_frame
->level
= next_frame
->level
+ 1;
1311 /* Try to unwind the PC. If that doesn't work, assume we've reached
1312 the oldest frame and simply return. Is there a better sentinal
1313 value? The unwound PC value is then used to initialize the new
1314 previous frame's type.
1316 Note that the pc-unwind is intentionally performed before the
1317 frame chain. This is ok since, for old targets, both
1318 frame_pc_unwind (nee, FRAME_SAVED_PC) and FRAME_CHAIN()) assume
1319 NEXT_FRAME's data structures have already been initialized (using
1320 DEPRECATED_INIT_EXTRA_FRAME_INFO) and hence the call order
1323 By unwinding the PC first, it becomes possible to, in the case of
1324 a dummy frame, avoid also unwinding the frame ID. This is
1325 because (well ignoring the PPC) a dummy frame can be located
1326 using NEXT_FRAME's frame ID. */
1328 prev_frame
->pc
= frame_pc_unwind (next_frame
);
1329 if (prev_frame
->pc
== 0)
1331 /* The allocated PREV_FRAME will be reclaimed when the frame
1332 obstack is next purged. */
1334 fprintf_unfiltered (gdb_stdlog
,
1335 "Outermost frame - unwound PC zero\n");
1338 prev_frame
->type
= frame_type_from_pc (prev_frame
->pc
);
1340 /* Set the unwind functions based on that identified PC. */
1341 prev_frame
->unwind
= frame_unwind_find_by_pc (current_gdbarch
,
1344 /* FIXME: cagney/2003-01-13: A dummy frame doesn't need to unwind
1345 the frame ID because the frame ID comes from the previous frame.
1346 The other frames do though. True? */
1348 /* FIXME: cagney/2002-12-18: Instead of this hack, should just
1349 save the frame ID directly. */
1350 struct frame_id id
= frame_id_unwind (next_frame
);
1351 /* Check that the unwound ID is valid. As of 2003-02-24 the
1352 x86-64 was returning an invalid frame ID when trying to do an
1353 unwind a sentinel frame that belonged to a frame dummy. */
1354 if (!frame_id_p (id
))
1357 fprintf_unfiltered (gdb_stdlog
,
1358 "Outermost frame - unwound frame ID invalid\n");
1361 /* Check that the new frame isn't inner to (younger, below, next)
1362 the old frame. If that happens the frame unwind is going
1364 /* FIXME: cagney/2003-02-25: Ignore the sentinel frame since that
1365 doesn't have a valid frame ID. Should instead set the sentinel
1366 frame's frame ID to a `sentinel'. Leave it until after the
1367 switch to storing the frame ID, instead of the frame base, in
1368 the frame object. */
1369 if (next_frame
->level
>= 0
1370 && frame_id_inner (id
, get_frame_id (next_frame
)))
1371 error ("Unwound frame inner-to selected frame (corrupt stack?)");
1372 /* Note that, due to frameless functions, the stronger test of the
1373 new frame being outer to the old frame can't be used -
1374 frameless functions differ by only their PC value. */
1375 prev_frame
->frame
= id
.base
;
1379 next_frame
->prev
= prev_frame
;
1380 prev_frame
->next
= next_frame
;
1382 /* FIXME: cagney/2002-01-19: This call will go away. Instead of
1383 initializing extra info, all frames will use the frame_cache
1384 (passed to the unwind functions) to store additional frame info.
1385 Unfortunatly legacy targets can't use legacy_get_prev_frame() to
1386 unwind the sentinel frame and, consequently, are forced to take
1387 this code path and rely on the below call to
1388 DEPRECATED_INIT_EXTRA_FRAME_INFO to initialize the inner-most
1390 if (DEPRECATED_INIT_EXTRA_FRAME_INFO_P ())
1392 gdb_assert (prev_frame
->level
== 0);
1393 DEPRECATED_INIT_EXTRA_FRAME_INFO (0, prev_frame
);
1400 get_frame_pc (struct frame_info
*frame
)
1406 pc_notcurrent (struct frame_info
*frame
)
1408 /* If FRAME is not the innermost frame, that normally means that
1409 FRAME->pc points at the return instruction (which is *after* the
1410 call instruction), and we want to get the line containing the
1411 call (because the call is where the user thinks the program is).
1412 However, if the next frame is either a SIGTRAMP_FRAME or a
1413 DUMMY_FRAME, then the next frame will contain a saved interrupt
1414 PC and such a PC indicates the current (rather than next)
1415 instruction/line, consequently, for such cases, want to get the
1416 line containing fi->pc. */
1417 struct frame_info
*next
= get_next_frame (frame
);
1418 int notcurrent
= (next
!= NULL
&& get_frame_type (next
) == NORMAL_FRAME
);
1423 find_frame_sal (struct frame_info
*frame
, struct symtab_and_line
*sal
)
1425 (*sal
) = find_pc_line (frame
->pc
, pc_notcurrent (frame
));
1428 /* Per "frame.h", return the ``address'' of the frame. Code should
1429 really be using get_frame_id(). */
1431 get_frame_base (struct frame_info
*fi
)
1436 /* Level of the selected frame: 0 for innermost, 1 for its caller, ...
1437 or -1 for a NULL frame. */
1440 frame_relative_level (struct frame_info
*fi
)
1449 get_frame_type (struct frame_info
*frame
)
1451 /* Some targets still don't use [generic] dummy frames. Catch them
1453 if (!DEPRECATED_USE_GENERIC_DUMMY_FRAMES
1454 && deprecated_frame_in_dummy (frame
))
1460 deprecated_set_frame_type (struct frame_info
*frame
, enum frame_type type
)
1462 /* Arrrg! See comment in "frame.h". */
1466 #ifdef FRAME_FIND_SAVED_REGS
1467 /* XXX - deprecated. This is a compatibility function for targets
1468 that do not yet implement DEPRECATED_FRAME_INIT_SAVED_REGS. */
1469 /* Find the addresses in which registers are saved in FRAME. */
1472 deprecated_get_frame_saved_regs (struct frame_info
*frame
,
1473 struct frame_saved_regs
*saved_regs_addr
)
1475 if (frame
->saved_regs
== NULL
)
1477 frame
->saved_regs
= (CORE_ADDR
*)
1478 frame_obstack_zalloc (SIZEOF_FRAME_SAVED_REGS
);
1480 if (saved_regs_addr
== NULL
)
1482 struct frame_saved_regs saved_regs
;
1483 FRAME_FIND_SAVED_REGS (frame
, saved_regs
);
1484 memcpy (frame
->saved_regs
, &saved_regs
, SIZEOF_FRAME_SAVED_REGS
);
1488 FRAME_FIND_SAVED_REGS (frame
, *saved_regs_addr
);
1489 memcpy (frame
->saved_regs
, saved_regs_addr
, SIZEOF_FRAME_SAVED_REGS
);
1494 struct frame_extra_info
*
1495 get_frame_extra_info (struct frame_info
*fi
)
1497 return fi
->extra_info
;
1500 struct frame_extra_info
*
1501 frame_extra_info_zalloc (struct frame_info
*fi
, long size
)
1503 fi
->extra_info
= frame_obstack_zalloc (size
);
1504 return fi
->extra_info
;
1508 deprecated_update_frame_pc_hack (struct frame_info
*frame
, CORE_ADDR pc
)
1510 /* See comment in "frame.h". */
1511 gdb_assert (frame
->next
!= NULL
);
1516 deprecated_update_frame_base_hack (struct frame_info
*frame
, CORE_ADDR base
)
1518 /* See comment in "frame.h". */
1519 frame
->frame
= base
;
1523 deprecated_set_frame_saved_regs_hack (struct frame_info
*frame
,
1524 CORE_ADDR
*saved_regs
)
1526 frame
->saved_regs
= saved_regs
;
1530 deprecated_set_frame_extra_info_hack (struct frame_info
*frame
,
1531 struct frame_extra_info
*extra_info
)
1533 frame
->extra_info
= extra_info
;
1537 deprecated_set_frame_next_hack (struct frame_info
*fi
,
1538 struct frame_info
*next
)
1544 deprecated_set_frame_prev_hack (struct frame_info
*fi
,
1545 struct frame_info
*prev
)
1551 deprecated_get_frame_context (struct frame_info
*fi
)
1557 deprecated_set_frame_context (struct frame_info
*fi
,
1558 struct context
*context
)
1560 fi
->context
= context
;
1564 deprecated_frame_xmalloc (void)
1566 struct frame_info
*frame
= XMALLOC (struct frame_info
);
1567 memset (frame
, 0, sizeof (struct frame_info
));
1572 deprecated_frame_xmalloc_with_cleanup (long sizeof_saved_regs
,
1573 long sizeof_extra_info
)
1575 struct frame_info
*frame
= deprecated_frame_xmalloc ();
1576 make_cleanup (xfree
, frame
);
1577 if (sizeof_saved_regs
> 0)
1579 frame
->saved_regs
= xcalloc (1, sizeof_saved_regs
);
1580 make_cleanup (xfree
, frame
->saved_regs
);
1582 if (sizeof_extra_info
> 0)
1584 frame
->extra_info
= xcalloc (1, sizeof_extra_info
);
1585 make_cleanup (xfree
, frame
->extra_info
);
1591 _initialize_frame (void)
1593 obstack_init (&frame_cache_obstack
);
1595 /* FIXME: cagney/2003-01-19: This command needs a rename. Suggest
1596 `set backtrace {past,beyond,...}-main'. Also suggest adding `set
1597 backtrace ...-start' to control backtraces past start. The
1598 problem with `below' is that it stops the `up' command. */
1600 add_setshow_boolean_cmd ("backtrace-below-main", class_obscure
,
1601 &backtrace_below_main
, "\
1602 Set whether backtraces should continue past \"main\".\n\
1603 Normally the caller of \"main\" is not of interest, so GDB will terminate\n\
1604 the backtrace at \"main\". Set this variable if you need to see the rest\n\
1605 of the stack trace.", "\
1606 Show whether backtraces should continue past \"main\".\n\
1607 Normally the caller of \"main\" is not of interest, so GDB will terminate\n\
1608 the backtrace at \"main\". Set this variable if you need to see the rest\n\
1609 of the stack trace.",
1610 NULL
, NULL
, &setlist
, &showlist
);
1613 /* Debug this files internals. */
1614 add_show_from_set (add_set_cmd ("frame", class_maintenance
, var_zinteger
,
1615 &frame_debug
, "Set frame debugging.\n\
1616 When non-zero, frame specific internal debugging is enabled.", &setdebuglist
),