This is the mail archive of the gdb-patches@sourceware.org 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]

[rfc] [08/12] Get rid of current_gdbarch in rs6000-tdep.c


Hi,

this patch gets rid of some of the current_gdbarch's in rs6000-tdep.c

Is this ok to commit?

ChangeLog:

	* rs6000-tdep.c (ppc_supply_gregset, ppc_collect_gregset)
	(rs6000_push_dummy_call, rs6000_return_value, rs6000_frame_cache)
	rs6000_register_reggroup_p, rs6000_unwind_pc, rs6000_unwind_dummy_id):
	Replace current_gdbarch by gdbarch.
	(rs6000_skip_trampoline_code, rs6000_register_to_value)
	(rs6000_value_to_register, e500_move_ev_register): Use FRAME or REGCACHE
	to recognize current architecture.
	(rs6000_dump_tdep): Rename current_gdbarch to gdbarch.

--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com





diff -urpN src/gdb/rs6000-tdep.c dev/gdb/rs6000-tdep.c
--- src/gdb/rs6000-tdep.c	2007-06-19 05:22:04.000000000 +0200
+++ dev/gdb/rs6000-tdep.c	2007-08-01 11:52:00.000000000 +0200
@@ -342,8 +342,8 @@ ppc_supply_gregset (const struct regset 
 	ppc_supply_reg (regcache, i, gregs, offset);
     }
 
