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] Eliminate frame->pc


(I could almost cut/paste my last post about frame->frame)

This eliminates the redundant frame->pc. Instead the PC's value is only stored in frame->next->prev_pc.value.

Any remaining references to frame->pc remaining can, obviously, be replaced with either:

deprecated_update_frame_pc_hack()
get_frame_pc()

I've (hopefully) fixed all the ones that gdb_mbuild.sh turned up.

I'll commit in a few days,

Andrew
2003-04-05  Andrew Cagney  <cagney at redhat dot com>

	* frame.c (frame_pc_unwind): Update.
	(create_sentinel_frame): Do not set "pc".
	(get_prev_frame): Do not set "pc".  Use frame_pc_unwind.
	(get_frame_pc): Call frame_pc_unwind.
	(deprecated_update_frame_pc_hack): Update.
	(create_new_frame): Use "pc" not "->pc".
	* frame.h (struct frame_info): Delete field "pc".  Replace
	"pc_unwind_cache" and "pc_unwind_cache_p" with "prev_pc"
	structure.

Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.97
diff -u -r1.97 frame.c
--- frame.c	5 Apr 2003 15:39:33 -0000	1.97
+++ frame.c	5 Apr 2003 16:52:37 -0000
@@ -142,7 +142,7 @@
 CORE_ADDR
 frame_pc_unwind (struct frame_info *this_frame)
 {
-  if (!this_frame->pc_unwind_cache_p)
+  if (!this_frame->prev_pc.p)
     {
       CORE_ADDR pc;
       if (gdbarch_unwind_pc_p (current_gdbarch))
@@ -184,10 +184,10 @@
 	}
       else
 	internal_error (__FILE__, __LINE__, "No gdbarch_unwind_pc method");
-      this_frame->pc_unwind_cache = pc;
-      this_frame->pc_unwind_cache_p = 1;
+      this_frame->prev_pc.value = pc;
+      this_frame->prev_pc.p = 1;
     }
-  return this_frame->pc_unwind_cache;
+  return this_frame->prev_pc.value;
 }
 
 static int
@@ -504,14 +504,6 @@
   /* Link this frame back to itself.  The frame is self referential
      (the unwound PC is the same as the pc), so make it so.  */
   frame->next = frame;
-  /* Always unwind the PC as part of creating this frame.  This
-     ensures that the frame's PC points at something valid.  */
-  /* FIXME: cagney/2003-01-10: Problem here.  Unwinding a sentinel
-     frame's PC may require information such as the frame's thread's
-     stop reason.  Is it possible to get to that?  */
-  /* FIXME: cagney/2003-04-04: Once ->pc is eliminated, this
-     assignment can go away.  */
-  frame->pc = frame_pc_unwind (frame);
   /* Make the sentinel frame's ID valid, but invalid.  That way all
      comparisons with it should fail.  */
   frame->id_p = 1;
@@ -963,7 +955,7 @@
 
   /* Select/initialize both the unwind function and the frame's type
      based on the PC.  */
-  fi->unwind = frame_unwind_find_by_pc (current_gdbarch, fi->pc);
+  fi->unwind = frame_unwind_find_by_pc (current_gdbarch, pc);
   if (fi->unwind->type != UNKNOWN_FRAME)
     fi->type = fi->unwind->type;
   else
@@ -1091,9 +1083,10 @@
 
       /* Set the unwind functions based on that identified PC.  Ditto
          for the "type" but strongly prefer the unwinder's frame type.  */
-      prev->unwind = frame_unwind_find_by_pc (current_gdbarch, prev->pc);
+      prev->unwind = frame_unwind_find_by_pc (current_gdbarch,
+					      get_frame_pc (prev));
       if (prev->unwind->type == UNKNOWN_FRAME)
-	prev->type = frame_type_from_pc (prev->pc);
+	prev->type = frame_type_from_pc (get_frame_pc (prev));
       else
 	prev->type = prev->unwind->type;
 
@@ -1576,10 +1569,7 @@
      because (well ignoring the PPC) a dummy frame can be located
      using THIS_FRAME's frame ID.  */
 
-  /* FIXME: cagney/2003-04-04: Once ->pc is eliminated, this
-     assignment can go away.  */
-  prev_frame->pc = frame_pc_unwind (this_frame);
-  if (prev_frame->pc == 0)
+  if (frame_pc_unwind (this_frame) == 0)
     {
       /* The allocated PREV_FRAME will be reclaimed when the frame
 	 obstack is next purged.  */
@@ -1591,7 +1581,7 @@
 
   /* Set the unwind functions based on that identified PC.  */
   prev_frame->unwind = frame_unwind_find_by_pc (current_gdbarch,
-						prev_frame->pc);
+						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.
@@ -1628,7 +1618,8 @@
 CORE_ADDR
 get_frame_pc (struct frame_info *frame)
 {
-  return frame->pc;
+  gdb_assert (frame->next != NULL);
+  return frame_pc_unwind (frame->next);
 }
 
 static int
@@ -1797,8 +1788,6 @@
 void
 deprecated_update_frame_pc_hack (struct frame_info *frame, CORE_ADDR pc)
 {
-  /* See comment in "frame.h".  */
-  frame->pc = pc;
   /* NOTE: cagney/2003-03-11: Some architectures (e.g., Arm) are
      maintaining a locally allocated frame object.  Since such frame's
      are not in the frame chain, it isn't possible to assume that the
@@ -1808,8 +1797,8 @@
       /* While we're at it, update this frame's cached PC value, found
 	 in the next frame.  Oh for the day when "struct frame_info"
 	 is opaque and this hack on hack can just go away.  */
-      frame->next->pc_unwind_cache = pc;
-      frame->next->pc_unwind_cache_p = 1;
+      frame->next->prev_pc.value = pc;
+      frame->next->prev_pc.p = 1;
     }
 }
 
Index: frame.h
===================================================================
RCS file: /cvs/src/src/gdb/frame.h,v
retrieving revision 1.82
diff -u -r1.82 frame.h
--- frame.h	5 Apr 2003 15:39:33 -0000	1.82
+++ frame.h	5 Apr 2003 16:52:39 -0000
@@ -355,11 +355,6 @@
        sense for this machine.  */
     CORE_ADDR frame;
 
-    /* Address at which execution is occurring in this frame.
-       For the innermost frame, it's the current pc.
-       For other frames, it is a pc saved in the next frame.  */
-    CORE_ADDR pc;
-
     /* Level of this frame.  The inner-most (youngest) frame is at
        level 0.  As you move towards the outer-most (oldest) frame,
        the level increases.  This is a cached value.  It could just as
@@ -407,8 +402,10 @@
     const struct frame_unwind *unwind;
 
     /* Cached copy of the previous frame's resume address.  */
-    int pc_unwind_cache_p;
-    CORE_ADDR pc_unwind_cache;
+    struct {
+      int p;
+      CORE_ADDR value;
+    } prev_pc;
 
     /* This frame's ID.  Note that the frame's ID, base and PC contain
        redundant information.  */

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