+2018-10-21 Simon Marchi <simon.marchi@ericsson.com>
+
+ * gdbarch.sh (gdbarch_num_cooked_regs): New.
+ * gdbarch.h: Re-generate.
+ * ax-gdb.c (gen_expr): Use gdbarch_num_cooked_regs.
+ * dwarf2-frame.c (dwarf2_frame_cache): Likewise.
+ * eval.c (evaluate_subexp_standard): Likewise.
+ * findvar.c (value_of_register): Likewise.
+ (value_of_register_lazy): Likewise.
+ (address_from_register): Likewise.
+ * frame.c (get_frame_register_bytes): Likewise.
+ * gdbarch-selftests.c (register_to_value_test): Likewise.
+ * h8300-tdep.c (h8300_register_type): Likewise.
+ * i386-tdep.c (i386_dbx_reg_to_regnum): Likewise.
+ (i386_svr4_reg_to_regnum): Likewise.
+ * infcmd.c (default_print_registers_info): Likewise.
+ (registers_info): Likewise.
+ (print_vector_info): Likewise.
+ (default_print_float_info): Likewise.
+ * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise.
+ * mdebugread.c (mdebug_reg_to_regnum): Likewise.
+ * mi/mi-main.c (mi_cmd_data_list_register_names): Likewise.
+ (mi_cmd_data_list_changed_registers): Likewise.
+ (mi_cmd_data_list_register_values): Likewise.
+ (mi_cmd_data_write_register_values): Likewise.
+ (mi_cmd_trace_frame_collected): Likewise.
+ * mips-tdep.c (print_gp_register_row): Likewise.
+ (mips_print_registers_info): Likewise.
+ * nds32-tdep.c (nds32_gdbarch_init): Likewise.
+ * regcache.c (init_regcache_descr): Likewise.
+ (register_size): Likewise.
+ (register_dump::dump): Likewise.
+ (cooked_read_test): Likewise.
+ (cooked_write_test): Likewise.
+ * rs6000-tdep.c (rs6000_register_sim_regno): Likewise.
+ (rs6000_gdbarch_init): Likewise.
+ * stabsread.c (stab_reg_to_regnum): Likewise.
+ * stack.c (info_frame_command): Likewise.
+ * target-descriptions.c (tdesc_register_name): Likewise.
+ * trad-frame.c (trad_frame_alloc_saved_regs): Likewise.
+ * tui/tui-regs.c (tui_show_register_group): Likewise.
+ * user-regs.c (user_reg_map_name_to_regnum): Likewise.
+ (user_reg_map_regnum_to_name): Likewise.
+ (value_of_user_reg): Likewise.
+ (maintenance_print_user_registers): Likewise.
+ * xtensa-tdep.c (xtensa_find_register_by_name): Likewise.
+ (xtensa_register_name): Likewise.
+ (xtensa_register_type): Likewise.
+ (xtensa_reg_to_regnum): Likewise.
+ (xtensa_pseudo_register_read): Likewise.
+ (xtensa_pseudo_register_write): Likewise.
+
2018-10-21 Simon Marchi <simon.marchi@polymtl.ca>
* amd64-tdep.c (amd64_pseudo_register_read_value): Use
internal_error (__FILE__, __LINE__,
_("Register $%s not available"), name);
/* No support for tracing user registers yet. */
- if (reg >= gdbarch_num_regs (ax->gdbarch)
- + gdbarch_num_pseudo_regs (ax->gdbarch))
+ if (reg >= gdbarch_num_cooked_regs (ax->gdbarch))
error (_("'%s' is a user-register; "
"GDB cannot yet trace user-register contents."),
name);
dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
- const int num_regs = gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch);
+ const int num_regs = gdbarch_num_cooked_regs (gdbarch);
struct dwarf2_frame_cache *cache;
struct dwarf2_fde *fde;
CORE_ADDR entry_pc;
So for these registers, we fetch the register value regardless
of the evaluation mode. */
if (noside == EVAL_AVOID_SIDE_EFFECTS
- && regno < gdbarch_num_regs (exp->gdbarch)
- + gdbarch_num_pseudo_regs (exp->gdbarch))
+ && regno < gdbarch_num_cooked_regs (exp->gdbarch))
val = value_zero (register_type (exp->gdbarch, regno), not_lval);
else
val = value_of_register (regno, get_selected_frame (NULL));
/* User registers lie completely outside of the range of normal
registers. Catch them early so that the target never sees them. */
- if (regnum >= gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch))
+ if (regnum >= gdbarch_num_cooked_regs (gdbarch))
return value_of_user_reg (regnum, frame);
reg_val = value_of_register_lazy (frame, regnum);
struct value *reg_val;
struct frame_info *next_frame;
- gdb_assert (regnum < (gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch)));
+ gdb_assert (regnum < gdbarch_num_cooked_regs (gdbarch));
gdb_assert (frame != NULL);
struct type *type = builtin_type (gdbarch)->builtin_data_ptr;
struct value *value;
CORE_ADDR result;
- int regnum_max_excl = (gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch));
+ int regnum_max_excl = gdbarch_num_cooked_regs (gdbarch);
if (regnum < 0 || regnum >= regnum_max_excl)
error (_("Invalid register #%d, expecting 0 <= # < %d"), regnum,
/* Ensure that we will not read beyond the end of the register file.
This can only ever happen if the debug information is bad. */
maxsize = -offset;
- numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
+ numregs = gdbarch_num_cooked_regs (gdbarch);
for (i = regnum; i < numregs; i++)
{
int thissize = register_size (gdbarch, i);
= make_scoped_restore (&inferior_ptid, mock_ptid);
struct frame_info *frame = get_current_frame ();
- const int num_regs = (gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch));
+ const int num_regs = gdbarch_num_cooked_regs (gdbarch);
/* Test gdbarch methods register_to_value and value_to_register with
different combinations of register numbers and types. */
extern void gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file);
+/* Return the number of cooked registers (raw + pseudo) for ARCH. */
+
+static inline int
+gdbarch_num_cooked_regs (gdbarch *arch)
+{
+ return gdbarch_num_regs (arch) + gdbarch_num_pseudo_regs (arch);
+}
+
#endif
extern void gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file);
+/* Return the number of cooked registers (raw + pseudo) for ARCH. */
+
+static inline int
+gdbarch_num_cooked_regs (gdbarch *arch)
+{
+ return gdbarch_num_regs (arch) + gdbarch_num_pseudo_regs (arch);
+}
+
#endif
EOF
exec 1>&2
static struct type *
h8300_register_type (struct gdbarch *gdbarch, int regno)
{
- if (regno < 0 || regno >= gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch))
+ if (regno < 0 || regno >= gdbarch_num_cooked_regs (gdbarch))
internal_error (__FILE__, __LINE__,
_("h8300_register_type: illegal register number %d"),
regno);
}
/* This will hopefully provoke a warning. */
- return gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
+ return gdbarch_num_cooked_regs (gdbarch);
}
/* Convert SVR4 DWARF register number REG to the appropriate register number
int regnum = i386_svr4_dwarf_reg_to_regnum (gdbarch, reg);
if (regnum == -1)
- return gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
+ return gdbarch_num_cooked_regs (gdbarch);
return regnum;
}
int regnum, int print_all)
{
int i;
- const int numregs = gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch);
+ const int numregs = gdbarch_num_cooked_regs (gdbarch);
for (i = 0; i < numregs; i++)
{
/* User registers lie completely outside of the range of
normal registers. Catch them early so that the target
never sees them. */
- if (regnum >= gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch))
+ if (regnum >= gdbarch_num_cooked_regs (gdbarch))
{
struct value *regval = value_of_user_reg (regnum, frame);
const char *regname = user_reg_map_regnum_to_name (gdbarch,
int regnum;
for (regnum = 0;
- regnum < gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch);
+ regnum < gdbarch_num_cooked_regs (gdbarch);
regnum++)
{
if (gdbarch_register_reggroup_p (gdbarch, regnum, group))
int regnum;
int printed_something = 0;
- for (regnum = 0;
- regnum < gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch);
- regnum++)
+ for (regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++)
{
if (gdbarch_register_reggroup_p (gdbarch, regnum, vector_reggroup))
{
int regnum;
int printed_something = 0;
- for (regnum = 0;
- regnum < gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch);
- regnum++)
+ for (regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++)
{
if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup))
{
/* Adjust all the saved registers so that they contain addresses and not
offsets. */
- for (i = 0;
- i < gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch) - 1;
- i++)
+ for (i = 0; i < gdbarch_num_cooked_regs (gdbarch); i++)
if (trad_frame_addr_p (info->saved_regs, i))
{
info->saved_regs[i].addr += this_base;
{
int regno = gdbarch_ecoff_reg_to_regnum (gdbarch, SYMBOL_VALUE (sym));
- if (regno < 0
- || regno >= (gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch)))
+ if (regno < 0 || regno >= gdbarch_num_cooked_regs (gdbarch))
{
- reg_value_complaint (regno,
- gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch),
+ reg_value_complaint (regno, gdbarch_num_cooked_regs (gdbarch),
SYMBOL_PRINT_NAME (sym));
regno = gdbarch_sp_regnum (gdbarch); /* Known safe, though useless. */
debugged. */
gdbarch = get_current_arch ();
- numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
+ numregs = gdbarch_num_cooked_regs (gdbarch);
ui_out_emit_list list_emitter (uiout, "register-names");
debugged. */
gdbarch = this_regs->arch ();
- numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
+ numregs = gdbarch_num_cooked_regs (gdbarch);
ui_out_emit_list list_emitter (uiout, "changed-registers");
frame = get_selected_frame (NULL);
gdbarch = get_frame_arch (frame);
- numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
+ numregs = gdbarch_num_cooked_regs (gdbarch);
ui_out_emit_list list_emitter (uiout, "register-values");
regcache = get_current_regcache ();
gdbarch = regcache->arch ();
- numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
+ numregs = gdbarch_num_cooked_regs (gdbarch);
if (argc == 0)
error (_("-data-write-register-values: Usage: -data-write-register-"
frame = get_selected_frame (NULL);
gdbarch = get_frame_arch (frame);
- numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
+ numregs = gdbarch_num_cooked_regs (gdbarch);
for (regnum = 0; regnum < numregs; regnum++)
{
/* For GP registers, we print a separate row of names above the vals. */
for (col = 0, regnum = start_regnum;
- col < ncols && regnum < gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch);
+ col < ncols && regnum < gdbarch_num_cooked_regs (gdbarch);
regnum++)
{
if (*gdbarch_register_name (gdbarch, regnum) == '\0')
/* Now print the values in hex, 4 or 8 to the row. */
for (col = 0, regnum = start_regnum;
- col < ncols && regnum < gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch);
+ col < ncols && regnum < gdbarch_num_cooked_regs (gdbarch);
regnum++)
{
if (*gdbarch_register_name (gdbarch, regnum) == '\0')
/* Do all (or most) registers. */
{
regnum = gdbarch_num_regs (gdbarch);
- while (regnum < gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch))
+ while (regnum < gdbarch_num_cooked_regs (gdbarch))
{
if (mips_float_register_p (gdbarch, regnum))
{
/* Add NDS32 register aliases. To avoid search in user register name space,
user_reg_map_name_to_regnum is not used. */
- maxregs = (gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch));
+ maxregs = gdbarch_num_cooked_regs (gdbarch);
for (i = 0; i < ARRAY_SIZE (nds32_register_aliases); i++)
{
int regnum, j;
/* Total size of the register space. The raw registers are mapped
directly onto the raw register cache while the pseudo's are
either mapped onto raw-registers or memory. */
- descr->nr_cooked_registers = gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch);
+ descr->nr_cooked_registers = gdbarch_num_cooked_regs (gdbarch);
/* Fill in a table of register types. */
descr->register_type
struct regcache_descr *descr = regcache_descr (gdbarch);
int size;
- gdb_assert (regnum >= 0
- && regnum < (gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch)));
+ gdb_assert (regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch));
size = descr->sizeof_register[regnum];
return size;
}
long register_offset = 0;
gdb_assert (descr->nr_cooked_registers
- == (gdbarch_num_regs (m_gdbarch)
- + gdbarch_num_pseudo_regs (m_gdbarch)));
+ == gdbarch_num_cooked_regs (m_gdbarch));
for (regnum = -1; regnum < descr->nr_cooked_registers; regnum++)
{
mock_target.reset ();
/* Then, read all raw and pseudo registers, and don't expect calling
to_{fetch,store}_registers. */
- for (int regnum = 0;
- regnum < gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
- regnum++)
+ for (int regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++)
{
if (register_size (gdbarch, regnum) == 0)
continue;
readonly regcache. */
mock_target.reset ();
- for (int regnum = 0;
- regnum < gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
- regnum++)
+ for (int regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++)
{
if (register_size (gdbarch, regnum) == 0)
continue;
readwrite_regcache readwrite (gdbarch);
- const int num_regs = (gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch));
+ const int num_regs = gdbarch_num_cooked_regs (gdbarch);
for (auto regnum = 0; regnum < num_regs; regnum++)
{
if (tdep->sim_regno == NULL)
init_sim_regno_table (gdbarch);
- gdb_assert (0 <= reg
- && reg <= gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch));
+ gdb_assert (0 <= reg && reg <= gdbarch_num_cooked_regs (gdbarch));
sim_regno = tdep->sim_regno[reg];
if (sim_regno >= 0)
cur_reg += 32;
}
- gdb_assert (gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch) == cur_reg);
+ gdb_assert (gdbarch_num_cooked_regs (gdbarch) == cur_reg);
/* Register the ravenscar_arch_ops. */
if (mach == bfd_mach_ppc_e500)
{
int regno = gdbarch_stab_reg_to_regnum (gdbarch, SYMBOL_VALUE (sym));
- if (regno < 0
- || regno >= (gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch)))
+ if (regno < 0 || regno >= gdbarch_num_cooked_regs (gdbarch))
{
- reg_value_complaint (regno,
- gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch),
+ reg_value_complaint (regno, gdbarch_num_cooked_regs (gdbarch),
SYMBOL_PRINT_NAME (sym));
regno = gdbarch_sp_regnum (gdbarch); /* Known safe, though useless. */
}
count = 0;
- numregs = gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch);
+ numregs = gdbarch_num_cooked_regs (gdbarch);
for (i = 0; i < numregs; i++)
if (i != sp_regnum
&& gdbarch_register_reggroup_p (gdbarch, i, all_reggroup))
{
struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno);
int num_regs = gdbarch_num_regs (gdbarch);
- int num_pseudo_regs = gdbarch_num_pseudo_regs (gdbarch);
if (reg != NULL)
return reg->name.c_str ();
- if (regno >= num_regs && regno < num_regs + num_pseudo_regs)
+ if (regno >= num_regs && regno < gdbarch_num_cooked_regs (gdbarch))
{
struct tdesc_arch_data *data
= (struct tdesc_arch_data *) gdbarch_data (gdbarch, tdesc_data);
trad_frame_alloc_saved_regs (struct gdbarch *gdbarch)
{
int regnum;
- int numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
+ int numregs = gdbarch_num_cooked_regs (gdbarch);
struct trad_frame_saved_reg *this_saved_regs
= FRAME_OBSTACK_CALLOC (numregs, struct trad_frame_saved_reg);
/* See how many registers must be displayed. */
nr_regs = 0;
- for (regnum = 0;
- regnum < gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch);
- regnum++)
+ for (regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++)
{
const char *name;
/* Now set the register names and values. */
pos = 0;
- for (regnum = 0;
- regnum < gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch);
- regnum++)
+ for (regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++)
{
struct tui_gen_win_info *data_item_win;
struct tui_data_element *data;
specific register override the user registers. */
{
int i;
- int maxregs = (gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch));
+ int maxregs = gdbarch_num_cooked_regs (gdbarch);
for (i = 0; i < maxregs; i++)
{
if ((len < 0 && strcmp (reg->name, name))
|| (len == strlen (reg->name)
&& strncmp (reg->name, name, len) == 0))
- return gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch) + nr;
+ return gdbarch_num_cooked_regs (gdbarch) + nr;
}
}
const char *
user_reg_map_regnum_to_name (struct gdbarch *gdbarch, int regnum)
{
- int maxregs = (gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch));
+ int maxregs = gdbarch_num_cooked_regs (gdbarch);
if (regnum < 0)
return NULL;
value_of_user_reg (int regnum, struct frame_info *frame)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
- int maxregs = (gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch));
+ int maxregs = gdbarch_num_cooked_regs (gdbarch);
struct user_reg *reg = usernum_to_user_reg (gdbarch, regnum - maxregs);
gdb_assert (reg != NULL);
int regnum;
regs = (struct gdb_user_regs *) gdbarch_data (gdbarch, user_regs_data);
- regnum = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
+ regnum = gdbarch_num_cooked_regs (gdbarch);
fprintf_unfiltered (gdb_stdout, " %-11s %3s\n", "Name", "Nr");
for (reg = regs->first; reg != NULL; reg = reg->next, ++regnum)
{
int i;
- for (i = 0; i < gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch);
- i++)
+ for (i = 0; i < gdbarch_num_cooked_regs (gdbarch); i++)
if (strcasecmp (gdbarch_tdep (gdbarch)->regmap[i].name, name) == 0)
return i;
xtensa_register_name (struct gdbarch *gdbarch, int regnum)
{
/* Return the name stored in the register map. */
- if (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch))
+ if (regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch))
return gdbarch_tdep (gdbarch)->regmap[regnum].name;
internal_error (__FILE__, __LINE__, _("invalid register %d"), regnum);
return builtin_type (gdbarch)->builtin_data_ptr;
/* Return the stored type for all other registers. */
- else if (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch))
+ else if (regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch))
{
xtensa_register_t* reg = &tdep->regmap[regnum];
if (regnum >= 0 && regnum < 16)
return gdbarch_tdep (gdbarch)->a0_base + regnum;
- for (i = 0;
- i < gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
- i++)
+ for (i = 0; i < gdbarch_num_cooked_regs (gdbarch); i++)
if (regnum == gdbarch_tdep (gdbarch)->regmap[i].target_number)
return i;
return REG_VALID;
}
/* Pseudo registers. */
- else if (regnum >= 0
- && regnum < gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch))
+ else if (regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch))
{
xtensa_register_t *reg = &gdbarch_tdep (gdbarch)->regmap[regnum];
xtensa_register_type_t type = reg->type;
return;
}
/* Pseudo registers. */
- else if (regnum >= 0
- && regnum < gdbarch_num_regs (gdbarch)
- + gdbarch_num_pseudo_regs (gdbarch))
+ else if (regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch))
{
xtensa_register_t *reg = &gdbarch_tdep (gdbarch)->regmap[regnum];
xtensa_register_type_t type = reg->type;