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]

[unwind-20030108-branch] Work around get_frame_base()


Hello,

This patch modifies the new unwind code so that the frame ID is always unwound and frame->frame is always initialized.

The problem is with a frame's base being redundantly (always a dangerous thing :-) stored both in frame->frame and frame->next->id_cache. Since the new code on-demand unwinds the frame (seeting frame->next->id_cache but not frame->frame) this can lead to frame->frame being left uninitialized.

The correct fix, once `struct frame_info' is opaque, is to eliminate frame->frame.

(I think this again re-enforces why things like `struct frame_info' need to be opaque, only accessor methods used when accessing the corresponding object.)

Andrew
2003-01-19  Andrew Cagney  <ac131313@redhat.com>

	* d10v-frame.c: Use D10V_RET1_REGNUM.
	(saved_regs_unwinder): Don't use get_frame_saved_regs.
	* frame.c (get_prev_frame): Always initialize frame.frame.
	(get_frame_base): Return frame.frame.

Index: d10v-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/Attic/d10v-frame.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 d10v-frame.c
--- d10v-frame.c	13 Jan 2003 17:03:53 -0000	1.1.2.1
+++ d10v-frame.c	19 Jan 2003 18:43:39 -0000
@@ -311,7 +311,7 @@
 	  if (bufferp != NULL)
 	    {
 	      /* Read the value in from memory.  */
-	      read_memory (get_frame_saved_regs (frame)[regnum], bufferp,
+	      read_memory (saved_regs[regnum], bufferp,
 			   REGISTER_RAW_SIZE (regnum));
 	    }
 	}
Index: d10v-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/d10v-tdep.c,v
retrieving revision 1.69.2.2
diff -u -r1.69.2.2 d10v-tdep.c
--- d10v-tdep.c	13 Jan 2003 17:03:53 -0000	1.69.2.2
+++ d10v-tdep.c	19 Jan 2003 18:43:57 -0000
@@ -459,7 +459,7 @@
     {
       bfd_byte tmp[2];
       tmp[1] = *(bfd_byte *)valbuf;
-      regcache_cooked_write (regcache, RET1_REGNUM, tmp);
+      regcache_cooked_write (regcache, D10V_RET1_REGNUM, tmp);
     }
   else
     {
@@ -471,7 +471,7 @@
          out any dangling byte at the end of the buffer.  */
       for (reg = 0; (reg * 2) + 1 < TYPE_LENGTH (type); reg++)
 	{
-	  regcache_cooked_write (regcache, RET1_REGNUM + reg,
+	  regcache_cooked_write (regcache, D10V_RET1_REGNUM + reg,
 				 (bfd_byte *) valbuf + reg * 2);
 	}
       /* Write out any dangling byte at the end of the buffer.  */
@@ -489,8 +489,8 @@
 d10v_extract_struct_value_address (struct regcache *regcache)
 {
   ULONGEST addr;
-  regcache_cooked_read_unsigned (regcache, ARG1_REGNUM, &addr);
-  return (addr | DMEM_START);
+  regcache_cooked_read_unsigned (regcache, D10V_ARG1_REGNUM, &addr);
+  return (addr | D10V_DMEM_START);
 }
 
 static CORE_ADDR
@@ -1093,7 +1093,7 @@
   if (TYPE_LENGTH (type) == 1)
     {
       ULONGEST c;
-      regcache_cooked_read_unsigned (regcache, RET1_REGNUM, &c);
+      regcache_cooked_read_unsigned (regcache, D10V_RET1_REGNUM, &c);
       store_unsigned_integer (valbuf, 1, c);
     }
   else
@@ -1103,11 +1103,11 @@
 	 remaining bytes in remaining registers. Interestingly, when
 	 such values are passed in, the last byte is in the most
 	 significant byte of that same register - wierd. */
-      int reg = RET1_REGNUM;
+      int reg = D10V_RET1_REGNUM;
       int off = 0;
       if (TYPE_LENGTH (type) & 1)
 	{
-	  regcache_cooked_read_part (regcache, RET1_REGNUM, 1, 1,
+	  regcache_cooked_read_part (regcache, D10V_RET1_REGNUM, 1, 1,
 				     (bfd_byte *)valbuf + off);
 	  off++;
 	  reg++;
@@ -1115,7 +1115,7 @@
       /* Transfer the remaining registers.  */
       for (; off < TYPE_LENGTH (type); reg++, off += 2)
 	{
-	  regcache_cooked_read (regcache, RET1_REGNUM + reg,
+	  regcache_cooked_read (regcache, D10V_RET1_REGNUM + reg,
 				(bfd_byte *) valbuf + off);
 	}
     }
Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.56.2.5
diff -u -r1.56.2.5 frame.c
--- frame.c	13 Jan 2003 21:14:01 -0000	1.56.2.5
+++ frame.c	19 Jan 2003 18:44:28 -0000
@@ -973,27 +973,17 @@
   prev_frame->unwind = frame_unwind_find_by_pc (current_gdbarch,
 						prev_frame->pc);
 
-  /* Now figure out how to initialize this new frame.  Perhaphs one
-     day, this will too, be selected by set_unwind_by_pc().  */
-  if (prev_frame->type != DUMMY_FRAME)
-    {
-      /* 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?  */
-#if 0
-      /* Oops, the frame doesn't chain.  Treat this as the last frame.  */
-      prev_frame->id = frame_id_unwind (next_frame);
-      if (!frame_id_p (prev_frame->id))
-	return NULL;
-#else      
-      /* 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);
-      if (!frame_id_p (id))
-	return NULL;
-      prev_frame->frame = id.base;
-#endif
-    }
+  /* 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);
+    if (!frame_id_p (id))
+      return NULL;
+    prev_frame->frame = id.base;
+  }
 
   /* Link it in.  */
   next_frame->prev = prev_frame;
@@ -1077,8 +1067,14 @@
 CORE_ADDR
 get_frame_base (struct frame_info *fi)
 {
+#if 1
+  /* FIXME: cagney/2003-01-13: Should be using the frame base obtained
+     by unwinding the previous frame.  */
+  return fi->frame;
+#else
   struct frame_id id = frame_id_unwind (fi->next);
   return id.base;
+#endif
 }
 
 /* Level of the selected frame: 0 for innermost, 1 for its caller, ...

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