[08/12] NIOS2 Linux: Fill 'collect_regset' in regset structure.

Message ID 1401122208-2481-9-git-send-email-arnez@linux.vnet.ibm.com
State New, archived
Headers

Commit Message

Andreas Arnez May 26, 2014, 4:36 p.m. UTC
  gdb/
	* nios2-linux-tdep.c (NIOS2_GREGS_SIZE): New macro.
	(nios2_collect_gregset): New function.
	(nios2_core_regset): Add collect method.
---
 gdb/nios2-linux-tdep.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
  

Comments

Yao Qi May 27, 2014, 2:12 a.m. UTC | #1
On 05/27/2014 12:36 AM, Andreas Arnez wrote:
> +#define NIOS2_GREGS_SIZE (4 * 31)
> +

Is it used?

>  /* Implement the supply_regset hook for core files.  */
>  
>  static void
> @@ -73,11 +75,26 @@ nios2_supply_gregset (const struct regset *regset,
>        }
>  }
>  
> +static void
> +nios2_collect_gregset (const struct regset *regset,
> +		       const struct regcache *regcache,
> +		       int regnum, void *gregs_buf, size_t len)

The comment to this function is needed, like the comment to
nios2_supply_gregset.

> +{
> +  gdb_byte *gregs = gregs_buf;
> +  int regno;
> +
> +  for (regno = NIOS2_Z_REGNUM; regno <= NIOS2_MPUACC_REGNUM; regno++)
> +    if (regnum == -1 || regnum == regno)
> +      {
> +	if (reg_offsets[regno] != -1)
> +	  regcache_raw_collect (regcache, regno,
> +				gregs + 4 * reg_offsets[regno]);
> +      }
> +}
> +
>  static const struct regset nios2_core_regset =
>  {
> -  NULL,
> -  nios2_supply_gregset,
> -  NULL,
> +  NULL, nios2_supply_gregset, nios2_collect_gregset
>  };

I'd like to put each field in one line.  Otherwise, it is OK.
  

Patch

diff --git a/gdb/nios2-linux-tdep.c b/gdb/nios2-linux-tdep.c
index 84ab576..f4cacf6 100644
--- a/gdb/nios2-linux-tdep.c
+++ b/gdb/nios2-linux-tdep.c
@@ -51,6 +51,8 @@  static const int reg_offsets[NIOS2_NUM_REGS] =
   -1, -1, -1, -1, -1, -1, -1, -1
 };
 
+#define NIOS2_GREGS_SIZE (4 * 31)
+
 /* Implement the supply_regset hook for core files.  */
 
 static void
@@ -73,11 +75,26 @@  nios2_supply_gregset (const struct regset *regset,
       }
 }
 
+static void
+nios2_collect_gregset (const struct regset *regset,
+		       const struct regcache *regcache,
+		       int regnum, void *gregs_buf, size_t len)
+{
+  gdb_byte *gregs = gregs_buf;
+  int regno;
+
+  for (regno = NIOS2_Z_REGNUM; regno <= NIOS2_MPUACC_REGNUM; regno++)
+    if (regnum == -1 || regnum == regno)
+      {
+	if (reg_offsets[regno] != -1)
+	  regcache_raw_collect (regcache, regno,
+				gregs + 4 * reg_offsets[regno]);
+      }
+}
+
 static const struct regset nios2_core_regset =
 {
-  NULL,
-  nios2_supply_gregset,
-  NULL,
+  NULL, nios2_supply_gregset, nios2_collect_gregset
 };
 
 /* Implement the regset_from_core_section gdbarch method.  */