diff mbox

[10/11] Add XTENSA_MAX_REGISTER_SIZE

Message ID A9D0B291-CF87-44EB-9B48-E1E66B7578D9@arm.com
State New
Headers show

Commit Message

Alan Hayward April 4, 2017, 10:15 a.m. UTC
Max size set to 128bits, which I determined using xtensa_register_type()

Tested on a --enable-targets=all build using make check with board files
unix and native-gdbserver.

I do not have a XTENSA machine to test on.

Ok to commit?

Alan.

2017-04-04  Alan Hayward  <alan.hayward@arm.com>

	* xtensa-tdep.c (xtensa_register_write_masked): Use XTENSA_MAX_REGISTER_SIZE.
	(xtensa_register_read_masked): Likewise.
	(xtensa_pseudo_register_read): Likewise.
	(xtensa_pseudo_register_write): Likewise.
	* xtensa-tdep.h (XTENSA_MAX_REGISTER_SIZE): Add.

Comments

Yao Qi April 5, 2017, 10:23 a.m. UTC | #1
Alan Hayward <Alan.Hayward@arm.com> writes:

> @@ -559,7 +559,7 @@ xtensa_pseudo_register_read (struct gdbarch *gdbarch,
>        && (regnum >= gdbarch_tdep (gdbarch)->a0_base)
>        && (regnum <= gdbarch_tdep (gdbarch)->a0_base + 15))
>      {
> -      gdb_byte *buf = (gdb_byte *) alloca (MAX_REGISTER_SIZE);
> +      gdb_byte *buf = (gdb_byte *) alloca (XTENSA_MAX_REGISTER_SIZE);
>        enum register_status status;
>
>        status = regcache_raw_read (regcache,
> @@ -655,7 +655,7 @@ xtensa_pseudo_register_write (struct gdbarch *gdbarch,
>        && (regnum >= gdbarch_tdep (gdbarch)->a0_base)
>        && (regnum <= gdbarch_tdep (gdbarch)->a0_base + 15))
>      {
> -      gdb_byte *buf = (gdb_byte *) alloca (MAX_REGISTER_SIZE);
> +      gdb_byte *buf = (gdb_byte *) alloca (XTENSA_MAX_REGISTER_SIZE);
>
>        regcache_raw_read (regcache,
>  			 gdbarch_tdep (gdbarch)->wb_regnum, buf);

The "buf" can be removed by using regcache_raw_read_unsigned.
diff mbox

Patch

diff --git a/gdb/xtensa-tdep.h b/gdb/xtensa-tdep.h
index 46aeecb35567930ac1497df3dae09d5ffe57e9e1..39abe1f8acb8fc508f48c7cf5bd81366e5f584be 100644
--- a/gdb/xtensa-tdep.h
+++ b/gdb/xtensa-tdep.h
@@ -222,6 +222,9 @@  struct gdbarch_tdep
   struct ctype_cache *type_entries;
 };

+/* Big enough to hold the size of the largest register in bytes.  */
+#define XTENSA_MAX_REGISTER_SIZE	16
+
 /* Macro to instantiate a gdbarch_tdep structure.  */

 #define XTENSA_GDBARCH_TDEP_INSTANTIATE(rmap,spillsz)			\
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index 376f4c7340c3292273d5b0912b23ff7166382e8b..655f884926dfad88cb03b582f608788c049d3bad 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -370,7 +370,7 @@  static void
 xtensa_register_write_masked (struct regcache *regcache,
 			      xtensa_register_t *reg, const gdb_byte *buffer)
 {
-  unsigned int value[(MAX_REGISTER_SIZE + 3) / 4];
+  unsigned int value[(XTENSA_MAX_REGISTER_SIZE + 3) / 4];
   const xtensa_mask_t *mask = reg->mask;

   int shift = 0;		/* Shift for next mask (mod 32).  */
@@ -454,7 +454,7 @@  static enum register_status
 xtensa_register_read_masked (struct regcache *regcache,
 			     xtensa_register_t *reg, gdb_byte *buffer)
 {
-  unsigned int value[(MAX_REGISTER_SIZE + 3) / 4];
+  unsigned int value[(XTENSA_MAX_REGISTER_SIZE + 3) / 4];
   const xtensa_mask_t *mask = reg->mask;

   int shift = 0;
@@ -559,7 +559,7 @@  xtensa_pseudo_register_read (struct gdbarch *gdbarch,
       && (regnum >= gdbarch_tdep (gdbarch)->a0_base)
       && (regnum <= gdbarch_tdep (gdbarch)->a0_base + 15))
     {
-      gdb_byte *buf = (gdb_byte *) alloca (MAX_REGISTER_SIZE);
+      gdb_byte *buf = (gdb_byte *) alloca (XTENSA_MAX_REGISTER_SIZE);
       enum register_status status;

       status = regcache_raw_read (regcache,
@@ -655,7 +655,7 @@  xtensa_pseudo_register_write (struct gdbarch *gdbarch,
       && (regnum >= gdbarch_tdep (gdbarch)->a0_base)
       && (regnum <= gdbarch_tdep (gdbarch)->a0_base + 15))
     {
-      gdb_byte *buf = (gdb_byte *) alloca (MAX_REGISTER_SIZE);
+      gdb_byte *buf = (gdb_byte *) alloca (XTENSA_MAX_REGISTER_SIZE);

       regcache_raw_read (regcache,
 			 gdbarch_tdep (gdbarch)->wb_regnum, buf);