"pc", "", "unique"
};
- if (regno < 0)
- return NULL;
- if (regno >= ARRAY_SIZE(register_names))
- return NULL;
+ gdb_static_assert (ALPHA_NUM_REGS == ARRAY_SIZE (register_names));
return register_names[regno];
}
"SREG", "SP", "PC2",
"pc"
};
- if (regnum < 0)
- return NULL;
- if (regnum >= (sizeof (register_names) / sizeof (*register_names)))
- return NULL;
+ gdb_static_assert (ARRAY_SIZE (register_names)
+ == (AVR_NUM_REGS + AVR_NUM_PSEUDO_REGS));
return register_names[regnum];
}
static const char *
bpf_register_name (struct gdbarch *gdbarch, int reg)
{
- if (reg >= 0 && reg < BPF_NUM_REGS)
- return bpf_register_names[reg];
- return NULL;
+ gdb_static_assert (ARRAY_SIZE (bpf_register_names) == BPF_NUM_REGS);
+ return bpf_register_names[reg];
}
/* Return the GDB type of register REGNUM. */
"r8", "r9", "r10", "r11", \
"r12", "r13", "sp", "pc" };
- if (regno >= 0 && regno < NUM_GENREGS)
+ if (regno < NUM_GENREGS)
{
/* General register. */
+ gdb_static_assert (ARRAY_SIZE (cris_genreg_names) == NUM_GENREGS);
return cris_genreg_names[regno];
}
else if (regno >= NUM_GENREGS && regno < gdbarch_num_regs (gdbarch))
static const char *
frv_register_name (struct gdbarch *gdbarch, int reg)
{
- if (reg < 0)
- return "?toosmall?";
-
- if (reg >= frv_num_regs + frv_num_pseudo_regs)
- return "?toolarge?";
-
frv_gdbarch_tdep *tdep = gdbarch_tdep<frv_gdbarch_tdep> (gdbarch);
return tdep->register_names[reg];
}
static const char *
ft32_register_name (struct gdbarch *gdbarch, int reg_nr)
{
- if (reg_nr < 0)
- return NULL;
- if (reg_nr >= FT32_NUM_REGS)
- return NULL;
+ gdb_static_assert (ARRAY_SIZE (ft32_register_names) == FT32_NUM_REGS);
return ft32_register_names[reg_nr];
}
h8300_register_name_common (const char *regnames[], int numregs,
struct gdbarch *gdbarch, int regno)
{
- if (regno < 0
- || regno >= numregs)
- internal_error (__FILE__, __LINE__,
- _("h8300_register_name_common: illegal register number %d"),
- regno);
- else
- return regnames[regno];
+ gdb_assert (numregs == gdbarch_num_cooked_regs (gdbarch));
+ return regnames[regno];
}
static const char *
"fr28", "fr28R", "fr29", "fr29R",
"fr30", "fr30R", "fr31", "fr31R"
};
- if (i < 0 || i >= (sizeof (names) / sizeof (*names)))
- return NULL;
- else
- return names[i];
+ gdb_static_assert (ARRAY_SIZE (names) == hppa32_num_regs);
+ return names[i];
}
static const char *
"fr24", "fr25", "fr26", "fr27",
"fr28", "fr29", "fr30", "fr31"
};
- if (i < 0 || i >= (sizeof (names) / sizeof (*names)))
- return NULL;
- else
- return names[i];
+ gdb_static_assert (ARRAY_SIZE (names) == hppa64_num_regs);
+ return names[i];
}
/* Map dwarf DBX register numbers to GDB register numbers. */
"r30", "r31",
"pc"
};
- if (regnum < 0 || regnum >= E_NUM_REGS)
- return NULL;
+ gdb_static_assert (ARRAY_SIZE (names) == E_NUM_REGS);
return names[regnum];
}
"PC", "EID", "EBA", "DEBA", "IE", "IM", "IP"
};
- if ((reg_nr < 0) || (reg_nr >= ARRAY_SIZE (register_names)))
- return NULL;
- else
- return register_names[reg_nr];
+ gdb_static_assert (ARRAY_SIZE (register_names) == SIM_LM32_NUM_REGS);
+ return register_names[reg_nr];
}
/* Return type of register. */
static const char *
m32r_register_name (struct gdbarch *gdbarch, int reg_nr)
{
- if (reg_nr < 0)
- return NULL;
- if (reg_nr >= M32R_NUM_REGS)
- return NULL;
+ gdb_static_assert (ARRAY_SIZE (m32r_register_names) == M32R_NUM_REGS);
return m32r_register_names[reg_nr];
}
if (reg_nr == HARD_PC_REGNUM && use_page_register (gdbarch))
return "ppc";
-
- if (reg_nr < 0)
- return NULL;
if (reg_nr >= M68HC11_ALL_REGS)
- return NULL;
+ return "";
m68hc11_initialize_register_info ();
{
m68k_gdbarch_tdep *tdep = gdbarch_tdep<m68k_gdbarch_tdep> (gdbarch);
- if (regnum < 0 || regnum >= ARRAY_SIZE (m68k_register_names))
- internal_error (__FILE__, __LINE__,
- _("m68k_register_name: illegal register number %d"),
- regnum);
- else if (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FPI_REGNUM
- && tdep->fpregs_present == 0)
+ gdb_static_assert (ARRAY_SIZE (m68k_register_names) == M68K_NUM_REGS);
+ if (regnum >= M68K_FP0_REGNUM && regnum <= M68K_FPI_REGNUM
+ && tdep->fpregs_present == 0)
return "";
else
return m68k_register_names[regnum];
static const char *
microblaze_register_name (struct gdbarch *gdbarch, int regnum)
{
- if (regnum >= 0 && regnum < MICROBLAZE_NUM_REGS)
- return microblaze_register_names[regnum];
- return NULL;
+ gdb_static_assert (ARRAY_SIZE (microblaze_register_names)
+ == MICROBLAZE_NUM_REGS);
+ return microblaze_register_names[regnum];
}
static struct type *
}
static const char *
-register_name (int reg, const char **regs, long sizeof_regs)
+register_name (int reg, const char **regs, long num_regs)
{
- if (reg < 0 || reg >= sizeof_regs / sizeof (regs[0]))
- return NULL;
- else
- return regs[reg];
+ gdb_assert (reg < num_regs);
+ return regs[reg];
}
static const char *
"", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "fp"
};
- return register_name (reg, regs, sizeof regs);
+ return register_name (reg, regs, ARRAY_SIZE (regs));
}
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"ssp", "msp", "usp", "mcrh", "mcrl", "mcvf", "", "", ""
};
- return register_name (reg, regs, sizeof regs);
+ return register_name (reg, regs, ARRAY_SIZE (regs));
}
static const char *
"fs16", "fs17", "fs18", "fs19", "fs20", "fs21", "fs22", "fs23",
"fs24", "fs25", "fs26", "fs27", "fs28", "fs29", "fs30", "fs31"
};
- return register_name (reg, regs, sizeof regs);
+ return register_name (reg, regs, ARRAY_SIZE (regs));
}
static struct type *
static const char *
moxie_register_name (struct gdbarch *gdbarch, int reg_nr)
{
- if (reg_nr < 0)
- return NULL;
- if (reg_nr >= MOXIE_NUM_REGS)
- return NULL;
+ gdb_static_assert (ARRAY_SIZE (moxie_register_names) == MOXIE_NUM_REGS);
return moxie_register_names[reg_nr];
}
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
};
+ gdb_static_assert (ARRAY_SIZE (reg_names) == (MSP430_NUM_REGS
+ + MSP430_NUM_PSEUDO_REGS));
return reg_names[regnr];
}
regnum -= gdbarch_num_regs (gdbarch);
/* Currently, only FSRs could be defined as pseudo registers. */
- if (regnum < gdbarch_num_pseudo_regs (gdbarch))
- return nds32_fsr_register_names[regnum];
-
- warning (_("Unknown nds32 pseudo register %d."), regnum);
- return NULL;
+ gdb_assert (regnum < gdbarch_num_pseudo_regs (gdbarch));
+ return nds32_fsr_register_names[regnum];
}
/* Implement the "pseudo_register_read" gdbarch method. */
nios2_register_name (struct gdbarch *gdbarch, int regno)
{
/* Use mnemonic aliases for GPRs. */
- if (regno >= 0 && regno < NIOS2_NUM_REGS)
+ if (regno < NIOS2_NUM_REGS)
return nios2_reg_names[regno];
else
return tdesc_register_name (gdbarch, regno);
"pc", "pr", "gbr", "vbr", "mach", "macl", "sr"
};
- gdb_assert (reg_nr >= 0);
- if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
+ if (reg_nr >= ARRAY_SIZE (register_names))
return "";
return register_names[reg_nr];
}
"r0b1", "r1b1", "r2b1", "r3b1", "r4b1", "r5b1", "r6b1", "r7b1",
};
- gdb_assert (reg_nr >= 0);
- if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
+ if (reg_nr >= ARRAY_SIZE (register_names))
return "";
return register_names[reg_nr];
}
"r0b0", "r1b0", "r2b0", "r3b0", "r4b0", "r5b0", "r6b0", "r7b0",
"r0b1", "r1b1", "r2b1", "r3b1", "r4b1", "r5b1", "r6b1", "r7b1",
};
- gdb_assert (reg_nr >= 0);
- if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
+ if (reg_nr >= ARRAY_SIZE (register_names))
return "";
return register_names[reg_nr];
}
"fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7",
"fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15",
};
- gdb_assert (reg_nr >= 0);
- if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
+ if (reg_nr >= ARRAY_SIZE (register_names))
return "";
return register_names[reg_nr];
}
/* double precision (pseudo) 68 - 75 */
"dr0", "dr2", "dr4", "dr6", "dr8", "dr10", "dr12", "dr14",
};
- gdb_assert (reg_nr >= 0);
- if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
+ if (reg_nr >= ARRAY_SIZE (register_names))
return "";
return register_names[reg_nr];
}
"bank",
/* double precision (pseudo) 68 - 75: report blank, see below. */
};
- gdb_assert (reg_nr >= 0);
- if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
+ if (reg_nr >= ARRAY_SIZE (register_names))
return "";
return register_names[reg_nr];
}
"", "",
"rs", "re",
};
- gdb_assert (reg_nr >= 0);
- if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
+ if (reg_nr >= ARRAY_SIZE (register_names))
return "";
return register_names[reg_nr];
}
"rs", "re", "", "", "", "", "", "",
"r0b", "r1b", "r2b", "r3b", "r4b", "r5b", "r6b", "r7b",
};
- gdb_assert (reg_nr >= 0);
- if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
+ if (reg_nr >= ARRAY_SIZE (register_names))
return "";
return register_names[reg_nr];
}
/* FIXME: missing XF */
/* FIXME: missing XD */
};
- gdb_assert (reg_nr >= 0);
- if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
+ if (reg_nr >= ARRAY_SIZE (register_names))
return "";
return register_names[reg_nr];
}
/* vectors (pseudo) 76 - 79 -- not for nofpu target: report blank
below. */
};
- gdb_assert (reg_nr >= 0);
- if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
+ if (reg_nr >= ARRAY_SIZE (register_names))
return "";
return register_names[reg_nr];
}
"rs", "re", "", "", "", "", "", "",
"r0b", "r1b", "r2b", "r3b", "r4b", "r5b", "r6b", "r7b",
};
- gdb_assert (reg_nr >= 0);
- if (reg_nr >= (sizeof (register_names) / sizeof (*register_names)))
+ if (reg_nr >= ARRAY_SIZE (register_names))
return "";
return register_names[reg_nr];
}
{
regnum -= gdbarch_num_regs (gdbarch);
- if (regnum < SPARC32_NUM_PSEUDO_REGS)
- return sparc32_pseudo_register_names[regnum];
-
- internal_error (__FILE__, __LINE__,
- _("sparc32_pseudo_register_name: bad register number %d"),
- regnum);
+ gdb_assert (regnum < SPARC32_NUM_PSEUDO_REGS);
+ return sparc32_pseudo_register_names[regnum];
}
/* Return the name of register REGNUM. */
{
regnum -= gdbarch_num_regs (gdbarch);
- if (regnum < SPARC64_NUM_PSEUDO_REGS)
- return sparc64_pseudo_register_names[regnum];
-
- internal_error (__FILE__, __LINE__,
- _("sparc64_pseudo_register_name: bad register number %d"),
- regnum);
+ gdb_assert (regnum < SPARC64_NUM_PSEUDO_REGS);
+ return sparc64_pseudo_register_names[regnum];
}
/* Return the name of register REGNUM. */
static const char *
tic6x_register_name (struct gdbarch *gdbarch, int regno)
{
- if (regno < 0)
- return NULL;
-
if (tdesc_has_registers (gdbarch_target_desc (gdbarch)))
return tdesc_register_name (gdbarch, regno);
else if (regno >= ARRAY_SIZE (tic6x_register_names))
static const char *
tilegx_register_name (struct gdbarch *gdbarch, int regnum)
{
- static const char *const register_names[TILEGX_NUM_REGS] =
+ static const char *const register_names[] =
{
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
"pc", "faultnum",
};
- if (regnum < 0 || regnum >= TILEGX_NUM_REGS)
- internal_error (__FILE__, __LINE__,
- "tilegx_register_name: invalid register number %d",
- regnum);
-
+ gdb_static_assert (TILEGX_NUM_REGS == ARRAY_SIZE (register_names));
return register_names[regnum];
}
"sr24", "sr25", "sr26", "sr27", "sr28", "sr29", "sr30", "sr31",
"pc", "fp"
};
- if (regnum < 0 || regnum > E_NUM_OF_V850_REGS)
- return "";
+ gdb_static_assert (E_NUM_OF_V850_REGS == ARRAY_SIZE (v850_reg_names));
return v850_reg_names[regnum];
}
"sr24", "sr25", "sr26", "sr27", "sr28", "sr29", "sr30", "sr31",
"pc", "fp"
};
- if (regnum < 0 || regnum > E_NUM_OF_V850E_REGS)
- return "";
+ gdb_static_assert (E_NUM_OF_V850E_REGS == ARRAY_SIZE (v850e_reg_names));
return v850e_reg_names[regnum];
}
"", "", "", "", "", "", "", "",
"", "", "", "fpspc"
};
- if (regnum < 0 || regnum >= E_NUM_OF_V850E2_REGS)
+ if (regnum >= E_NUM_OF_V850E2_REGS)
return "";
return v850e2_reg_names[regnum];
}
"vr24", "vr25", "vr26", "vr27", "vr28", "vr29", "vr30", "vr31",
};
- if (regnum < 0 || regnum >= E_NUM_OF_V850E3V5_REGS)
- return "";
+ gdb_static_assert (E_NUM_OF_V850E3V5_REGS
+ == ARRAY_SIZE (v850e3v5_reg_names));
return v850e3v5_reg_names[regnum];
}
"ps",
};
- if (regnum >= 0 && regnum < ARRAY_SIZE (register_names))
- return register_names[regnum];
-
- return NULL;
+ gdb_static_assert (VAX_NUM_REGS == ARRAY_SIZE (register_names));
+ return register_names[regnum];
}
/* Return the GDB type object for the "standard" data type of data in
"psw", "sp", "pc"
};
- if (regnum < 0 || regnum >= E_NUM_REGS)
- internal_error (__FILE__, __LINE__,
- _("xstormy16_register_name: illegal register number %d"),
- regnum);
- else
- return register_names[regnum];
-
+ gdb_static_assert (ARRAY_SIZE (register_names) == E_NUM_REGS);
+ return register_names[regnum];
}
static struct type *
xtensa_gdbarch_tdep *tdep = gdbarch_tdep<xtensa_gdbarch_tdep> (gdbarch);
/* Return the name stored in the register map. */
- if (regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch))
- return tdep->regmap[regnum].name;
-
- internal_error (__FILE__, __LINE__, _("invalid register %d"), regnum);
- return 0;
+ return tdep->regmap[regnum].name;
}
/* Return the type of a register. Create a new type, if necessary. */
static const char *
z80_register_name (struct gdbarch *gdbarch, int regnum)
{
- if (regnum >= 0 && regnum < ARRAY_SIZE (z80_reg_names))
+ if (regnum < ARRAY_SIZE (z80_reg_names))
return z80_reg_names[regnum];
- return NULL;
+ return "";
}
/* Return the type of a register specified by the architecture. Only