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] [05/12] 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-07-31 15:16:34.000000000 +0200
+++ dev/gdb/i386-tdep.c	2007-08-01 09:13:08.000000000 +0200
@@ -171,6 +171,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[]).  */
 
@@ -201,8 +203,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
@@ -211,6 +213,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[]).  */
 
@@ -246,8 +250,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
@@ -914,7 +918,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);
 }
 
@@ -1100,7 +1106,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;
     }
@@ -1133,7 +1139,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];
 
@@ -1270,7 +1276,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
@@ -1280,7 +1287,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;
@@ -1386,8 +1393,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)
 	{
@@ -1458,8 +1465,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);
@@ -1910,7 +1917,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);
@@ -1941,7 +1948,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]