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 frame ID evaluation


Hello,

Ref: Lazy get_frame_id()
http://sources.redhat.com/ml/gdb/2003-03/msg00243.html

The attached delays the computation of the frame ID until when it is needed. Doing this (at least for targets using new frames) reduces the overhead of creating the initial frame - it avoids the need to do any prologue analysis until it is actually needed.

The follow on change is to exploit this in infrun.c, by using get_frame_type (get_current_frame ()) instead of PC_IN_SIGTRAMP() and PC_IN_DUMMY_FRAME(). They'll follow as separate changes.

Andrew
2003-03-26  Andrew Cagney  <cagney at redhat dot com>

	* frame.c (get_frame_base): Force ID initialization.
	(get_prev_frame): Move computation of the frame ID from here ...
	(get_frame_id): ... to here.
	(legacy_get_prev_frame): Mark the frame ID as valid.
	* frame.h (struct frame_info): Add field "id_p".

Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.89
diff -u -r1.89 frame.c
--- frame.c	26 Mar 2003 00:00:07 -0000	1.89
+++ frame.c	27 Mar 2003 00:53:39 -0000
@@ -57,13 +57,19 @@
     {
       return null_frame_id;
     }
-  else
+  if (!fi->id_p)
     {
-      struct frame_id id;
-      id.base = fi->frame;
-      id.pc = fi->pc;
-      return id;
+      gdb_assert (!legacy_frame_p (current_gdbarch));
+      /* Find THIS frame's ID.  */
+      fi->unwind->this_id (fi->next, &fi->prologue_cache, &fi->id);
+      fi->id_p = 1;
+      /* 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.  */
+      fi->frame = fi->id.base;
     }
+  return frame_id_build (fi->frame, fi->pc);
 }
 
 const struct frame_id null_frame_id; /* All zeros.  */
@@ -1038,6 +1044,9 @@
      problem.  */
   prev->type = NORMAL_FRAME;
 
+  /* A legacy frame's ID is always computed here.  Mark it as valid.  */
+  prev->id_p = 1;
+
   /* Handle sentinel frame unwind as a special case.  */
   if (this_frame->level < 0)
     {
@@ -1546,24 +1555,7 @@
   prev_frame->unwind = frame_unwind_find_by_pc (current_gdbarch,
 						prev_frame->pc);
 
-  /* Find the prev's frame's ID.  */
-
-  /* The callee expects to be invoked with:
-
-     this->unwind->this_id (this->next, &this->cache, &this->id);
-
-     The below is carefully shifted one frame `to the left' so that
-     both the unwind->this_id and unwind->prev_register methods are
-     consistently invoked with NEXT_FRAME and THIS_PROLOGUE_CACHE.
-       
-     Also note that, while the PC for this new previous frame was
-     unwound first (see above), the below is the first call that
-     [potentially] requires analysis of the new previous frame's
-     prologue.  Consequently, it is this call, that typically ends up
-     initializing the previous frame's prologue cache.  */
-  prev_frame->unwind->this_id (this_frame,
-			       &prev_frame->prologue_cache,
-			       &prev_frame->id);
+  /* The prev's frame's ID is computed by demand in 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
@@ -1577,12 +1569,6 @@
      return 0 (indicating we don't know the address of the arglist) if
      we don't know what frame this frame calls.  */
 
-  /* 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.  */
   this_frame->prev = prev_frame;
   prev_frame->next = this_frame;
@@ -1624,6 +1610,12 @@
 CORE_ADDR
 get_frame_base (struct frame_info *fi)
 {
+  if (!fi->id_p)
+    {
+      /* HACK: Force the ID code to (indirectly) initialize the
+         ->frame pointer.  */
+      get_frame_id (fi);
+    }
   return fi->frame;
 }
 
Index: frame.h
===================================================================
RCS file: /cvs/src/src/gdb/frame.h,v
retrieving revision 1.76
diff -u -r1.76 frame.h
--- frame.h	24 Mar 2003 03:54:47 -0000	1.76
+++ frame.h	27 Mar 2003 00:53:41 -0000
@@ -411,6 +411,7 @@
 
     /* This frame's ID.  Note that the frame's ID, base and PC contain
        redundant information.  */
+    int id_p;
     struct frame_id id;
 
     /* Pointers to the next (down, inner, younger) and previous (up,

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