This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit] Simplify frame ID caching


Hello,

This patch simplifies the caching of the computed frame ID. It does two things to achieve this:

- it eliminates the public interface frame_id_unwind() which in turn eliminates the need for the unwind cache. External methods that need the frame ID can call:
get_frame_id (get_prev_frame (next_frame))


- it modifies get_prev_frame() so that the unwound ID is stored directly in prev_frame.

I've tested it on d10v and i386 linux.

Note the fixmes:

- it still hasn't eliminated the duplication between frame->frame and frame->id.base
- it alerts the reader to the off-by-one bug that I'm trying to fix


committed,
Andrew
2003-03-05  Andrew Cagney  <cagney at redhat dot com>

	* frame.h (struct frame_info): Replace "id_unwind_cache_p" and
	"id_unwind_cache" with "id".
	(frame_id_unwind): Delete declaration.
	* frame.c (frame_id_unwind): Delete function.
	(get_prev_frame): Call the frame id unwind method directly.  Store
	the returned next frame's ID value in NEXT_FRAME.  Note that there
	is a problem with the wrong unwind ID being called with the wrong
	unwind cache.

Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.71
diff -u -r1.71 frame.c
--- frame.c	2 Mar 2003 04:02:22 -0000	1.71
+++ frame.c	5 Mar 2003 18:33:20 -0000
@@ -145,17 +145,6 @@
   return frame->pc_unwind_cache;
 }
 
-struct frame_id
-frame_id_unwind (struct frame_info *frame)
-{
-  if (!frame->id_unwind_cache_p)
-    {
-      frame->unwind->id (frame, &frame->unwind_cache, &frame->id_unwind_cache);
-      frame->id_unwind_cache_p = 1;
-    }
-  return frame->id_unwind_cache;
-}
-
 void
 frame_pop (struct frame_info *frame)
 {
@@ -1344,36 +1333,42 @@
   /* FIXME: cagney/2003-01-13: A dummy frame doesn't need to unwind
      the frame ID because the frame ID comes from the previous frame.
      The other frames do though.  True?  */
-  {
-    /* FIXME: cagney/2002-12-18: Instead of this hack, should just
-       save the frame ID directly.  */
-    struct frame_id id = frame_id_unwind (next_frame);
-    /* Check that the unwound ID is valid.  As of 2003-02-24 the
-       x86-64 was returning an invalid frame ID when trying to do an
-       unwind a sentinel frame that belonged to a frame dummy.  */
-    if (!frame_id_p (id))
-      {
-	if (frame_debug)
-	  fprintf_unfiltered (gdb_stdlog,
-			      "Outermost frame - unwound frame ID invalid\n");
-	return NULL;
-      }
-    /* Check that the new frame isn't inner to (younger, below, next)
-       the old frame.  If that happens the frame unwind is going
-       backwards.  */
-    /* FIXME: cagney/2003-02-25: Ignore the sentinel frame since that
-       doesn't have a valid frame ID.  Should instead set the sentinel
-       frame's frame ID to a `sentinel'.  Leave it until after the
-       switch to storing the frame ID, instead of the frame base, in
-       the frame object.  */
-    if (next_frame->level >= 0
-	&& frame_id_inner (id, get_frame_id (next_frame)))
-      error ("Unwound frame inner-to selected frame (corrupt stack?)");
-    /* Note that, due to frameless functions, the stronger test of the
-       new frame being outer to the old frame can't be used -
-       frameless functions differ by only their PC value.  */
-    prev_frame->frame = id.base;
-  }
+  /* FIXME: cagney/2003-03-04: The below call isn't right.  It should
+     instead be doing something like "prev_frame -> unwind -> id
+     (next_frame, & prev_frame -> unwind_cache, & prev_frame -> id)"
+     but that requires more extensive (pending) changes.  */
+  next_frame->unwind->id (next_frame, &next_frame->unwind_cache,
+			  &prev_frame->id);
+  /* Check that the unwound ID is valid.  As of 2003-02-24 the x86-64
+     was returning an invalid frame ID when trying to do an unwind a
+     sentinel frame that belonged to a frame dummy.  */
+  if (!frame_id_p (prev_frame->id))
+    {
+      if (frame_debug)
+	fprintf_unfiltered (gdb_stdlog,
+			    "Outermost frame - unwound frame ID invalid\n");
+      return NULL;
+    }
+  /* Check that the new frame isn't inner to (younger, below, next)
+     the old frame.  If that happens the frame unwind is going
+     backwards.  */
+  /* FIXME: cagney/2003-02-25: Ignore the sentinel frame since that
+     doesn't have a valid frame ID.  Should instead set the sentinel
+     frame's frame ID to a `sentinel'.  Leave it until after the
+     switch to storing the frame ID, instead of the frame base, in the
+     frame object.  */
+  if (next_frame->level >= 0
+      && frame_id_inner (prev_frame->id, get_frame_id (next_frame)))
+    error ("Unwound frame inner-to selected frame (corrupt stack?)");
+  /* Note that, due to frameless functions, the stronger test of the
+     new frame being outer to the old frame can't be used - frameless
+     functions differ by only their PC value.  */
+
+  /* FIXME: cagney/2002-12-18: Instead of this hack, should only store
+     the frame ID in PREV_FRAME.  Unfortunatly, some architectures
+     (HP/UX) still reply on EXTRA_FRAME_INFO and, hence, still poke at
+     the "struct frame_info" object directly.  */
+  prev_frame->frame = prev_frame->id.base;
 
   /* Link it in.  */
   next_frame->prev = prev_frame;
Index: frame.h
===================================================================
RCS file: /cvs/src/src/gdb/frame.h,v
retrieving revision 1.70
diff -u -r1.70 frame.h
--- frame.h	2 Mar 2003 04:02:22 -0000	1.70
+++ frame.h	5 Mar 2003 18:33:20 -0000
@@ -310,10 +310,6 @@
 
 extern CORE_ADDR frame_pc_unwind (struct frame_info *frame);
 
-/* Unwind the frame ID.  Return an ID that uniquely identifies the
-   caller's frame.  */
-extern struct frame_id frame_id_unwind (struct frame_info *frame);
-
 /* Discard the specified frame.  Restoring the registers to the state
    of the caller.  */
 extern void frame_pop (struct frame_info *frame);
@@ -412,9 +408,9 @@
     int pc_unwind_cache_p;
     CORE_ADDR pc_unwind_cache;
 
-    /* Cached copy of the previous frame's ID.  */
-    int id_unwind_cache_p;
-    struct frame_id id_unwind_cache;
+    /* This frame's ID.  Note that the frame's ID, base and PC contain
+       redundant information.  */
+    struct frame_id id;
 
     /* Pointers to the next (down, inner, younger) and previous (up,
        outer, older) frame_info's in the frame cache.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]