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] Add gdbach to cannot_fetch_register and cannot_store_register


Hi,

this patch adds gdbarch to cannot_fetch_register and cannot_store_register to get rid of current_gdbarch.
Tested with gdb_mbuild and on x86. Is this ok to commit?


ChangeLog:


	* gdbarch.sh (cannot_fetch_register, cannot_store_register): Add gdbarch
	as parameter.
	* gdbarch.{c,h}: Regenerate.

* alpha-tdep.c (alpha_cannot_fetch_register)
(alpha_cannot_store_register): Add gdbarch as parameter. Replace current_gdbarch by gdbarch.
* cris-tdep.c (cris_cannot_fetch_register, cris_cannot_store_register)
(crisv32_cannot_fetch_register)
(crisv32_cannot_store_register): Likewise.
* arch-utils.c (cannot_register_not): Likewise.
* arch-utils.h (cannot_register_not): Likewise.
* hppa-tdep.c (hppa32_cannot_store_register)
(hppa32_cannot_store_register, hppa64_cannot_store_register)
(hppa64_cannot_fetch_register): Likewise.
* mipsnbsd-tdep.c (mipsnbsd_cannot_fetch_register)
(mipsnbsd_cannot_store_register): Likewise.


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

diff -urpN src/gdb/alpha-tdep.c dev/gdb/alpha-tdep.c
--- src/gdb/alpha-tdep.c	2007-11-09 06:32:19.000000000 +0100
+++ dev/gdb/alpha-tdep.c	2007-11-09 09:27:38.000000000 +0100
@@ -77,17 +77,17 @@ alpha_register_name (struct gdbarch *gdb
 }
 
 static int
-alpha_cannot_fetch_register (int regno)
+alpha_cannot_fetch_register (struct gdbarch *gdbarch, int regno)
 {
   return (regno == ALPHA_ZERO_REGNUM
-          || strlen (alpha_register_name (current_gdbarch, regno)) == 0);
+          || strlen (alpha_register_name (gdbarch, regno)) == 0);
 }
 
 static int
-alpha_cannot_store_register (int regno)
+alpha_cannot_store_register (struct gdbarch *gdbarch, int regno)
 {
   return (regno == ALPHA_ZERO_REGNUM
-          || strlen (alpha_register_name (current_gdbarch, regno)) == 0);
+          || strlen (alpha_register_name (gdbarch, regno)) == 0);
 }
 
 static struct type *
diff -urpN src/gdb/arch-utils.c dev/gdb/arch-utils.c
--- src/gdb/arch-utils.c	2007-11-09 09:28:55.000000000 +0100
+++ dev/gdb/arch-utils.c	2007-11-09 09:28:04.000000000 +0100
@@ -125,7 +125,7 @@ default_coff_make_msymbol_special (int v
 }
 
 int
-cannot_register_not (int regnum)
+cannot_register_not (struct gdbarch *gdbarch, int regnum)
 {
   return 0;
 }
