Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] Remove global variable arm_linux_vfp_register_count in arm-linux-nat.c
@ 2015-05-26 15:31 Yao Qi
  2015-05-26 15:31 ` [PATCH 2/2] Remove global variable arm_linux_has_wmmx_registers " Yao Qi
  2015-05-28  9:39 ` [PATCH 1/2] Remove global variable arm_linux_vfp_register_count " Yao Qi
  0 siblings, 2 replies; 3+ messages in thread
From: Yao Qi @ 2015-05-26 15:31 UTC (permalink / raw)
  To: gdb-patches

This patch is to remove the global variable arm_linux_vfp_register_count
from arm-linux-nat.c.  This global variable is set when native gdb
looks for the right target description according HWCAP.  However,
'struct gdbarch_tdep' has already had a field have_vfp_registers, which
is a boolean about whether target has vfp registers or not.  This
patch converts this boolean field to a numeric counter to replace
global variable arm_linux_vfp_register_count.

gdb:

2015-05-26  Yao Qi  <yao.qi@linaro.org>

	* arm-linux-nat.c (arm_linux_vfp_register_count): Remove.
	(fetch_vfp_regs): Use vfp_register_count from gdbarch_tdep
	instead of arm_linux_vfp_register_count.
	(store_vfp_regs): Likewise.
	(arm_linux_fetch_inferior_registers): Likewise.
	(arm_linux_store_inferior_registers): Likewise.
	(arm_linux_read_description): Don't set
	arm_linux_vfp_register_count.
	* arm-linux-tdep.c (arm_linux_iterate_over_regset_sections):
	Adjust.
	* arm-tdep.c (arm_gdbarch_init): Add assert on
	vfp_register_count.
	* arm-tdep.h (struct gdbarch_tdep) <have_vfp_registers>: Rename
	field to vfp_register_count.  All users updated.
---
 gdb/arm-linux-nat.c  | 46 +++++++++++++++++++++-------------------------
 gdb/arm-linux-tdep.c |  2 +-
 gdb/arm-tdep.c       |  9 ++++++---
 gdb/arm-tdep.h       |  4 +++-
 4 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index afc5817..5c0ede6 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -64,10 +64,6 @@
 /* A flag for whether the WMMX registers are available.  */
 static int arm_linux_has_wmmx_registers;
 
-/* The number of 64-bit VFP registers we have (expect this to be 0,
-   16, or 32).  */
-static int arm_linux_vfp_register_count;
-
 extern int arm_apcs_32;
 
 /* On GNU/Linux, threads are implemented as pseudo-processes, in which
@@ -460,6 +456,8 @@ fetch_vfp_regs (struct regcache *regcache)
 {
   char regbuf[VFP_REGS_SIZE];
   int ret, regno, tid;
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   /* Get the thread id for the ptrace call.  */
   tid = GET_THREAD_ID (inferior_ptid);
@@ -471,7 +469,7 @@ fetch_vfp_regs (struct regcache *regcache)
       return;
     }
 
-  for (regno = 0; regno < arm_linux_vfp_register_count; regno++)
+  for (regno = 0; regno < tdep->vfp_register_count; regno++)
     regcache_raw_supply (regcache, regno + ARM_D0_REGNUM,
 			 (char *) regbuf + regno * 8);
 
@@ -484,6 +482,8 @@ store_vfp_regs (const struct regcache *regcache)
 {
   char regbuf[VFP_REGS_SIZE];
   int ret, regno, tid;
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   /* Get the thread id for the ptrace call.  */
   tid = GET_THREAD_ID (inferior_ptid);
@@ -495,7 +495,7 @@ store_vfp_regs (const struct regcache *regcache)
       return;
     }
 
-  for (regno = 0; regno < arm_linux_vfp_register_count; regno++)
+  for (regno = 0; regno < tdep->vfp_register_count; regno++)
     regcache_raw_collect (regcache, regno + ARM_D0_REGNUM,
 			  (char *) regbuf + regno * 8);
 
@@ -519,13 +519,16 @@ static void
 arm_linux_fetch_inferior_registers (struct target_ops *ops,
 				    struct regcache *regcache, int regno)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
   if (-1 == regno)
     {
       fetch_regs (regcache);
       fetch_fpregs (regcache);
       if (arm_linux_has_wmmx_registers)
 	fetch_wmmx_regs (regcache);
-      if (arm_linux_vfp_register_count > 0)
+      if (tdep->vfp_register_count > 0)
 	fetch_vfp_regs (regcache);
     }
   else 