-  if (regnum == -1 || regnum == gdbarch_pc_regnum (current_gdbarch))
-    ppc_supply_reg (regcache, gdbarch_pc_regnum (current_gdbarch),
+  if (regnum == -1 || regnum == gdbarch_pc_regnum (gdbarch))
+    ppc_supply_reg (regcache, gdbarch_pc_regnum (gdbarch),
 		    gregs, offsets->pc_offset);
   if (regnum == -1 || regnum == tdep->ppc_ps_regnum)
     ppc_supply_reg (regcache, tdep->ppc_ps_regnum,
@@ -419,8 +419,8 @@ ppc_collect_gregset (const struct regset
 	ppc_collect_reg (regcache, i, gregs, offset);
     }
 
-  if (regnum == -1 || regnum == gdbarch_pc_regnum (current_gdbarch))
-    ppc_collect_reg (regcache, gdbarch_pc_regnum (current_gdbarch),
+  if (regnum == -1 || regnum == gdbarch_pc_regnum (gdbarch))
+    ppc_collect_reg (regcache, gdbarch_pc_regnum (gdbarch),
 		     gregs, offsets->pc_offset);
   if (regnum == -1 || regnum == tdep->ppc_ps_regnum)
     ppc_collect_reg (regcache, tdep->ppc_ps_regnum,
@@ -1583,14 +1583,14 @@ rs6000_push_dummy_call (struct gdbarch *
 			int nargs, struct value **args, CORE_ADDR sp,
 			int struct_return, CORE_ADDR struct_addr)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   int ii;
   int len = 0;
   int argno;			/* current argument number */
   int argbytes;			/* current argument byte */
   gdb_byte tmp_buffer[50];
   int f_argno = 0;		/* current floating point argno */
-  int wordsize = gdbarch_tdep (current_gdbarch)->wordsize;
+  int wordsize = gdbarch_tdep (gdbarch)->wordsize;
   CORE_ADDR func_addr = find_function_addr (function, NULL);
 
   struct value *arg = 0;
@@ -1601,7 +1601,7 @@ rs6000_push_dummy_call (struct gdbarch *
   /* The calling convention this function implements assumes the
      processor has floating-point registers.  We shouldn't be using it
      on PPC variants that lack them.  */
-  gdb_assert (ppc_floating_point_unit_p (current_gdbarch));
+  gdb_assert (ppc_floating_point_unit_p (gdbarch));
 
   /* The first eight words of ther arguments are passed in registers.
      Copy them appropriately.  */
@@ -1639,7 +1639,7 @@ rs6000_push_dummy_call (struct gdbarch *
 
   for (argno = 0, argbytes = 0; argno < nargs && ii < 8; ++ii)
     {
-      int reg_size = register_size (current_gdbarch, ii + 3);
+      int reg_size = register_size (gdbarch, ii + 3);
 
       arg = args[argno];
       type = check_typedef (value_type (arg));
@@ -1686,7 +1686,7 @@ rs6000_push_dummy_call (struct gdbarch *
       else
 	{
 	  /* Argument can fit in one register.  No problem.  */
-	  int adj = gdbarch_byte_order (current_gdbarch)
+	  int adj = gdbarch_byte_order (gdbarch)
 		    == BFD_ENDIAN_BIG ? reg_size - len : 0;
 	  gdb_byte word[MAX_REGISTER_SIZE];
 
@@ -1700,7 +1700,7 @@ rs6000_push_dummy_call (struct gdbarch *
 ran_out_of_registers_for_arguments:
 
   regcache_cooked_read_unsigned (regcache,
-				 gdbarch_sp_regnum (current_gdbarch),
+				 gdbarch_sp_regnum (gdbarch),
 				 &saved_sp);
 
   /* Location for 8 parameters are always reserved.  */
@@ -1744,7 +1744,7 @@ ran_out_of_registers_for_arguments:
          else.  */
 
       regcache_raw_write_signed (regcache,
-				 gdbarch_sp_regnum (current_gdbarch), sp);
+				 gdbarch_sp_regnum (gdbarch), sp);
 
       /* If the last argument copied into the registers didn't fit there 
          completely, push the rest of it into stack.  */
@@ -1791,7 +1791,7 @@ ran_out_of_registers_for_arguments:
      Not doing this can lead to conflicts with the kernel which thinks
      that it still has control over this not-yet-allocated stack
      region.  */
-  regcache_raw_write_signed (regcache, gdbarch_sp_regnum (current_gdbarch), sp);
+  regcache_raw_write_signed (regcache, gdbarch_sp_regnum (gdbarch), sp);
 
   /* Set back chain properly.  */
   store_unsigned_integer (tmp_buffer, wordsize, saved_sp);
@@ -1818,13 +1818,13 @@ rs6000_return_value (struct gdbarch *gdb
 		     struct regcache *regcache, gdb_byte *readbuf,
 		     const gdb_byte *writebuf)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   gdb_byte buf[8];
 
   /* The calling convention this function implements assumes the
      processor has floating-point registers.  We shouldn't be using it
      on PowerPC variants that lack them.  */
-  gdb_assert (ppc_floating_point_unit_p (current_gdbarch));
+  gdb_assert (ppc_floating_point_unit_p (gdbarch));
 
   /* AltiVec extension: Functions that declare a vector data type as a
      return value place that return value in VR2.  */
@@ -2025,7 +2025,8 @@ rs6000_skip_trampoline_code (struct fram
 	return 0;
     }
   ii = get_frame_register_unsigned (frame, 11);	/* r11 holds destination addr   */
-  pc = read_memory_addr (ii, gdbarch_tdep (current_gdbarch)->wordsize); /* (r11) value */
+  /* (r11) value */
+  pc = read_memory_addr (ii, gdbarch_tdep (get_frame_arch (frame))->wordsize); 
   return pc;
 }
 
@@ -2180,8 +2181,8 @@ rs6000_register_reggroup_p (struct gdbar
   int vector_p;
   int general_p;
 
-  if (gdbarch_register_name (current_gdbarch, regnum) == NULL
-      || *gdbarch_register_name (current_gdbarch, regnum) == '\0')
+  if (gdbarch_register_name (gdbarch, regnum) == NULL
+      || *gdbarch_register_name (gdbarch, regnum) == '\0')
     return 0;
   if (group == all_reggroup)
     return 1;
@@ -2215,7 +2216,7 @@ rs6000_register_reggroup_p (struct gdbar
 	       || regnum == tdep->ppc_lr_regnum
 	       || regnum == tdep->ppc_ctr_regnum
 	       || regnum == tdep->ppc_xer_regnum
-	       || regnum == gdbarch_pc_regnum (current_gdbarch));
+	       || regnum == gdbarch_pc_regnum (gdbarch));
   if (group == general_reggroup)
     return general_p;
 
@@ -2244,7 +2245,7 @@ rs6000_register_to_value (struct frame_i
                           struct type *type,
                           gdb_byte *to)
 {
-  const struct reg *reg = gdbarch_tdep (current_gdbarch)->regs + regnum;
+  const struct reg *reg = gdbarch_tdep (get_frame_arch (frame))->regs + regnum;
   gdb_byte from[MAX_REGISTER_SIZE];
   
   gdb_assert (reg->fpr);
@@ -2260,7 +2261,7 @@ rs6000_value_to_register (struct frame_i
                           struct type *type,
                           const gdb_byte *from)
 {
-  const struct reg *reg = gdbarch_tdep (current_gdbarch)->regs + regnum;
+  const struct reg *reg = gdbarch_tdep (get_frame_arch (frame))->regs + regnum;
   gdb_byte to[MAX_REGISTER_SIZE];
 
   gdb_assert (reg->fpr);
@@ -2309,7 +2310,7 @@ e500_move_ev_register (void (*move) (str
 
   reg_index = ev_reg - tdep->ppc_ev0_regnum;
 
-  if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+  if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG)
     {
       move (regcache, tdep->ppc_ev0_upper_regnum + reg_index, byte_buffer);
       move (regcache, tdep->ppc_gp0_regnum + reg_index, byte_buffer + 4);
@@ -3125,14 +3126,14 @@ static CORE_ADDR
 rs6000_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
 {
   return frame_unwind_register_unsigned (next_frame,
-					 gdbarch_pc_regnum (current_gdbarch));
+					 gdbarch_pc_regnum (gdbarch));
 }
 
 static struct frame_id
 rs6000_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame)
 {
   return frame_id_build (frame_unwind_register_unsigned
-			 (next_frame, gdbarch_sp_regnum (current_gdbarch)),
+			 (next_frame, gdbarch_sp_regnum (gdbarch)),
 			frame_pc_unwind (next_frame));
 }
 
@@ -3171,7 +3172,7 @@ rs6000_frame_cache (struct frame_info *n
      the mean time, the address of the prev frame is used as the
      base address of this frame.  */
   cache->base = frame_unwind_register_unsigned
-		(next_frame, gdbarch_sp_regnum (current_gdbarch));
+		(next_frame, gdbarch_sp_regnum (gdbarch));
 
   /* If the function appears to be frameless, check a couple of likely
      indicators that we have simply failed to find the frame setup.
@@ -3210,7 +3211,7 @@ rs6000_frame_cache (struct frame_info *n
     cache->base = read_memory_addr (cache->base, wordsize);
 
   trad_frame_set_value (cache->saved_regs,
-			gdbarch_sp_regnum (current_gdbarch), cache->base);
+			gdbarch_sp_regnum (gdbarch), cache->base);
 
   /* if != -1, fdata.saved_fpr is the smallest number of saved_fpr.
      All fpr's from saved_fpr to fp31 are saved.  */
@@ -3289,7 +3290,7 @@ rs6000_frame_cache (struct frame_info *n
   if (fdata.lr_offset != 0)
     cache->saved_regs[tdep->ppc_lr_regnum].addr = cache->base + fdata.lr_offset;
   /* The PC is found in the link register.  */
-  cache->saved_regs[gdbarch_pc_regnum (current_gdbarch)] =
+  cache->saved_regs[gdbarch_pc_regnum (gdbarch)] =
     cache->saved_regs[tdep->ppc_lr_regnum];
 
   /* If != 0, fdata.vrsave_offset is the offset from the frame that
@@ -3301,7 +3302,7 @@ rs6000_frame_cache (struct frame_info *n
     /* If no alloca register used, then fi->frame is the value of the
        %sp for this frame, and it is good enough.  */
     cache->initial_sp = frame_unwind_register_unsigned
-			(next_frame, gdbarch_sp_regnum (current_gdbarch));
+			(next_frame, gdbarch_sp_regnum (gdbarch));
   else
     cache->initial_sp = frame_unwind_register_unsigned (next_frame,
 							fdata.alloca_reg);
@@ -3715,9 +3716,9 @@ rs6000_gdbarch_init (struct gdbarch_info
 }
 
 static void
-rs6000_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file)
+rs6000_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   if (tdep == NULL)
     return;





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