diff -urpN src/gdb/arch-utils.h dev/gdb/arch-utils.h
--- src/gdb/arch-utils.h	2007-11-09 09:28:55.000000000 +0100
+++ dev/gdb/arch-utils.h	2007-11-09 09:28:20.000000000 +0100
@@ -54,7 +54,7 @@ void default_coff_make_msymbol_special (
 /* Version of cannot_fetch_register() / cannot_store_register() that
    always fails. */
 
-int cannot_register_not (int regnum);
+int cannot_register_not (struct gdbarch *gdbarch, int regnum);
 
 /* Legacy version of target_virtual_frame_pointer().  Assumes that
    there is an gdbarch_deprecated_fp_regnum and that it is the same, cooked or
diff -urpN src/gdb/cris-tdep.c dev/gdb/cris-tdep.c
--- src/gdb/cris-tdep.c	2007-11-07 07:32:59.000000000 +0100
+++ dev/gdb/cris-tdep.c	2007-11-09 09:27:38.000000000 +0100
@@ -1590,9 +1590,9 @@ cris_register_size (int regno)
    for unimplemented (size 0) and non-existant registers.  */
 
 static int
-cris_cannot_fetch_register (int regno)
+cris_cannot_fetch_register (struct gdbarch *gdbarch, int regno)
 {
-  return ((regno < 0 || regno >= gdbarch_num_regs (current_gdbarch))
+  return ((regno < 0 || regno >= gdbarch_num_regs (gdbarch))
           || (cris_register_size (regno) == 0));
 }
 
@@ -1600,7 +1600,7 @@ cris_cannot_fetch_register (int regno)
    reasons.  */
 
 static int
-cris_cannot_store_register (int regno)
+cris_cannot_store_register (struct gdbarch *gdbarch, int regno)
 {
   /* There are three kinds of registers we refuse to write to.
      1. Those that not implemented.
@@ -1609,7 +1609,7 @@ cris_cannot_store_register (int regno)
   */
 
   if (regno < 0
-      || regno >= gdbarch_num_regs (current_gdbarch)
+      || regno >= gdbarch_num_regs (gdbarch)
       || cris_register_size (regno) == 0)
     /* Not implemented.  */
     return 1;
@@ -1632,9 +1632,9 @@ cris_cannot_store_register (int regno)
    for unimplemented (size 0) and non-existant registers.  */
 
 static int
-crisv32_cannot_fetch_register (int regno)
+crisv32_cannot_fetch_register (struct gdbarch *gdbarch, int regno)
 {
-  return ((regno < 0 || regno >= gdbarch_num_regs (current_gdbarch))
+  return ((regno < 0 || regno >= gdbarch_num_regs (gdbarch))
           || (cris_register_size (regno) == 0));
 }
 
@@ -1642,7 +1642,7 @@ crisv32_cannot_fetch_register (int regno
    reasons.  */
 
 static int
-crisv32_cannot_store_register (int regno)
+crisv32_cannot_store_register (struct gdbarch *gdbarch, int regno)
 {
   /* There are three kinds of registers we refuse to write to.
      1. Those that not implemented.
@@ -1651,7 +1651,7 @@ crisv32_cannot_store_register (int regno
   */
 
   if (regno < 0
-      || regno >= gdbarch_num_regs (current_gdbarch)
+      || regno >= gdbarch_num_regs (gdbarch)
       || cris_register_size (regno) == 0)
     /* Not implemented.  */
     return 1;
diff -urpN src/gdb/gdbarch.c dev/gdb/gdbarch.c
--- src/gdb/gdbarch.c	2007-11-09 06:32:19.000000000 +0100
+++ dev/gdb/gdbarch.c	2007-11-09 09:27:38.000000000 +0100
@@ -291,8 +291,8 @@ struct gdbarch startup_gdbarch =
   0,  /* print_float_info */
   0,  /* print_vector_info */
   0,  /* register_sim_regno */
-  0,  /* cannot_fetch_register */
-  0,  /* cannot_store_register */
+  cannot_register_not,  /* cannot_fetch_register */
+  cannot_register_not,  /* cannot_store_register */
   0,  /* get_longjmp_target */
   0,  /* believe_pcc_promotion */
   generic_convert_register_p,  /* convert_register_p */
@@ -1848,7 +1848,7 @@ gdbarch_cannot_fetch_register (struct gd
   gdb_assert (gdbarch->cannot_fetch_register != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_cannot_fetch_register called\n");
-  return gdbarch->cannot_fetch_register (regnum);
+  return gdbarch->cannot_fetch_register (gdbarch, regnum);
 }
 
 void
@@ -1865,7 +1865,7 @@ gdbarch_cannot_store_register (struct gd
   gdb_assert (gdbarch->cannot_store_register != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_cannot_store_register called\n");
-  return gdbarch->cannot_store_register (regnum);
+  return gdbarch->cannot_store_register (gdbarch, regnum);
 }
 
 void
diff -urpN src/gdb/gdbarch.h dev/gdb/gdbarch.h
--- src/gdb/gdbarch.h	2007-11-09 06:32:19.000000000 +0100
+++ dev/gdb/gdbarch.h	2007-11-09 09:27:38.000000000 +0100
@@ -300,11 +300,11 @@ typedef int (gdbarch_register_sim_regno_
 extern int gdbarch_register_sim_regno (struct gdbarch *gdbarch, int reg_nr);
 extern void set_gdbarch_register_sim_regno (struct gdbarch *gdbarch, gdbarch_register_sim_regno_ftype *register_sim_regno);
 
-typedef int (gdbarch_cannot_fetch_register_ftype) (int regnum);
+typedef int (gdbarch_cannot_fetch_register_ftype) (struct gdbarch *gdbarch, int regnum);
 extern int gdbarch_cannot_fetch_register (struct gdbarch *gdbarch, int regnum);
 extern void set_gdbarch_cannot_fetch_register (struct gdbarch *gdbarch, gdbarch_cannot_fetch_register_ftype *cannot_fetch_register);
 
-typedef int (gdbarch_cannot_store_register_ftype) (int regnum);
+typedef int (gdbarch_cannot_store_register_ftype) (struct gdbarch *gdbarch, int regnum);
 extern int gdbarch_cannot_store_register (struct gdbarch *gdbarch, int regnum);
 extern void set_gdbarch_cannot_store_register (struct gdbarch *gdbarch, gdbarch_cannot_store_register_ftype *cannot_store_register);
 
diff -urpN src/gdb/gdbarch.sh dev/gdb/gdbarch.sh
--- src/gdb/gdbarch.sh	2007-11-09 06:32:19.000000000 +0100
+++ dev/gdb/gdbarch.sh	2007-11-09 09:27:38.000000000 +0100
@@ -445,8 +445,8 @@ M:void:print_vector_info:struct ui_file 
 # MAP a GDB RAW register number onto a simulator register number.  See
 # also include/...-sim.h.
 f:int:register_sim_regno:int reg_nr:reg_nr::legacy_register_sim_regno::0
-f:int:cannot_fetch_register:int regnum:regnum::cannot_register_not::0
-f:int:cannot_store_register:int regnum:regnum::cannot_register_not::0
+m:int:cannot_fetch_register:int regnum:regnum::cannot_register_not::0
+m:int:cannot_store_register:int regnum:regnum::cannot_register_not::0
 # setjmp/longjmp support.
 F:int:get_longjmp_target:struct frame_info *frame, CORE_ADDR *pc:frame, pc
 #
diff -urpN src/gdb/hppa-tdep.c dev/gdb/hppa-tdep.c
--- src/gdb/hppa-tdep.c	2007-11-07 07:32:59.000000000 +0100
+++ dev/gdb/hppa-tdep.c	2007-11-09 09:27:38.000000000 +0100
@@ -2632,7 +2632,7 @@ hppa64_register_type (struct gdbarch *gd
    through ptrace/ttrace.  */
 
 static int
-hppa32_cannot_store_register (int regnum)
+hppa32_cannot_store_register (struct gdbarch *gdbarch, int regnum)
 {
   return (regnum == 0
           || regnum == HPPA_PCSQ_HEAD_REGNUM
@@ -2641,17 +2641,17 @@ hppa32_cannot_store_register (int regnum
 }
 
 static int
-hppa32_cannot_fetch_register (int regnum)
+hppa32_cannot_fetch_register (struct gdbarch *gdbarch, int regnum)
 {
   /* cr26 and cr27 are readable (but not writable) from userspace.  */
   if (regnum == HPPA_CR26_REGNUM || regnum == HPPA_CR27_REGNUM)
     return 0;
   else
-    return hppa32_cannot_store_register (regnum);
+    return hppa32_cannot_store_register (gdbarch, regnum);
 }
 
 static int
-hppa64_cannot_store_register (int regnum)
+hppa64_cannot_store_register (struct gdbarch *gdbarch, int regnum)
 {
   return (regnum == 0
           || regnum == HPPA_PCSQ_HEAD_REGNUM
@@ -2660,13 +2660,13 @@ hppa64_cannot_store_register (int regnum
 }
 
 static int
-hppa64_cannot_fetch_register (int regnum)
+hppa64_cannot_fetch_register (struct gdbarch *gdbarch, int regnum)
 {
   /* cr26 and cr27 are readable (but not writable) from userspace.  */
   if (regnum == HPPA_CR26_REGNUM || regnum == HPPA_CR27_REGNUM)
     return 0;
   else
-    return hppa64_cannot_store_register (regnum);
+    return hppa64_cannot_store_register (gdbarch, regnum);
 }
 
 static CORE_ADDR
diff -urpN src/gdb/mipsnbsd-tdep.c dev/gdb/mipsnbsd-tdep.c
--- src/gdb/mipsnbsd-tdep.c	2007-10-10 19:04:38.000000000 +0200
+++ dev/gdb/mipsnbsd-tdep.c	2007-11-09 09:27:38.000000000 +0100
@@ -309,17 +309,17 @@ mipsnbsd_get_longjmp_target (struct fram
 }
 
 static int
-mipsnbsd_cannot_fetch_register (int regno)
+mipsnbsd_cannot_fetch_register (struct gdbarch *gdbarch, int regno)
 {
   return (regno == MIPS_ZERO_REGNUM
-	  || regno == mips_regnum (current_gdbarch)->fp_implementation_revision);
+	  || regno == mips_regnum (gdbarch)->fp_implementation_revision);
 }
 
 static int
-mipsnbsd_cannot_store_register (int regno)
+mipsnbsd_cannot_store_register (struct gdbarch *gdbarch, int regno)
 {
   return (regno == MIPS_ZERO_REGNUM
-	  || regno == mips_regnum (current_gdbarch)->fp_implementation_revision);
+	  || regno == mips_regnum (gdbarch)->fp_implementation_revision);
 }
 
 /* Shared library support.  */

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