This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
RFA: Patch to blockframe.c, frame.h, arm-tdep.c and fr30-tdep.c (prologue cache)
- To: gdb-patches at sourceware dot cygnus dot com, Elena Zannoni <ezannoni at cygnus dot com>
- Subject: RFA: Patch to blockframe.c, frame.h, arm-tdep.c and fr30-tdep.c (prologue cache)
- From: Fernando Nasser <fnasser at cygnus dot com>
- Date: Thu, 17 Feb 2000 20:48:06 -0500
- Organization: Red Hat , Inc. - Toronto
I believe the following fixes a bug found by Elena.
Fernando
2000-02-17 Fernando Nasser <fnasser@totem.to.cygnus.com>
* blockframe.c (check_prologue_cache, save_prologue_cache,
flush_prologue_cache): Slightly improved version of a prologue
cache
used by some targets. Here there is a flush mechanism so we
never use
stale data.
* frame.h: Prototypes for the above functions.
* arm-tdep.c (check_prologue_cache, save_prologue_cache):
Deleted.
Moved (with changes) to blockframe.c.
--
Fernando Nasser
Red Hat - Toronto E-Mail: fnasser@cygnus.com
2323 Yonge Street, Suite #300 Tel: 416-482-2661 ext. 311
Toronto, Ontario M4P 2C9 Fax: 416-482-6299
Index: blockframe.c
===================================================================
RCS file: /cvs/src/src/gdb/blockframe.c,v
retrieving revision 1.1.1.11
diff -c -p -r1.1.1.11 blockframe.c
*** blockframe.c 1999/12/22 21:45:03 1.1.1.11
--- blockframe.c 2000/02/18 01:38:15
*************** flush_cached_frames ()
*** 269,274 ****
--- 269,275 ----
current_frame = NULL; /* Invalidate cache */
select_frame (NULL, -1);
+ flush_prolog_cache (); /* Invalidate prologue cache as well. */
annotate_frames_invalid ();
}
*************** reinit_frame_cache ()
*** 284,289 ****
--- 285,354 ----
{
select_frame (get_current_frame (), 0);
}
+ }
+
+ /* Check if prologue for this frame's PC has already been scanned. If
+ it has, copy the relevant information about that prologue and
+ return non-zero. Otherwise do not copy anything and return zero.
+
+ The information saved in the cache includes:
+ * the frame register number;
+ * the size of the stack frame;
+ * the offsets of saved regs (relative to the old SP); and
+ * the offset from the stack pointer to the frame pointer
+
+ The cache contains only one entry, since this is adequate for the
+ typical sequence of prologue scan requests we get. When performing
+ a backtrace, GDB will usually ask to scan the same function twice
+ in a row (once to get the frame chain, and once to fill in the
+ extra frame information). */
+
+ static struct frame_info prologue_cache;
+ static int prologue_cache_valid = 0; /* Indicate if contents are
valid. */
+
+ static int
+ check_prologue_cache (struct frame_info *fi)
+ {
+ int i;
+
+ if ((prolog_cache_valid)
+ && (fi->pc == prologue_cache.pc))
+ {
+ fi->framereg = prologue_cache.framereg;
+ fi->framesize = prologue_cache.framesize;
+ fi->frameoffset = prologue_cache.frameoffset;
+ for (i = 0; i <= NUM_REGS; i++)
+ fi->fsr.regs[i] = prologue_cache.fsr.regs[i];
+ return 1;
+ }
+ else
+ return 0;
+ }
+
+ /* Copy the prologue information from fi to the prologue cache. */
+
+ static void
+ save_prologue_cache (struct frame_info *fi)
+ {
+ int i;
+
+ prologue_cache.pc = fi->pc;
+ prologue_cache.framereg = fi->framereg;
+ prologue_cache.framesize = fi->framesize;
+ prologue_cache.frameoffset = fi->frameoffset;
+
+ for (i = 0; i <= NUM_REGS; i++)
+ prologue_cache.fsr.regs[i] = fi->fsr.regs[i];
+
+ prologue_cache_valid = 1;
+ }
+
+ /* Flush the prologue cache. */
+
+ static void
+ flush_prologue_cache ()
+ {
+ prologue_cache_valid = 0;
}
/* Return nonzero if the function for this frame lacks a prologue.
Many
Index: frame.h
===================================================================
RCS file: /cvs/src/src/gdb/frame.h,v
retrieving revision 1.1.1.11
diff -c -p -r1.1.1.11 frame.h
*** frame.h 2000/02/02 00:21:06 1.1.1.11
--- frame.h 2000/02/18 01:38:15
*************** extern void flush_cached_frames PARAMS (
*** 181,186 ****
--- 181,191 ----
extern void reinit_frame_cache PARAMS ((void));
+ extern static int check_prologue_cache PARAMS ((struct frame_info *));
+
+ extern static void save_prologue_cache PARAMS ((struct frame_info *));
+
+ extern static void flush_prologue_cache PARAMS ((void));
#ifdef FRAME_FIND_SAVED_REGS
/* XXX - deprecated */
Index: arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.3
diff -c -p -r1.3 arm-tdep.c
*** arm-tdep.c 2000/02/17 19:51:04 1.3
--- arm-tdep.c 2000/02/18 01:38:16
*************** thumb_scan_prologue (struct frame_info *
*** 576,635 ****
}
}
- /* Check if prologue for this frame's PC has already been scanned. If
- it has, copy the relevant information about that prologue and
- return non-zero. Otherwise do not copy anything and return zero.
-
- The information saved in the cache includes:
- * the frame register number;
- * the size of the stack frame;
- * the offsets of saved regs (relative to the old SP); and
- * the offset from the stack pointer to the frame pointer
-
- The cache contains only one entry, since this is adequate for the
- typical sequence of prologue scan requests we get. When performing
- a backtrace, GDB will usually ask to scan the same function twice
- in a row (once to get the frame chain, and once to fill in the
- extra frame information). */
-
- static struct frame_info prologue_cache;
-
- static int
- check_prologue_cache (struct frame_info *fi)
- {
- int i;
-
- if (fi->pc == prologue_cache.pc)
- {
- fi->framereg = prologue_cache.framereg;
- fi->framesize = prologue_cache.framesize;
- fi->frameoffset = prologue_cache.frameoffset;
- for (i = 0; i <= NUM_REGS; i++)
- fi->fsr.regs[i] = prologue_cache.fsr.regs[i];
- return 1;
- }
- else
- return 0;
- }
-
-
- /* Copy the prologue information from fi to the prologue cache. */
-
- static void
- save_prologue_cache (struct frame_info *fi)
- {
- int i;
-
- prologue_cache.pc = fi->pc;
- prologue_cache.framereg = fi->framereg;
- prologue_cache.framesize = fi->framesize;
- prologue_cache.frameoffset = fi->frameoffset;
-
- for (i = 0; i <= NUM_REGS; i++)
- prologue_cache.fsr.regs[i] = fi->fsr.regs[i];
- }
-
-
/* This function decodes an ARM function prologue to determine:
1) the size of the stack frame
2) which registers are saved on it
--- 576,581 ----
Index: fr30-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/fr30-tdep.c,v
retrieving revision 1.1.1.4
diff -c -p -r1.1.1.4 fr30-tdep.c
*** fr30-tdep.c 1999/07/07 20:06:09 1.1.1.4
--- fr30-tdep.c 2000/02/18 01:38:16
*************** _initialize_fr30_tdep ()
*** 251,318 ****
tm_print_insn = print_insn_fr30;
}
- /* Function: check_prologue_cache
- Check if prologue for this frame's PC has already been scanned.
- If it has, copy the relevant information about that prologue and
- return non-zero. Otherwise do not copy anything and return zero.
-
- The information saved in the cache includes:
- * the frame register number;
- * the size of the stack frame;
- * the offsets of saved regs (relative to the old SP); and
- * the offset from the stack pointer to the frame pointer
-
- The cache contains only one entry, since this is adequate
- for the typical sequence of prologue scan requests we get.
- When performing a backtrace, GDB will usually ask to scan
- the same function twice in a row (once to get the frame chain,
- and once to fill in the extra frame information).
- */
-
- static struct frame_info prologue_cache;
-
- static int
- check_prologue_cache (fi)
- struct frame_info *fi;
- {
- int i;
-
- if (fi->pc == prologue_cache.pc)
- {
- fi->framereg = prologue_cache.framereg;
- fi->framesize = prologue_cache.framesize;
- fi->frameoffset = prologue_cache.frameoffset;
- for (i = 0; i <= NUM_REGS; i++)
- fi->fsr.regs[i] = prologue_cache.fsr.regs[i];
- return 1;
- }
- else
- return 0;
- }
-
-
- /* Function: save_prologue_cache
- Copy the prologue information from fi to the prologue cache.
- */
-
- static void
- save_prologue_cache (fi)
- struct frame_info *fi;
- {
- int i;
-
- prologue_cache.pc = fi->pc;
- prologue_cache.framereg = fi->framereg;
- prologue_cache.framesize = fi->framesize;
- prologue_cache.frameoffset = fi->frameoffset;
-
- for (i = 0; i <= NUM_REGS; i++)
- {
- prologue_cache.fsr.regs[i] = fi->fsr.regs[i];
- }
- }
-
-
/* Function: scan_prologue
Scan the prologue of the function that contains PC, and record what
we find in PI. PI->fsr must be zeroed by the called. Returns the
--- 251,256 ----