[08/12] NIOS2 Linux: Fill 'collect_regset' in regset structure.
Commit Message
On Tue, May 27 2014, Yao Qi wrote:
> On 05/27/2014 12:36 AM, Andreas Arnez wrote:
>> +#define NIOS2_GREGS_SIZE (4 * 31)
>> +
>
> Is it used?
No, this is needed in the follow-on patch series, but not here.
Removed.
>> /* 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.
Done.
>> 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.
Done.
See the updated patch below.
BTW, I was wondering why nios2_supply_gregset initializes the
unavailable registers with zero instead of just leaving them
<unavailable>. This special treatment is the main reason against using
the new generic supply/collect functions from regcache.c, because those
currently do not support initializing registers with zero.
--
@@ -73,11 +73,30 @@ nios2_supply_gregset (const struct regset *regset,
}
}
+/* Implement the collect_regset hook for core files. */
+
+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,
+ nios2_collect_gregset
};
/* Implement the regset_from_core_section gdbarch method. */