This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] gdb/h8300-tdep.c: Fix register name in h8300h machine.
- From: Yoshinori Sato <ysato at users dot sourceforge dot jp>
- To: gdb-patches at sourceware dot org
- Date: Mon, 22 Jul 2019 19:27:08 +0900
- Subject: [PATCH] gdb/h8300-tdep.c: Fix register name in h8300h machine.
H8/300H general register name "ER0" - "ER7".
But gdb using "R0" - "R7".
This changes register name "ER0" - "ER7" in h8300h machine mode.
---
gdb/ChangeLog | 9 +++++++++
gdb/h8300-tdep.c | 54 ++++++++++++++++++++++++++++++++----------------------
2 files changed, 41 insertions(+), 22 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 63f6fa90d1..1ac285ff50 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2019-07-22 Yoshinori Sato <ysato@users.sourceforge.jp>
+
+ * h8300-tdep.c (h8300_register_name_common): New.
+ (h8300_register_name): Use h8300_register_name_common.
+ (h8300s_register_name): Likewise.
+ (h8300sx_register_name): Likewise.
+ (h8300h_register_nam): New.
+ (h8300_gdbarch_init): Use h8300h_register_name in h8300h machine.
+
2019-07-21 Christian Biesinger <cbiesinger@google.com>
* symtab.c (lookup_symbol_in_objfile_symtabs): Change int to block_enum.
diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
index b41a0b6c26..2a3d374085 100644
--- a/gdb/h8300-tdep.c
+++ b/gdb/h8300-tdep.c
@@ -929,6 +929,19 @@ h8300_register_sim_regno (struct gdbarch *gdbarch, int regnum)
}
static const char *
+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];
+}
+
+static const char *
h8300_register_name (struct gdbarch *gdbarch, int regno)
{
/* The register names change depending on which h8300 processor
@@ -938,13 +951,20 @@ h8300_register_name (struct gdbarch *gdbarch, int regno)
"sp", "", "pc", "cycles", "tick", "inst",
"ccr", /* pseudo register */
};
- if (regno < 0
- || regno >= (sizeof (register_names) / sizeof (*register_names)))
- internal_error (__FILE__, __LINE__,
- _("h8300_register_name: illegal register number %d"),
- regno);
- else
- return register_names[regno];
+ return h8300_register_name_common(register_names, ARRAY_SIZE(register_names),
+ gdbarch, regno);
+}
+
+static const char *
+h8300h_register_name (struct gdbarch *gdbarch, int regno)
+{
+ static const char *register_names[] = {
+ "er0", "er1", "er2", "er3", "er4", "er5", "er6",
+ "sp", "", "pc", "cycles", "tick", "inst",
+ "ccr", /* pseudo register */
+ };
+ return h8300_register_name_common(register_names, ARRAY_SIZE(register_names),
+ gdbarch, regno);
}
static const char *
@@ -956,13 +976,8 @@ h8300s_register_name (struct gdbarch *gdbarch, int regno)
"mach", "macl",
"ccr", "exr" /* pseudo registers */
};
- if (regno < 0
- || regno >= (sizeof (register_names) / sizeof (*register_names)))
- internal_error (__FILE__, __LINE__,
- _("h8300s_register_name: illegal register number %d"),
- regno);
- else
- return register_names[regno];
+ return h8300_register_name_common(register_names, ARRAY_SIZE(register_names),
+ gdbarch, regno);
}
static const char *
@@ -974,13 +989,8 @@ h8300sx_register_name (struct gdbarch *gdbarch, int regno)
"mach", "macl", "sbr", "vbr",
"ccr", "exr" /* pseudo registers */
};
- if (regno < 0
- || regno >= (sizeof (register_names) / sizeof (*register_names)))
- internal_error (__FILE__, __LINE__,
- _("h8300sx_register_name: illegal register number %d"),
- regno);
- else
- return register_names[regno];
+ return h8300_register_name_common(register_names, ARRAY_SIZE(register_names),
+ gdbarch, regno);
}
static void
@@ -1259,7 +1269,7 @@ h8300_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_num_pseudo_regs (gdbarch, 1);
set_gdbarch_dwarf2_reg_to_regnum (gdbarch, h8300_dbg_reg_to_regnum);
set_gdbarch_stab_reg_to_regnum (gdbarch, h8300_dbg_reg_to_regnum);
- set_gdbarch_register_name (gdbarch, h8300_register_name);
+ set_gdbarch_register_name (gdbarch, h8300h_register_name);
if (info.bfd_arch_info->mach != bfd_mach_h8300hn)
{
set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
--
2.11.0