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] [09/16] Get rid of current_gdbarch in i386-tdep.c


Hi,

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

Is this ok to commit?


ChangeLog:


	* i386-tdep.c (i386_unwind_pc, i386_sigtramp_frame_cache)
	(i386_get_longjmp_target, i386_extract_return_value)
	(i386_store_return_value, I387_NUM_XMM_REGS, i386_register_to_value)
	(i386_value_to_register, i386_dbx_reg_to_regnum)
	(i386_svr4_reg_to_regnum, i386_frame_prev_register)
	(i386_register_to_value, i386_value_to_register): Replace
	current_gdbarch by frame-specific architecture recognition.


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




diff -urpN src/gdb/i386-tdep.c dev/gdb/i386-tdep.c
--- src/gdb/i386-tdep.c	2007-08-24 04:24:06.000000000 +0200
+++ dev/gdb/i386-tdep.c	2007-08-27 10:37:29.000000000 +0200
@@ -169,6 +169,8 @@ i386_register_name (int regnum)
 static int
 i386_dbx_reg_to_regnum (int reg)
 {
+  struct gdbarch *gdbarch = get_frame_arch (get_current_frame ());
+
   /* This implements what GCC calls the "default" register map
      (dbx_register_map[]).  */
 
@@ -199,8 +201,8 @@ i386_dbx_reg_to_regnum (int reg)
     }
 
   /* This will hopefully provoke a warning.  */
-  return gdbarch_num_regs (current_gdbarch)
-	 + gdbarch_num_pseudo_regs (current_gdbarch);
+  return gdbarch_num_regs (gdbarch)
+	 + gdbarch_num_pseudo_regs (gdbarch);
 }
 
 /* Convert SVR4 register number REG to the appropriate register number
@@ -209,6 +211,8 @@ i386_dbx_reg_to_regnum (int reg)
 static int
 i386_svr4_reg_to_regnum (int reg)
 {
+  struct gdbarch *gdbarch = get_frame_arch (get_current_frame ());
+
   /* This implements the GCC register map that tries to be compatible
      with the SVR4 C compiler for DWARF (svr4_dbx_register_map[]).  */
 
@@ -244,8 +248,8 @@ i386_svr4_reg_to_regnum (int reg)
     }
 
   /* This will hopefully provoke a warning.  */
-  return gdbarch_num_regs (current_gdbarch)
-	 + gdbarch_num_pseudo_regs (current_gdbarch);
+  return gdbarch_num_regs (gdbarch)
+	 + gdbarch_num_pseudo_regs (gdbarch);
 }
 
 #undef I387_ST0_REGNUM
@@ -912,7 +916,9 @@ i386_unwind_pc (struct gdbarch *gdbarch,
 {
   gdb_byte buf[8];
 
-  frame_unwind_register (next_frame, gdbarch_pc_regnum (current_gdbarch), buf);
+  frame_unwind_register (next_frame,
+			 gdbarch_pc_regnum (get_frame_arch (next_frame)),
+			 buf);
   return extract_typed_address (buf, builtin_type_void_func_ptr);
 }
 
@@ -1098,7 +1104,7 @@ i386_frame_prev_register (struct frame_i
 	{
 	  /* Read the value in from memory.  */
 	  read_memory (*addrp, valuep,
-		       register_size (current_gdbarch, regnum));
+		       register_size (get_frame_arch (next_frame), regnum));
 	}
       return;
     }
@@ -1131,7 +1137,7 @@ static struct i386_frame_cache *
 i386_sigtramp_frame_cache (struct frame_info *next_frame, void **this_cache)
 {
   struct i386_frame_cache *cache;
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (next_frame));
   CORE_ADDR addr;
   gdb_byte buf[4];
 
@@ -1268,7 +1274,8 @@ i386_get_longjmp_target (struct frame_in
 {
   gdb_byte buf[8];
   CORE_ADDR sp, jb_addr;
-  int jb_pc_offset = gdbarch_tdep (get_frame_arch (frame))->jb_pc_offset;
+  struct gdbarch *gdbarch  = get_frame_arch (frame);
+  int jb_pc_offset = gdbarch_tdep (gdbarch)->jb_pc_offset;
   int len = TYPE_LENGTH (builtin_type_void_func_ptr);
 
   /* If JB_PC_OFFSET is -1, we have no way to find out where the
@@ -1278,7 +1285,7 @@ i386_get_longjmp_target (struct frame_in
 
   /* Don't use I386_ESP_REGNUM here, since this function is also used
      for AMD64.  */
-  get_frame_register (frame, gdbarch_sp_regnum (current_gdbarch), buf);
+  get_frame_register (frame, gdbarch_sp_regnum (gdbarch), buf);
   sp = extract_typed_address (buf, builtin_type_void_data_ptr);
   if (target_read_memory (sp + len, buf, len))
     return 0;
@@ -1384,8 +1391,8 @@ i386_extract_return_value (struct gdbarc
     }
   else
     {
-      int low_size = register_size (current_gdbarch, LOW_RETURN_REGNUM);
-      int high_size = register_size (current_gdbarch, HIGH_RETURN_REGNUM);
+      int low_size = register_size (gdbarch, LOW_RETURN_REGNUM);
+      int high_size = register_size (gdbarch, HIGH_RETURN_REGNUM);
 
       if (len <= low_size)
 	{
@@ -1456,8 +1463,8 @@ i386_store_return_value (struct gdbarch 
     }
   else
     {
-      int low_size = register_size (current_gdbarch, LOW_RETURN_REGNUM);
-      int high_size = register_size (current_gdbarch, HIGH_RETURN_REGNUM);
+      int low_size = register_size (gdbarch, LOW_RETURN_REGNUM);
+      int high_size = register_size (gdbarch, HIGH_RETURN_REGNUM);
 
       if (len <= low_size)
 	regcache_raw_write_part (regcache, LOW_RETURN_REGNUM, 0, len, valbuf);
@@ -1908,7 +1915,7 @@ i386_register_to_value (struct frame_inf
   while (len > 0)
     {
       gdb_assert (regnum != -1);
-      gdb_assert (register_size (current_gdbarch, regnum) == 4);
+      gdb_assert (register_size (get_frame_arch (frame), regnum) == 4);
 
       get_frame_register (frame, regnum, to);
       regnum = i386_next_regnum (regnum);
@@ -1939,7 +1946,7 @@ i386_value_to_register (struct frame_inf
   while (len > 0)
     {
       gdb_assert (regnum != -1);
-      gdb_assert (register_size (current_gdbarch, regnum) == 4);
+      gdb_assert (register_size (get_frame_arch (frame), regnum) == 4);
 
       put_frame_register (frame, regnum, from);
       regnum = i386_next_regnum (regnum);




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