@@ -537,9 +540,9 @@ arm_linux_fetch_inferior_registers (struct target_ops *ops,
       else if (arm_linux_has_wmmx_registers
 	       && regno >= ARM_WR0_REGNUM && regno <= ARM_WCGR7_REGNUM)
 	fetch_wmmx_regs (regcache);
-      else if (arm_linux_vfp_register_count > 0
+      else if (tdep->vfp_register_count > 0
 	       && regno >= ARM_D0_REGNUM
-	       && regno <= ARM_D0_REGNUM + arm_linux_vfp_register_count)
+	       && regno <= ARM_D0_REGNUM + tdep->vfp_register_count)
 	fetch_vfp_regs (regcache);
     }
 }
@@ -552,13 +555,16 @@ static void
 arm_linux_store_inferior_registers (struct target_ops *ops,
 				    struct regcache *regcache, int regno)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
   if (-1 == regno)
     {
       store_regs (regcache);
       store_fpregs (regcache);
       if (arm_linux_has_wmmx_registers)
 	store_wmmx_regs (regcache);
-      if (arm_linux_vfp_register_count > 0)
+      if (tdep->vfp_register_count > 0)
 	store_vfp_regs (regcache);
     }
   else
@@ -570,9 +576,9 @@ arm_linux_store_inferior_registers (struct target_ops *ops,
       else if (arm_linux_has_wmmx_registers
 	       && regno >= ARM_WR0_REGNUM && regno <= ARM_WCGR7_REGNUM)
 	store_wmmx_regs (regcache);
-      else if (arm_linux_vfp_register_count > 0
+      else if (tdep->vfp_register_count > 0
 	       && regno >= ARM_D0_REGNUM
-	       && regno <= ARM_D0_REGNUM + arm_linux_vfp_register_count)
+	       && regno <= ARM_D0_REGNUM + tdep->vfp_register_count)
 	store_vfp_regs (regcache);
     }
 }
