* frame.h (deprecated_frame_xmalloc_with_cleanup): Declare.
* frame.c (deprecated_frame_xmalloc_with_cleanup): New function.
* arm-tdep.c (arm_frame_chain): Allocate caller_fi using
deprecated_frame_xmalloc_with_cleanup.
* m32r-tdep.c (m32r_virtual_frame_pointer): Allocate `fi' using
deprecated_frame_xmalloc.
* mcore-tdep.c (analyze_dummy_frame): Ditto for dummy.
* mn10200-tdep.c (mn10200_frame_chain): Ditto for dummy_frame.
+2003-01-06 Andrew Cagney <ac131313@redhat.com>
+
+ * frame.h (deprecated_frame_xmalloc_with_cleanup): Declare.
+ * frame.c (deprecated_frame_xmalloc_with_cleanup): New function.
+ * arm-tdep.c (arm_frame_chain): Allocate caller_fi using
+ deprecated_frame_xmalloc_with_cleanup.
+ * m32r-tdep.c (m32r_virtual_frame_pointer): Allocate `fi' using
+ deprecated_frame_xmalloc.
+ * mcore-tdep.c (analyze_dummy_frame): Ditto for dummy.
+ * mn10200-tdep.c (mn10200_frame_chain): Ditto for dummy_frame.
+
2003-01-06 Andrew Cagney <cagney@redhat.com>
* x86-64-linux-tdep.c: Include "osabi.h".
caller_fi. */
if (arm_pc_is_thumb (caller_pc) != arm_pc_is_thumb (get_frame_pc (fi)))
{
- struct frame_info caller_fi;
- struct cleanup *old_chain;
-
- /* Create a temporary frame suitable for scanning the caller's
- prologue. (Ugh.) */
- memset (&caller_fi, 0, sizeof (caller_fi));
- caller_fi.extra_info = (struct frame_extra_info *)
- xcalloc (1, sizeof (struct frame_extra_info));
- old_chain = make_cleanup (xfree, caller_fi.extra_info);
- caller_fi.saved_regs = (CORE_ADDR *)
- xcalloc (1, SIZEOF_FRAME_SAVED_REGS);
- make_cleanup (xfree, caller_fi.saved_regs);
+ struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
+ struct frame_info *caller_fi =
+ deprecated_frame_xmalloc_with_cleanup (SIZEOF_FRAME_SAVED_REGS,
+ sizeof (struct frame_extra_info));
/* Now, scan the prologue and obtain the frame register. */
- deprecated_update_frame_pc_hack (&caller_fi, caller_pc);
- arm_scan_prologue (&caller_fi);
- framereg = caller_fi.extra_info->framereg;
+ deprecated_update_frame_pc_hack (caller_fi, caller_pc);
+ arm_scan_prologue (caller_fi);
+ framereg = caller_fi->extra_info->framereg;
/* Deallocate the storage associated with the temporary frame
created above. */
CORE_ADDR
cris_skip_prologue_main (CORE_ADDR pc, int frameless_p)
{
- struct frame_info fi;
- static struct frame_extra_info fei;
+ struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
+ struct frame_info *fi;
struct symtab_and_line sal = find_pc_line (pc, 0);
int best_limit;
CORE_ADDR pc_after_prologue;
- /* frame_info now contains dynamic memory. Since fi is a dummy here,
- I use static memory for extra_info, and don't bother allocating
- memory for saved_regs. */
- memset (&fi, 0, sizeof (fi));
- fi.extra_info = &fei;
+ /* frame_info now contains dynamic memory. Since fi is a dummy
+ here, I don't bother allocating memory for saved_regs. */
+ fi = deprecated_frame_xmalloc_with_cleanup (0, sizeof (struct frame_extra_info));
/* If there is no symbol information then sal.end == 0, and we end up
examining only the first instruction in the function prologue.
else
best_limit = pc + 100;
- pc_after_prologue = cris_examine (pc, best_limit, &fi, frameless_p);
+ pc_after_prologue = cris_examine (pc, best_limit, fi, frameless_p);
+ do_cleanups (old_chain);
return pc_after_prologue;
}
return frame;
}
+struct frame_info *
+deprecated_frame_xmalloc_with_cleanup (long sizeof_saved_regs,
+ long sizeof_extra_info)
+{
+ struct frame_info *frame = deprecated_frame_xmalloc ();
+ make_cleanup (xfree, frame);
+ if (sizeof_saved_regs > 0)
+ {
+ frame->saved_regs = xcalloc (1, sizeof_saved_regs);
+ make_cleanup (xfree, frame->saved_regs);
+ }
+ if (sizeof_extra_info > 0)
+ {
+ frame->extra_info = xcalloc (1, sizeof_extra_info);
+ make_cleanup (xfree, frame->extra_info);
+ }
+ return frame;
+}
void
_initialize_frame (void)
been created. By always creating a frame, this problem goes away. */
extern struct frame_info *deprecated_frame_xmalloc (void);
+/* FIXME: cagney/2003-01-05: Allocate a frame, along with the
+ saved_regs and extra_info. Set up cleanups for all three. Same as
+ for deprecated_frame_xmalloc, targets are calling this when
+ creating a scratch `struct frame_info'. The frame overhaul makes
+ this unnecessary since all frame queries are parameterized with a
+ common cache parameter and a frame. */
+extern struct frame_info *deprecated_frame_xmalloc_with_cleanup (long sizeof_saved_regs,
+ long sizeof_extra_info);
+
#endif /* !defined (FRAME_H) */
void
m32r_virtual_frame_pointer (CORE_ADDR pc, long *reg, long *offset)
{
- struct frame_info fi;
+ struct frame_info *fi = deprecated_frame_xmalloc ();
+ struct cleanup *old_chain = make_cleanup (xfree, fi);
/* Set up a dummy frame_info. */
- fi.next = NULL;
- fi.prev = NULL;
- fi.frame = 0;
- fi.pc = pc;
+ fi->next = NULL;
+ fi->prev = NULL;
+ fi->frame = 0;
+ fi->pc = pc;
/* Analyze the prolog and fill in the extra info. */
- m32r_init_extra_frame_info (&fi);
-
+ m32r_init_extra_frame_info (fi);
/* Results will tell us which type of frame it uses. */
- if (fi.using_frame_pointer)
+ if (fi->using_frame_pointer)
{
*reg = FP_REGNUM;
*offset = 0;
*reg = SP_REGNUM;
*offset = 0;
}
+ do_cleanups (old_chain);
}
/* Function: find_callers_reg
if (dummy == NULL)
{
- dummy = (struct frame_info *) xmalloc (sizeof (struct frame_info));
+ dummy = deprecated_frame_xmalloc ();
dummy->saved_regs = (CORE_ADDR *) xmalloc (SIZEOF_FRAME_SAVED_REGS);
dummy->extra_info =
(struct frame_extra_info *) xmalloc (sizeof (struct frame_extra_info));
CORE_ADDR
mn10200_frame_chain (struct frame_info *fi)
{
- struct frame_info dummy_frame;
+ struct frame_info *dummy_frame = deprecated_frame_xmalloc ();
+ struct cleanup *old_chain = make_cleanup (xfree, dummy_frame);
+ CORE_ADDR ret;
/* Walk through the prologue to determine the stack size,
location of saved registers, end of the prologue, etc. */
So we set up a dummy frame and call mn10200_analyze_prologue to
find stuff for us. */
- deprecated_update_frame_pc_hack (&dummy_frame, FRAME_SAVED_PC (fi));
- deprecated_update_frame_base_hack (&dummy_frame, fi->frame);
- memset (dummy_frame.fsr.regs, '\000', sizeof dummy_frame.fsr.regs);
- dummy_frame.status = 0;
- dummy_frame.stack_size = 0;
- mn10200_analyze_prologue (&dummy_frame, 0);
-
- if (dummy_frame.status & MY_FRAME_IN_FP)
+ deprecated_update_frame_pc_hack (dummy_frame, FRAME_SAVED_PC (fi));
+ deprecated_update_frame_base_hack (dummy_frame, fi->frame);
+ memset (dummy_frame->fsr.regs, '\000', sizeof dummy_frame->fsr.regs);
+ dummy_frame->status = 0;
+ dummy_frame->stack_size = 0;
+ mn10200_analyze_prologue (dummy_frame, 0);
+
+ if (dummy_frame->status & MY_FRAME_IN_FP)
{
/* Our caller has a frame pointer. So find the frame in $a2, $a0,
or in the stack. */
if (fi->fsr.regs[6])
- return (read_memory_integer (fi->fsr.regs[FP_REGNUM], REGISTER_SIZE)
- & 0xffffff);
+ ret = (read_memory_integer (fi->fsr.regs[FP_REGNUM], REGISTER_SIZE)
+ & 0xffffff);
else if (fi->status & CALLER_A2_IN_A0)
- return read_register (4);
+ ret = read_register (4);
else
- return read_register (FP_REGNUM);
+ ret = read_register (FP_REGNUM);
}
else
{
/* Our caller does not have a frame pointer. So his frame starts
at the base of our frame (fi->frame) + <his size> + 4 (saved pc). */
- return fi->frame + -dummy_frame.stack_size + 4;
+ ret = fi->frame + -dummy_frame->stack_size + 4;
}
+ do_cleanups (old_chain);
+ return ret;
}
/* Function: skip_prologue
static struct frame_info *dummy = NULL;
if (dummy == NULL)
{
- dummy = xmalloc (sizeof (struct frame_info));
+ dummy = deprecated_frame_xmalloc ();
dummy->saved_regs = xmalloc (SIZEOF_FRAME_SAVED_REGS);
dummy->extra_info = xmalloc (sizeof (struct frame_extra_info));
}