aboutsummaryrefslogtreecommitdiff
path: root/gdb/rx-tdep.c
diff options
context:
space:
mode:
authorYoshinori Sato <ysato@users.sourceforge.jp>2019-08-21 00:24:37 +0900
committerYoshinori Sato <ysato@users.sourceforge.jp>2019-08-25 17:00:08 +0900
commite3ec872f8012377e50f0c9c888d2bc3163a356b2 (patch)
tree94033235c8b64c9ccea348d759a3a615312716c5 /gdb/rx-tdep.c
parent25602020bc462ddf4f0cc831e53bff20dbcfbb5f (diff)
downloadgdb-e3ec872f8012377e50f0c9c888d2bc3163a356b2.zip
gdb-e3ec872f8012377e50f0c9c888d2bc3163a356b2.tar.gz
gdb-e3ec872f8012377e50f0c9c888d2bc3163a356b2.tar.bz2
Convert the RX target to make use of target descriptions.
gdb/ChangeLog 2019-08-25 Yoshinori Sato <ysato@users.sourceforge.jp> * gdb/rx-tdep.c (rx_register_names): New. (rx_register_name): Delete. (rx_psw_type): Delete. (rx_fpsw_type): Delete. (rx_register_type): Delete. (rx_gdbarch_init): Convert target-descriptions. (_initialize_rx_tdep): Add initialize_tdesc_rx. * gdb/features/Makefile: Add rx.xml. * gdb/features/rx.xml: New. * gdb/features/rx.c: Generated. * gdb/NEWS: Mention target description support. gdb/doc/ChangeLog: 2019-08-25 Yoshinori Sato <ysato@users.sourceforge.jp> * gdb.texinfo (Standard Target Features): Add RX Features sub-section.
Diffstat (limited to 'gdb/rx-tdep.c')
-rw-r--r--gdb/rx-tdep.c160
1 files changed, 45 insertions, 115 deletions
diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c
index 4cbf919..45cc8b4 100644
--- a/gdb/rx-tdep.c
+++ b/gdb/rx-tdep.c
@@ -33,11 +33,15 @@
#include "value.h"
#include "gdbcore.h"
#include "dwarf2-frame.h"
+#include "remote.h"
+#include "target-descriptions.h"
#include "elf/rx.h"
#include "elf-bfd.h"
#include <algorithm>
+#include "features/rx.c"
+
/* Certain important register numbers. */
enum
{
@@ -114,117 +118,13 @@ struct rx_prologue
int reg_offset[RX_NUM_REGS];
};
-/* Implement the "register_name" gdbarch method. */
-static const char *
-rx_register_name (struct gdbarch *gdbarch, int regnr)
-{
- static const char *const reg_names[] = {
- "r0",
- "r1",
- "r2",
- "r3",
- "r4",
- "r5",
- "r6",
- "r7",
- "r8",
- "r9",
- "r10",
- "r11",
- "r12",
- "r13",
- "r14",
- "r15",
- "usp",
- "isp",
- "psw",
- "pc",
- "intb",
- "bpsw",
- "bpc",
- "fintv",
- "fpsw",
- "acc"
- };
-
- return reg_names[regnr];
-}
-
-/* Construct the flags type for PSW and BPSW. */
-
-static struct type *
-rx_psw_type (struct gdbarch *gdbarch)
-{
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-
- if (tdep->rx_psw_type == NULL)
- {
- tdep->rx_psw_type = arch_flags_type (gdbarch, "rx_psw_type", 32);
- append_flags_type_flag (tdep->rx_psw_type, 0, "C");
- append_flags_type_flag (tdep->rx_psw_type, 1, "Z");
- append_flags_type_flag (tdep->rx_psw_type, 2, "S");
- append_flags_type_flag (tdep->rx_psw_type, 3, "O");
- append_flags_type_flag (tdep->rx_psw_type, 16, "I");
- append_flags_type_flag (tdep->rx_psw_type, 17, "U");
- append_flags_type_flag (tdep->rx_psw_type, 20, "PM");
- append_flags_type_flag (tdep->rx_psw_type, 24, "IPL0");
- append_flags_type_flag (tdep->rx_psw_type, 25, "IPL1");
- append_flags_type_flag (tdep->rx_psw_type, 26, "IPL2");
- append_flags_type_flag (tdep->rx_psw_type, 27, "IPL3");
- }
- return tdep->rx_psw_type;
-}
-
-/* Construct flags type for FPSW. */
-
-static struct type *
-rx_fpsw_type (struct gdbarch *gdbarch)
-{
- struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-
- if (tdep->rx_fpsw_type == NULL)
- {
- tdep->rx_fpsw_type = arch_flags_type (gdbarch, "rx_fpsw_type", 32);
- append_flags_type_flag (tdep->rx_fpsw_type, 0, "RM0");
- append_flags_type_flag (tdep->rx_fpsw_type, 1, "RM1");
- append_flags_type_flag (tdep->rx_fpsw_type, 2, "CV");
- append_flags_type_flag (tdep->rx_fpsw_type, 3, "CO");
- append_flags_type_flag (tdep->rx_fpsw_type, 4, "CZ");
- append_flags_type_flag (tdep->rx_fpsw_type, 5, "CU");
- append_flags_type_flag (tdep->rx_fpsw_type, 6, "CX");
- append_flags_type_flag (tdep->rx_fpsw_type, 7, "CE");
- append_flags_type_flag (tdep->rx_fpsw_type, 8, "DN");
- append_flags_type_flag (tdep->rx_fpsw_type, 10, "EV");
- append_flags_type_flag (tdep->rx_fpsw_type, 11, "EO");
- append_flags_type_flag (tdep->rx_fpsw_type, 12, "EZ");
- append_flags_type_flag (tdep->rx_fpsw_type, 13, "EU");
- append_flags_type_flag (tdep->rx_fpsw_type, 14, "EX");
- append_flags_type_flag (tdep->rx_fpsw_type, 26, "FV");
- append_flags_type_flag (tdep->rx_fpsw_type, 27, "FO");
- append_flags_type_flag (tdep->rx_fpsw_type, 28, "FZ");
- append_flags_type_flag (tdep->rx_fpsw_type, 29, "FU");
- append_flags_type_flag (tdep->rx_fpsw_type, 30, "FX");
- append_flags_type_flag (tdep->rx_fpsw_type, 31, "FS");
- }
-
- return tdep->rx_fpsw_type;
-}
-
-/* Implement the "register_type" gdbarch method. */
-static struct type *
-rx_register_type (struct gdbarch *gdbarch, int reg_nr)
-{
- if (reg_nr == RX_PC_REGNUM)
- return builtin_type (gdbarch)->builtin_func_ptr;
- else if (reg_nr == RX_PSW_REGNUM || reg_nr == RX_BPSW_REGNUM)
- return rx_psw_type (gdbarch);
- else if (reg_nr == RX_FPSW_REGNUM)
- return rx_fpsw_type (gdbarch);
- else if (reg_nr == RX_ACC_REGNUM)
- return builtin_type (gdbarch)->builtin_unsigned_long_long;
- else
- return builtin_type (gdbarch)->builtin_unsigned_long;
-}
+/* RX register names */
+static const char *const rx_register_names[] = {
+ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
+ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
+ "usp", "isp", "psw", "pc", "intb", "bpsw","bpc","fintv",
+ "fpsw", "acc",
+};
/* Function for finding saved registers in a 'struct pv_area'; this
@@ -1044,6 +944,8 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
struct gdbarch *gdbarch;
struct gdbarch_tdep *tdep;
int elf_flags;
+ struct tdesc_arch_data *tdesc_data = NULL;
+ const struct target_desc *tdesc = info.target_desc;
/* Extract the elf_flags if available. */
if (info.abfd != NULL
@@ -1065,16 +967,42 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
return arches->gdbarch;
}
- /* None found, create a new architecture from the information
- provided. */
+ if (tdesc == NULL)
+ tdesc = tdesc_rx;
+
+ /* Check any target description for validity. */
+ if (tdesc_has_registers (tdesc))
+ {
+ const struct tdesc_feature *feature;
+ bool valid_p = true;
+
+ feature = tdesc_find_feature (tdesc, "org.gnu.gdb.rx.core");
+
+ if (feature != NULL)
+ {
+ tdesc_data = tdesc_data_alloc ();
+ for (int i = 0; i < RX_NUM_REGS; i++)
+ valid_p &= tdesc_numbered_register (feature, tdesc_data, i,
+ rx_register_names[i]);
+ }
+
+ if (!valid_p)
+ {
+ tdesc_data_cleanup (tdesc_data);
+ return NULL;
+ }
+ }
+
+ gdb_assert(tdesc_data != NULL);
+
tdep = XCNEW (struct gdbarch_tdep);
gdbarch = gdbarch_alloc (&info, tdep);
tdep->elf_flags = elf_flags;
set_gdbarch_num_regs (gdbarch, RX_NUM_REGS);
+ tdesc_use_registers (gdbarch, tdesc, tdesc_data);
+
set_gdbarch_num_pseudo_regs (gdbarch, 0);
- set_gdbarch_register_name (gdbarch, rx_register_name);
- set_gdbarch_register_type (gdbarch, rx_register_type);
set_gdbarch_pc_regnum (gdbarch, RX_PC_REGNUM);
set_gdbarch_sp_regnum (gdbarch, RX_SP_REGNUM);
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
@@ -1092,6 +1020,7 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_ptr_bit (gdbarch, 32);
set_gdbarch_float_bit (gdbarch, 32);
set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
+
if (elf_flags & E_FLAG_RX_64BIT_DOUBLES)
{
set_gdbarch_double_bit (gdbarch, 64);
@@ -1132,4 +1061,5 @@ void
_initialize_rx_tdep (void)
{
register_gdbarch_init (bfd_arch_rx, rx_gdbarch_init);
+ initialize_tdesc_rx ();
}