gdb/csky: remove nullptr return from csky_pseudo_register_name

Building on the previous commits, in this commit I remove two
instances of 'return NULL' from csky_pseudo_register_name, and replace
them with a return of the empty string.

These two are particularly interesting, and worth pulling into their
own commit, because these returns of NULL appear to be depended on
within other parts of the csky code.

In csky-linux-tdep.c in the register collect/supply code, GDB checks
for the register name being nullptr in order to decide if a target
supports a particular feature or not.  I've updated the code to check
for the empty string.

I have no way of testing this change.
This commit is contained in:
Andrew Burgess 2022-09-01 15:39:59 +01:00
parent 7df4240040
commit 7ac20d65a8
2 changed files with 11 additions and 20 deletions

View file

@ -155,7 +155,7 @@ csky_supply_fregset (const struct regset *regset,
/* Supply vr0~vr15. */
for (i = 0; i < 16; i ++)
{
if (gdbarch_register_name (gdbarch, (CSKY_VR0_REGNUM + i)))
if (*gdbarch_register_name (gdbarch, (CSKY_VR0_REGNUM + i)) != '\0')
{
offset = 16 * i;
regcache->raw_supply (CSKY_VR0_REGNUM + i, fregs + offset);
@ -164,7 +164,7 @@ csky_supply_fregset (const struct regset *regset,
/* Supply fr0~fr15. */
for (i = 0; i < 16; i ++)
{
if (gdbarch_register_name (gdbarch, (CSKY_FR0_REGNUM + i)))
if (*gdbarch_register_name (gdbarch, (CSKY_FR0_REGNUM + i)) != '\0')
{
offset = 16 * i;
regcache->raw_supply (CSKY_FR0_REGNUM + i, fregs + offset);
@ -173,7 +173,7 @@ csky_supply_fregset (const struct regset *regset,
/* Supply fr16~fr31. */
for (i = 0; i < 16; i ++)
{
if (gdbarch_register_name (gdbarch, (CSKY_FR16_REGNUM + i)))
if (*gdbarch_register_name (gdbarch, (CSKY_FR16_REGNUM + i)) != '\0')
{
offset = (16 * 16) + (8 * i);
regcache->raw_supply (CSKY_FR16_REGNUM + i, fregs + offset);
@ -182,7 +182,7 @@ csky_supply_fregset (const struct regset *regset,
/* Supply fcr, fesr, fid. */
for (i = 0; i < 3; i ++)
{
if (gdbarch_register_name (gdbarch, fcr_regno[i]))
if (*gdbarch_register_name (gdbarch, fcr_regno[i]) != '\0')
{
offset = (16 * 16) + (16 * 8) + (4 * i);
regcache->raw_supply (fcr_regno[i], fregs + offset);
@ -245,7 +245,7 @@ csky_collect_fregset (const struct regset *regset,
/* Supply vr0~vr15. */
for (i = 0; i < 16; i ++)
{
if (gdbarch_register_name (gdbarch, (CSKY_VR0_REGNUM + i)))
if (*gdbarch_register_name (gdbarch, (CSKY_VR0_REGNUM + i)) != '\0')
{
offset = 16 * i;
regcache ->raw_collect (CSKY_VR0_REGNUM + i, fregs + offset);
@ -254,7 +254,7 @@ csky_collect_fregset (const struct regset *regset,
/* Supply fr16~fr31. */
for (i = 0; i < 16; i ++)
{
if (gdbarch_register_name (gdbarch, (CSKY_FR16_REGNUM + i)))
if (*gdbarch_register_name (gdbarch, (CSKY_FR16_REGNUM + i)) != '\0')
{
offset = (16 * 16) + (8 * i);
regcache ->raw_collect (CSKY_FR16_REGNUM + i, fregs + offset);
@ -263,7 +263,7 @@ csky_collect_fregset (const struct regset *regset,
/* Supply fcr, fesr, fid. */
for (i = 0; i < 3; i ++)
{
if (gdbarch_register_name (gdbarch, fcr_regno[i]))
if (*gdbarch_register_name (gdbarch, fcr_regno[i]) != '\0')
{
offset = (16 * 16) + (16 * 8) + (4 * i);
regcache ->raw_collect (fcr_regno[i], fregs + offset);

View file

@ -660,21 +660,12 @@ static const char * const csky_register_names[] =
static const char *
csky_register_name (struct gdbarch *gdbarch, int reg_nr)
{
int num_regs = gdbarch_num_regs (gdbarch);
int num_pseudo_regs = gdbarch_num_pseudo_regs (gdbarch);
if ((reg_nr >= num_regs) && (reg_nr < (num_regs + num_pseudo_regs)))
if (reg_nr >= gdbarch_num_regs (gdbarch))
return csky_pseudo_register_name (gdbarch, reg_nr);
if (tdesc_has_registers (gdbarch_target_desc (gdbarch)))
return tdesc_register_name (gdbarch, reg_nr);
if (reg_nr < 0)
return NULL;
if (reg_nr >= gdbarch_num_regs (gdbarch))
return NULL;
return csky_register_names[reg_nr];
}
@ -2543,15 +2534,15 @@ csky_pseudo_register_name (struct gdbarch *gdbarch, int regno)
if (regno < tdep->fv_pseudo_registers_count)
{
if ((regno < 64) && ((regno % 4) >= 2) && !tdep->has_vr0)
return NULL;
return "";
else if ((regno >= 64) && ((regno % 4) >= 2))
return NULL;
return "";
else
return fv_pseudo_names[regno];
}
}
return NULL;
return "";
}
/* Read for csky pseudo regs. */