aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2003-01-06 21:50:25 +0000
committerAndrew Cagney <cagney@redhat.com>2003-01-06 21:50:25 +0000
commitf6c609c4c2bb326e580c9f533bd2aa0e9d583556 (patch)
tree7f5974da7d3a38c4ed7430a947fd61c165eec113
parent84dc46cbdb5a9c4ca576b8768a2876e9551199a5 (diff)
downloadfsf-binutils-gdb-f6c609c4c2bb326e580c9f533bd2aa0e9d583556.zip
fsf-binutils-gdb-f6c609c4c2bb326e580c9f533bd2aa0e9d583556.tar.gz
fsf-binutils-gdb-f6c609c4c2bb326e580c9f533bd2aa0e9d583556.tar.bz2
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.
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/arm-tdep.c22
-rw-r--r--gdb/cris-tdep.c15
-rw-r--r--gdb/frame.c18
-rw-r--r--gdb/frame.h9
-rw-r--r--gdb/m32r-tdep.c17
-rw-r--r--gdb/mcore-tdep.c2
-rw-r--r--gdb/mn10200-tdep.c32
-rw-r--r--gdb/mn10300-tdep.c2
9 files changed, 81 insertions, 47 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b7add20..2c30678 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,14 @@
+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".
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index dba7dad..52729a2 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -1041,23 +1041,15 @@ arm_frame_chain (struct frame_info *fi)
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. */
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index eb7256b..fdc3afb 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -734,17 +734,15 @@ cris_skip_prologue_frameless_p (CORE_ADDR pc)
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.
@@ -754,7 +752,8 @@ cris_skip_prologue_main (CORE_ADDR pc, int frameless_p)
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;
}
diff --git a/gdb/frame.c b/gdb/frame.c
index 361651e..443f067 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -1316,6 +1316,24 @@ deprecated_frame_xmalloc (void)
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)
diff --git a/gdb/frame.h b/gdb/frame.h
index 21ef137..f593d00 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -684,4 +684,13 @@ extern void deprecated_set_frame_extra_info_hack (struct frame_info *frame,
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) */
diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c
index eeb6335..400f0a9 100644
--- a/gdb/m32r-tdep.c
+++ b/gdb/m32r-tdep.c
@@ -426,20 +426,20 @@ m32r_init_extra_frame_info (struct frame_info *fi)
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;
@@ -449,6 +449,7 @@ m32r_virtual_frame_pointer (CORE_ADDR pc, long *reg, long *offset)
*reg = SP_REGNUM;
*offset = 0;
}
+ do_cleanups (old_chain);
}
/* Function: find_callers_reg
diff --git a/gdb/mcore-tdep.c b/gdb/mcore-tdep.c
index 43cb248..118fa86 100644
--- a/gdb/mcore-tdep.c
+++ b/gdb/mcore-tdep.c
@@ -289,7 +289,7 @@ analyze_dummy_frame (CORE_ADDR pc, CORE_ADDR frame)
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));
diff --git a/gdb/mn10200-tdep.c b/gdb/mn10200-tdep.c
index 3aea842..808f7e4 100644
--- a/gdb/mn10200-tdep.c
+++ b/gdb/mn10200-tdep.c
@@ -607,7 +607,9 @@ mn10200_analyze_prologue (struct frame_info *fi, CORE_ADDR pc)
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. */
@@ -638,31 +640,33 @@ mn10200_frame_chain (struct frame_info *fi)
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
diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index a130e1c..4d8e1e7 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -153,7 +153,7 @@ analyze_dummy_frame (CORE_ADDR pc, CORE_ADDR frame)
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));
}