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]

[patch rfc] Lazy compute the frame's type


Hello,

This modifies the new frame code so that even the frame's type (and unwind method) are computed on demand.

By reducing the overhead of creating an initial inner-most frame to `zero', any potential concern over creating the inner-most frame in inf*.c is eliminated, and the possibility of some inf*.c cleanups gets that bit closer.

Well, almost. Just need to fix that small problem with the PC and DECR_PC_AFTER_BREAK.

I'll look to commit in a few days,
Andrew
2003-04-12  Andrew Cagney  <cagney at redhat dot com>

	* frame.c (get_prev_frame): Do not initialize "unwind" or "type",
	update comments.
	(get_frame_type): Initialize unwind and type when needed.
	(get_frame_id, frame_register_unwind): Ditto.

Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.105
diff -u -r1.105 frame.c
--- frame.c	10 Apr 2003 15:32:27 -0000	1.105
+++ frame.c	12 Apr 2003 17:09:31 -0000
@@ -135,6 +135,19 @@
       if (frame_debug)
 	fprintf_unfiltered (gdb_stdlog, "{ get_frame_id (fi=%d) ",
 			    fi->level);
+      /* Find the unwinder.  */
+      if (fi->unwind == NULL)
+	{
+	  fi->unwind = frame_unwind_find_by_pc (current_gdbarch,
+						get_frame_pc (fi));
+	  /* FIXME: cagney/2003-04-02: Rather than storing the frame's
+	     type in the frame, the unwinder's type should be returned
+	     directly.  Unfortunatly, legacy code, called by
+	     legacy_get_prev_frame, explicitly set the frames type
+	     using the method deprecated_set_frame_type().  */
+	  gdb_assert (fi->unwind->type != UNKNOWN_FRAME);
+	  fi->type = fi->unwind->type;
+	}
       /* Find THIS frame's ID.  */
       fi->unwind->this_id (fi->next, &fi->prologue_cache, &fi->this_id.value);
       fi->this_id.p = 1;
@@ -412,6 +425,20 @@
      detected the problem before calling here.  */
   gdb_assert (frame != NULL);
 
+  /* Find the unwinder.  */
+  if (frame->unwind == NULL)
+    {
+      frame->unwind = frame_unwind_find_by_pc (current_gdbarch,
+					       get_frame_pc (frame));
+      /* FIXME: cagney/2003-04-02: Rather than storing the frame's
+	 type in the frame, the unwinder's type should be returned
+	 directly.  Unfortunatly, legacy code, called by
+	 legacy_get_prev_frame, explicitly set the frames type using
+	 the method deprecated_set_frame_type().  */
+      gdb_assert (frame->unwind->type != UNKNOWN_FRAME);
+      frame->type = frame->unwind->type;
+    }
+
   /* Ask this frame to unwind its register.  See comment in
      "frame-unwind.h" for why NEXT frame and this unwind cace are
      passed in.  */
@@ -1856,22 +1883,12 @@
       return NULL;
     }
 
-  /* Set the unwind functions based on that identified PC.  */
-  prev_frame->unwind = frame_unwind_find_by_pc (current_gdbarch,
-						frame_pc_unwind (this_frame));
-
-  /* FIXME: cagney/2003-04-02: Rather than storing the frame's type in
-     the frame, the unwinder's type should be returned directly.
-     Unfortunatly, legacy code, called by legacy_get_prev_frame,
-     explicitly set the frames type using the method
-     deprecated_set_frame_type().  */
-  gdb_assert (prev_frame->unwind->type != UNKNOWN_FRAME);
-  prev_frame->type = prev_frame->unwind->type;
-
-  /* Can the frame's type and unwinder be computed on demand?  That
-     would make a frame's creation really really lite!  */
+  /* Don't yet compute ->unwind (and hence ->type).  It is computed
+     on-demand in get_frame_type, frame_register_unwind, and
+     get_frame_id.  */
 
-  /* The prev's frame's ID is computed by demand in get_frame_id().  */
+  /* Don't yet compute the frame's ID.  It is computed on-demand by
+     get_frame_id().  */
 
   /* The unwound frame ID is validate at the start of this function,
      as part of the logic to decide if that frame should be further
@@ -2009,6 +2026,20 @@
   if (!DEPRECATED_USE_GENERIC_DUMMY_FRAMES
       && deprecated_frame_in_dummy (frame))
     return DUMMY_FRAME;
+  if (frame->unwind == NULL)
+    {
+      /* Initialize the frame's unwinder because it is that which
+         provides the frame's type.  */
+      frame->unwind = frame_unwind_find_by_pc (current_gdbarch,
+					       get_frame_pc (frame));
+      /* FIXME: cagney/2003-04-02: Rather than storing the frame's
+	 type in the frame, the unwinder's type should be returned
+	 directly.  Unfortunatly, legacy code, called by
+	 legacy_get_prev_frame, explicitly set the frames type using
+	 the method deprecated_set_frame_type().  */
+      gdb_assert (frame->unwind->type != UNKNOWN_FRAME);
+      frame->type = frame->unwind->type;
+    }
   if (frame->type == UNKNOWN_FRAME)
     return NORMAL_FRAME;
   else

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