@@ -631,7 +637,6 @@ arm_linux_read_description (struct target_ops *ops)
 {
   CORE_ADDR arm_hwcap = 0;
   arm_linux_has_wmmx_registers = 0;
-  arm_linux_vfp_register_count = 0;
 
   if (target_auxv_search (ops, AT_HWCAP, &arm_hwcap) != 1)
     {
@@ -653,20 +658,11 @@ arm_linux_read_description (struct target_ops *ops)
       /* NEON implies VFPv3-D32 or no-VFP unit.  Say that we only support
 	 Neon with VFPv3-D32.  */
       if (arm_hwcap & HWCAP_NEON)
-	{
-	  arm_linux_vfp_register_count = 32;
-	  result = tdesc_arm_with_neon;
-	}
+	result = tdesc_arm_with_neon;
       else if ((arm_hwcap & (HWCAP_VFPv3 | HWCAP_VFPv3D16)) == HWCAP_VFPv3)
-	{
-	  arm_linux_vfp_register_count = 32;
-	  result = tdesc_arm_with_vfpv3;
-	}
+	result = tdesc_arm_with_vfpv3;
       else
-	{
-	  arm_linux_vfp_register_count = 16;
-	  result = tdesc_arm_with_vfpv2;
-	}
+	result = tdesc_arm_with_vfpv2;
 
       /* Now make sure that the kernel supports reading these
 	 registers.  Support was added in 2.6.30.  */
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index b6757bd..fd0ef5b 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -743,7 +743,7 @@ arm_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
 
   cb (".reg", ARM_LINUX_SIZEOF_GREGSET, &arm_linux_gregset, NULL, cb_data);
 
-  if (tdep->have_vfp_registers)
+  if (tdep->vfp_register_count > 0)
     cb (".reg-arm-vfp", ARM_LINUX_SIZEOF_VFP, &arm_linux_vfpregset,
 	"VFP floating-point", cb_data);
   else if (tdep->have_fpa_registers)
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 638855b..1d755e5 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -9914,7 +9914,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   enum arm_float_model fp_model = arm_fp_model;
   struct tdesc_arch_data *tdesc_data = NULL;
   int i, is_m = 0;
-  int have_vfp_registers = 0, have_vfp_pseudos = 0, have_neon_pseudos = 0;
+  int vfp_register_count = 0, have_vfp_pseudos = 0, have_neon_pseudos = 0;
   int have_neon = 0;
   int have_fpa_registers = 1;
   const struct target_desc *tdesc = info.target_desc;
@@ -10220,7 +10220,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 	  if (tdesc_unnumbered_register (feature, "s0") == 0)
 	    have_vfp_pseudos = 1;
 
-	  have_vfp_registers = 1;
+	  vfp_register_count = i;
 
 	  /* If we have VFP, also check for NEON.  The architecture allows
 	     NEON without VFP (integer vector operations only), but GDB
@@ -10289,7 +10289,10 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   tdep->fp_model = fp_model;
   tdep->is_m = is_m;
   tdep->have_fpa_registers = have_fpa_registers;
-  tdep->have_vfp_registers = have_vfp_registers;
+  gdb_assert (vfp_register_count == 0
+	      || vfp_register_count == 16
+	      || vfp_register_count == 32);
+  tdep->vfp_register_count = vfp_register_count;
   tdep->have_vfp_pseudos = have_vfp_pseudos;
   tdep->have_neon_pseudos = have_neon_pseudos;
   tdep->have_neon = have_neon;
diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h
index bd01ec9..06658a0 100644
--- a/gdb/arm-tdep.h
+++ b/gdb/arm-tdep.h
@@ -161,7 +161,9 @@ struct gdbarch_tdep
   enum arm_float_model fp_model; /* Floating point calling conventions.  */
 
   int have_fpa_registers;	/* Does the target report the FPA registers?  */
-  int have_vfp_registers;	/* Does the target report the VFP registers?  */
+  /* The number of VFP registers reported by the target.  It is zero
+     if VFP registers are not supported.  */
+  int vfp_register_count;
   int have_vfp_pseudos;		/* Are we synthesizing the single precision
 				   VFP registers?  */
   int have_neon_pseudos;	/* Are we synthesizing the quad precision
-- 
1.9.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] Remove global variable arm_linux_has_wmmx_registers in arm-linux-nat.c
  2015-05-26 15:31 [PATCH 1/2] Remove global variable arm_linux_vfp_register_count in arm-linux-nat.c Yao Qi
@ 2015-05-26 15:31 ` Yao Qi
  2015-05-28  9:39 ` [PATCH 1/2] Remove global variable arm_linux_vfp_register_count " Yao Qi
  1 sibling, 0 replies; 3+ messages in thread
From: Yao Qi @ 2015-05-26 15:31 UTC (permalink / raw)
  To: gdb-patches

This patch is to remove the global variable arm_linux_has_wmmx_registers
in arm-linux-nat.c, and add a new field have_wmmx_registers in
'struct gdbarch_tdep'.

gdb:

2015-05-26  Yao Qi  <yao.qi@linaro.org>

	* arm-linux-nat.c (arm_linux_has_wmmx_registers): Remove.
	(arm_linux_fetch_inferior_registers): Use
	tdep->have_wmmx_registers instead of arm_linux_has_wmmx_registers.
	(arm_linux_store_inferior_registers): Likewise.
	(arm_linux_read_description): Don't set
	arm_linux_has_wmmx_registers.
	* arm-tdep.c (arm_gdbarch_init): Set
	tdep->have_wmmx_registers according target descriptions.
	* arm-tdep.h (struct gdbarch_tdep) <have_wmmx_registers>: New
	field.
---
 gdb/arm-linux-nat.c | 17 +++++------------
 gdb/arm-tdep.c      |  4 ++++
 gdb/arm-tdep.h      |  1 +
 3 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index 5c0ede6..7352841 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -61,9 +61,6 @@
 #define PTRACE_SETHBPREGS 30
 #endif
 
-/* A flag for whether the WMMX registers are available.  */
-static int arm_linux_has_wmmx_registers;
-
 extern int arm_apcs_32;
 
 /* On GNU/Linux, threads are implemented as pseudo-processes, in which
@@ -526,7 +523,7 @@ arm_linux_fetch_inferior_registers (struct target_ops *ops,
     {
       fetch_regs (regcache);
       fetch_fpregs (regcache);
-      if (arm_linux_has_wmmx_registers)
+      if (tdep->have_wmmx_registers)
 	fetch_wmmx_regs (regcache);
       if (tdep->vfp_register_count > 0)
 	fetch_vfp_regs (regcache);
@@ -537,7 +534,7 @@ arm_linux_fetch_inferior_registers (struct target_ops *ops,
         fetch_register (regcache, regno);
       else if (regno >= ARM_F0_REGNUM && regno <= ARM_FPS_REGNUM)
         fetch_fpregister (regcache, regno);
-      else if (arm_linux_has_wmmx_registers
+      else if (tdep->have_wmmx_registers
 	       && regno >= ARM_WR0_REGNUM && regno <= ARM_WCGR7_REGNUM)
 	fetch_wmmx_regs (regcache);
       else if (tdep->vfp_register_count > 0
@@ -562,7 +559,7 @@ arm_linux_store_inferior_registers (struct target_ops *ops,
     {
       store_regs (regcache);
       store_fpregs (regcache);
-      if (arm_linux_has_wmmx_registers)
+      if (tdep->have_wmmx_registers)
 	store_wmmx_regs (regcache);
       if (tdep->vfp_register_count > 0)
 	store_vfp_regs (regcache);
@@ -573,7 +570,7 @@ arm_linux_store_inferior_registers (struct target_ops *ops,
         store_register (regcache, regno);
       else if ((regno >= ARM_F0_REGNUM) && (regno <= ARM_FPS_REGNUM))
         store_fpregister (regcache, regno);
-      else if (arm_linux_has_wmmx_registers
+      else if (tdep->have_wmmx_registers
 	       && regno >= ARM_WR0_REGNUM && regno <= ARM_WCGR7_REGNUM)
 	store_wmmx_regs (regcache);
       else if (tdep->vfp_register_count > 0
@@ -636,7 +633,6 @@ static const struct target_desc *
 arm_linux_read_description (struct target_ops *ops)
 {
   CORE_ADDR arm_hwcap = 0;
-  arm_linux_has_wmmx_registers = 0;
 
   if (target_auxv_search (ops, AT_HWCAP, &arm_hwcap) != 1)
     {
@@ -644,10 +640,7 @@ arm_linux_read_description (struct target_ops *ops)
     }
 
   if (arm_hwcap & HWCAP_IWMMXT)
-    {
-      arm_linux_has_wmmx_registers = 1;
-      return tdesc_arm_with_iwmmxt;
-    }
+    return tdesc_arm_with_iwmmxt;
 
   if (arm_hwcap & HWCAP_VFP)
     {
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 1d755e5..e451e05 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -9915,6 +9915,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   struct tdesc_arch_data *tdesc_data = NULL;
   int i, is_m = 0;
   int vfp_register_count = 0, have_vfp_pseudos = 0, have_neon_pseudos = 0;
+  int have_wmmx_registers = 0;
   int have_neon = 0;
   int have_fpa_registers = 1;
   const struct target_desc *tdesc = info.target_desc;
@@ -10178,6 +10179,8 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 	      tdesc_data_cleanup (tdesc_data);
 	      return NULL;
 	    }
+
+	  have_wmmx_registers = 1;
 	}
 
       /* If we have a VFP unit, check whether the single precision registers
@@ -10289,6 +10292,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   tdep->fp_model = fp_model;
   tdep->is_m = is_m;
   tdep->have_fpa_registers = have_fpa_registers;
+  tdep->have_wmmx_registers = have_wmmx_registers;
   gdb_assert (vfp_register_count == 0
 	      || vfp_register_count == 16
 	      || vfp_register_count == 32);
diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h
index 06658a0..f81679a 100644
--- a/gdb/arm-tdep.h
+++ b/gdb/arm-tdep.h
@@ -161,6 +161,7 @@ struct gdbarch_tdep
   enum arm_float_model fp_model; /* Floating point calling conventions.  */
 
   int have_fpa_registers;	/* Does the target report the FPA registers?  */
+  int have_wmmx_registers;	/* Does the target report the WMMX registers?  */
   /* The number of VFP registers reported by the target.  It is zero
      if VFP registers are not supported.  */
   int vfp_register_count;
-- 
1.9.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] Remove global variable arm_linux_vfp_register_count in arm-linux-nat.c
  2015-05-26 15:31 [PATCH 1/2] Remove global variable arm_linux_vfp_register_count in arm-linux-nat.c Yao Qi
  2015-05-26 15:31 ` [PATCH 2/2] Remove global variable arm_linux_has_wmmx_registers " Yao Qi
@ 2015-05-28  9:39 ` Yao Qi
  1 sibling, 0 replies; 3+ messages in thread
From: Yao Qi @ 2015-05-28  9:39 UTC (permalink / raw)
  To: gdb-patches

On 26/05/15 16:31, Yao Qi wrote:
> gdb:
>
> 2015-05-26  Yao Qi<yao.qi@linaro.org>
>
> 	* arm-linux-nat.c (arm_linux_vfp_register_count): Remove.
> 	(fetch_vfp_regs): Use vfp_register_count from gdbarch_tdep
> 	instead of arm_linux_vfp_register_count.
> 	(store_vfp_regs): Likewise.
> 	(arm_linux_fetch_inferior_registers): Likewise.
> 	(arm_linux_store_inferior_registers): Likewise.
> 	(arm_linux_read_description): Don't set
> 	arm_linux_vfp_register_count.
> 	* arm-linux-tdep.c (arm_linux_iterate_over_regset_sections):
> 	Adjust.
> 	* arm-tdep.c (arm_gdbarch_init): Add assert on
> 	vfp_register_count.
> 	* arm-tdep.h (struct gdbarch_tdep) <have_vfp_registers>: Rename
> 	field to vfp_register_count.  All users updated.

I've pushed two patches in.

-- 
Yao (齐尧)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-28  9:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-26 15:31 [PATCH 1/2] Remove global variable arm_linux_vfp_register_count in arm-linux-nat.c Yao Qi
2015-05-26 15:31 ` [PATCH 2/2] Remove global variable arm_linux_has_wmmx_registers " Yao Qi
2015-05-28  9:39 ` [PATCH 1/2] Remove global variable arm_linux_vfp_register_count " Yao Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox