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]

[RFA] Fix sparc64 pop/push frame reg saving



This makes sure that all the correct regs get saved
in push/pop regs on sparc64.

		sparc32			sparc64
failures before	83			111
failures after	83			110

2002-04-20  David S. Miller  <davem@redhat.com>

	* sparc-tdep.c (sparc_push_dummy_frame): Save Y, PC, NPC, CCR, FSR
	properly on sparc64.
	(sparc_push_dummy_frame): Find them in the right spot.
	(sparc_pop_frame): Restore them properly.

--- sparc-tdep.c.~1~	Fri Apr 19 23:53:57 2002
+++ sparc-tdep.c	Sat Apr 20 00:34:53 2002
@@ -960,13 +960,10 @@ sparc_push_dummy_frame (void)
 
   if (GDB_TARGET_IS_SPARC64)
     {
-      /* PC, NPC, CCR, FSR, FPRS, Y, ASI */
-      read_register_bytes (REGISTER_BYTE (PC_REGNUM), &register_temp[0],
-			   REGISTER_RAW_SIZE (PC_REGNUM) * 7);
-      read_register_bytes (REGISTER_BYTE (PSTATE_REGNUM), 
-			   &register_temp[7 * SPARC_INTREG_SIZE],
-			   REGISTER_RAW_SIZE (PSTATE_REGNUM));
-      /* FIXME: not sure what needs to be saved here.  */
+      /* Y, PC, NPC, CCR, FSR */
+      read_register_bytes (REGISTER_BYTE (Y_REGNUM),
+			   &register_temp[0],
+			   REGISTER_RAW_SIZE (Y_REGNUM) * 5);
     }
   else
     {
@@ -1111,14 +1108,10 @@ sparc_frame_find_saved_regs (struct fram
 
       if (GDB_TARGET_IS_SPARC64)
 	{
-	  for (regnum = PC_REGNUM; regnum < PC_REGNUM + 7; regnum++)
-	    {
-	      saved_regs_addr[regnum] =
-		frame_addr + (regnum - PC_REGNUM) * SPARC_INTREG_SIZE
-		- DUMMY_STACK_REG_BUF_SIZE;
-	    }
-	  saved_regs_addr[PSTATE_REGNUM] =
-	    frame_addr + 8 * SPARC_INTREG_SIZE - DUMMY_STACK_REG_BUF_SIZE;
+	  for (regnum = Y_REGNUM; regnum <= FSR_REGNUM; regnum++)
+	    saved_regs_addr[regnum] =
+	      frame_addr + (regnum - Y_REGNUM) * SPARC_INTREG_SIZE
+	      - DUMMY_STACK_REG_BUF_SIZE;
 	}
       else
 	for (regnum = Y_REGNUM; regnum < NUM_REGS; regnum++)
@@ -1173,7 +1166,6 @@ sparc_frame_find_saved_regs (struct fram
 	}
     }
   /* Otherwise, whatever we would get from ptrace(GETREGS) is accurate */
-  /* FIXME -- should this adjust for the sparc64 offset? */
   saved_regs_addr[SP_REGNUM] = FRAME_FP (fi);
 }
 
@@ -1224,6 +1216,14 @@ sparc_pop_frame (void)
 	      write_register_gen (CPS_REGNUM, raw_buffer);
 	    }
 	}
+      else
+	{
+	  if (fsr[FSR_REGNUM])
+	    {
+	      read_memory (fsr[FSR_REGNUM], raw_buffer, SPARC_INTREG_SIZE);
+	      write_register_gen (FSR_REGNUM, raw_buffer);
+	    }
+	}
     }
   if (fsr[G1_REGNUM])
     {
@@ -1289,10 +1289,19 @@ sparc_pop_frame (void)
     }
 
   if (!(GDB_TARGET_IS_SPARC64))
-    if (fsr[PS_REGNUM])
-      write_register (PS_REGNUM, 
-		      read_memory_integer (fsr[PS_REGNUM], 
-					   REGISTER_RAW_SIZE (PS_REGNUM)));
+    {
+      if (fsr[PS_REGNUM])
+	write_register (PS_REGNUM,
+			read_memory_integer (fsr[PS_REGNUM],
+					     REGISTER_RAW_SIZE (PS_REGNUM)));
+    }
+  else
+    {
+      if (fsr[CCR_REGNUM])
+	write_register (CCR_REGNUM,
+			read_memory_integer (fsr[CCR_REGNUM],
+					     REGISTER_RAW_SIZE (CCR_REGNUM)));
+    }
 
   if (fsr[Y_REGNUM])
     write_register (Y_REGNUM, 


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