Introduce gdbarch_num_cooked_regs
The expression gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch) is used quite often to find the number of cooked registers (raw + pseudo registers). This patch introduces gdbarch_num_cooked_regs, which does the equivalent. It substantially reduces required wrapping in some places, so should improve readability. There is a for loop in m68hc11_frame_unwind_cache that had iterated until (the equivalent of) gdbarch_num_cooked_regs (gdbarch) - 1. During review, we concluded that this is most likely an off-by-one mistake, so I replaced it with gdbarch_num_cooked_regs (gdbarch). gdb/ChangeLog: * 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.
This commit is contained in:
parent
925047fed0
commit
f6efe3f842
@ -1,3 +1,55 @@
|
||||
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
|
||||
|
@ -2036,8 +2036,7 @@ gen_expr (struct expression *exp, union exp_element **pc,
|
||||
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);
|
||||
|
@ -972,8 +972,7 @@ static struct dwarf2_frame_cache *
|
||||
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;
|
||||
|
@ -1395,8 +1395,7 @@ evaluate_subexp_standard (struct type *expect_type,
|
||||
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));
|
||||
|
@ -267,8 +267,7 @@ value_of_register (int regnum, struct frame_info *frame)
|
||||
|
||||
/* 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);
|
||||
@ -287,8 +286,7 @@ value_of_register_lazy (struct frame_info *frame, int 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);
|
||||
|
||||
@ -957,8 +955,7 @@ address_from_register (int regnum, struct frame_info *frame)
|
||||
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,
|
||||
|
@ -1416,7 +1416,7 @@ get_frame_register_bytes (struct frame_info *frame, int 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);
|
||||
|
@ -116,8 +116,7 @@ register_to_value_test (struct gdbarch *gdbarch)
|
||||
= 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. */
|
||||
|
@ -1806,4 +1806,12 @@ extern unsigned int gdbarch_debug;
|
||||
|
||||
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
|
||||
|
@ -1632,6 +1632,14 @@ extern unsigned int gdbarch_debug;
|
||||
|
||||
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
|
||||
|
@ -1128,8 +1128,7 @@ h8300_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
|
||||
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);
|
||||
|
@ -518,7 +518,7 @@ i386_dbx_reg_to_regnum (struct gdbarch *gdbarch, int reg)
|
||||
}
|
||||
|
||||
/* 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
|
||||
@ -575,7 +575,7 @@ i386_svr4_reg_to_regnum (struct gdbarch *gdbarch, int reg)
|
||||
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;
|
||||
}
|
||||
|
||||
|
19
gdb/infcmd.c
19
gdb/infcmd.c
@ -2387,8 +2387,7 @@ default_print_registers_info (struct gdbarch *gdbarch,
|
||||
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++)
|
||||
{
|
||||
@ -2475,8 +2474,7 @@ registers_info (const char *addr_exp, int fpregs)
|
||||
/* 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,
|
||||
@ -2515,8 +2513,7 @@ registers_info (const char *addr_exp, int fpregs)
|
||||
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))
|
||||
@ -2558,10 +2555,7 @@ print_vector_info (struct ui_file *file,
|
||||
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))
|
||||
{
|
||||
@ -3110,10 +3104,7 @@ default_print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
|
||||
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))
|
||||
{
|
||||
|
@ -854,10 +854,7 @@ m68hc11_frame_unwind_cache (struct frame_info *this_frame,
|
||||
|
||||
/* 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;
|
||||
|
@ -537,13 +537,9 @@ mdebug_reg_to_regnum (struct symbol *sym, struct gdbarch *gdbarch)
|
||||
{
|
||||
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. */
|
||||
|
@ -890,7 +890,7 @@ mi_cmd_data_list_register_names (const char *command, char **argv, int argc)
|
||||
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");
|
||||
|
||||
@ -949,7 +949,7 @@ mi_cmd_data_list_changed_registers (const char *command, char **argv, int argc)
|
||||
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");
|
||||
|
||||
@ -1076,7 +1076,7 @@ mi_cmd_data_list_register_values (const char *command, char **argv, int argc)
|
||||
|
||||
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");
|
||||
|
||||
@ -1164,7 +1164,7 @@ mi_cmd_data_write_register_values (const char *command, char **argv, int argc)
|
||||
|
||||
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-"
|
||||
@ -2638,7 +2638,7 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc)
|
||||
|
||||
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++)
|
||||
{
|
||||
|
@ -6497,8 +6497,7 @@ print_gp_register_row (struct ui_file *file, struct frame_info *frame,
|
||||
|
||||
/* 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')
|
||||
@ -6536,8 +6535,7 @@ print_gp_register_row (struct ui_file *file, struct frame_info *frame,
|
||||
|
||||
/* 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')
|
||||
@ -6603,8 +6601,7 @@ mips_print_registers_info (struct gdbarch *gdbarch, struct ui_file *file,
|
||||
/* 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))
|
||||
{
|
||||
|
@ -2099,7 +2099,7 @@ nds32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
|
||||
|
||||
/* 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;
|
||||
|
@ -86,8 +86,7 @@ init_regcache_descr (struct gdbarch *gdbarch)
|
||||
/* 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
|
||||
@ -163,9 +162,7 @@ register_size (struct gdbarch *gdbarch, int regnum)
|
||||
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;
|
||||
}
|
||||
@ -1311,8 +1308,7 @@ register_dump::dump (ui_file *file)
|
||||
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++)
|
||||
{
|
||||
@ -1637,9 +1633,7 @@ cooked_read_test (struct gdbarch *gdbarch)
|
||||
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;
|
||||
@ -1665,9 +1659,7 @@ cooked_read_test (struct gdbarch *gdbarch)
|
||||
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;
|
||||
@ -1762,8 +1754,7 @@ cooked_write_test (struct gdbarch *gdbarch)
|
||||
|
||||
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++)
|
||||
{
|
||||
|
@ -357,9 +357,7 @@ rs6000_register_sim_regno (struct gdbarch *gdbarch, int reg)
|
||||
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)
|
||||
@ -6475,8 +6473,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
|
||||
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)
|
||||
|
@ -616,13 +616,9 @@ stab_reg_to_regnum (struct symbol *sym, struct gdbarch *gdbarch)
|
||||
{
|
||||
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. */
|
||||
|
@ -1553,8 +1553,7 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
|
||||
}
|
||||
|
||||
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))
|
||||
|
@ -854,12 +854,11 @@ tdesc_register_name (struct gdbarch *gdbarch, int regno)
|
||||
{
|
||||
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);
|
||||
|
@ -48,7 +48,7 @@ struct trad_frame_saved_reg *
|
||||
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);
|
||||
|
||||
|
@ -206,10 +206,7 @@ tui_show_register_group (struct reggroup *group,
|
||||
|
||||
/* 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;
|
||||
|
||||
@ -253,10 +250,7 @@ tui_show_register_group (struct reggroup *group,
|
||||
|
||||
/* 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;
|
||||
|
@ -138,8 +138,7 @@ user_reg_map_name_to_regnum (struct gdbarch *gdbarch, const char *name,
|
||||
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++)
|
||||
{
|
||||
@ -165,8 +164,7 @@ user_reg_map_name_to_regnum (struct gdbarch *gdbarch, const char *name,
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,8 +190,7 @@ usernum_to_user_reg (struct gdbarch *gdbarch, int usernum)
|
||||
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;
|
||||
@ -213,8 +210,7 @@ struct value *
|
||||
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);
|
||||
@ -230,7 +226,7 @@ maintenance_print_user_registers (const char *args, int from_tty)
|
||||
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)
|
||||
|
@ -234,9 +234,7 @@ xtensa_find_register_by_name (struct gdbarch *gdbarch, const char *name)
|
||||
{
|
||||
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;
|
||||
@ -249,8 +247,7 @@ static const char *
|
||||
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);
|
||||
@ -276,8 +273,7 @@ xtensa_register_type (struct gdbarch *gdbarch, int 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];
|
||||
|
||||
@ -352,9 +348,7 @@ xtensa_reg_to_regnum (struct gdbarch *gdbarch, int 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;
|
||||
|
||||
@ -585,9 +579,7 @@ xtensa_pseudo_register_read (struct gdbarch *gdbarch,
|
||||
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;
|
||||
@ -670,9 +662,7 @@ xtensa_pseudo_register_write (struct gdbarch *gdbarch,
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user