From patchwork Wed Aug 21 03:33:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshinori Sato X-Patchwork-Id: 34219 Received: (qmail 130015 invoked by alias); 21 Aug 2019 03:33:17 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 130006 invoked by uid 89); 21 Aug 2019 03:33:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_SOFTFAIL autolearn=ham version=3.3.1 spammy=DOCTYPE, doctype, !DOCTYPE, isp X-HELO: mail01.asahi-net.or.jp Received: from mail01.asahi-net.or.jp (HELO mail01.asahi-net.or.jp) (202.224.55.13) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 Aug 2019 03:33:14 +0000 Received: from h61-195-96-97.vps.ablenet.jp (h61-195-96-97.ablenetvps.ne.jp [61.195.96.97]) (Authenticated sender: PQ4Y-STU) by mail01.asahi-net.or.jp (Postfix) with ESMTPA id 61714135F17; Wed, 21 Aug 2019 12:33:08 +0900 (JST) Received: from yo-satoh-debian.localdomain (ae227063.dynamic.ppp.asahi-net.or.jp [14.3.227.63]) by h61-195-96-97.vps.ablenet.jp (Postfix) with ESMTPSA id CB8FB240085; Wed, 21 Aug 2019 12:33:07 +0900 (JST) From: Yoshinori Sato To: gdb-patches@sourceware.org Cc: Yoshinori Sato Subject: [PATCH] RX: Convert target-description Date: Wed, 21 Aug 2019 12:33:01 +0900 Message-Id: <20190821033301.45309-1-ysato@users.sourceforge.jp> X-IsSubscribed: yes gdb/ChangeLog 2019-08-21 Yoshinori Sato * gdb/rx-tdep.c (rx_register_names): New. (rx_register_name): Use rx_register_names. (rx_register_name): Add check range. (rx_register_g_packet_guesses): New. (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/Makefile | 2 ++ gdb/features/rx.xml | 70 ++++++++++++++++++++++++++++++++++++ gdb/rx-tdep.c | 99 ++++++++++++++++++++++++++++++--------------------- 3 files changed, 130 insertions(+), 41 deletions(-) create mode 100644 gdb/features/rx.xml diff --git a/gdb/features/Makefile b/gdb/features/Makefile index 0c84faf405..2b65d46df0 100644 --- a/gdb/features/Makefile +++ b/gdb/features/Makefile @@ -161,6 +161,7 @@ XMLTOC = \ rs6000/powerpc-vsx64.xml \ rs6000/powerpc-vsx64l.xml \ rs6000/rs6000.xml \ + rx.xml \ s390-linux32.xml \ s390-linux32v1.xml \ s390-linux32v2.xml \ @@ -238,6 +239,7 @@ FEATURE_XMLFILES = aarch64-core.xml \ riscv/64bit-cpu.xml \ riscv/64bit-csr.xml \ riscv/64bit-fpu.xml \ + rx.xml \ tic6x-c6xp.xml \ tic6x-core.xml \ tic6x-gp.xml diff --git a/gdb/features/rx.xml b/gdb/features/rx.xml new file mode 100644 index 0000000000..b5aa9ac4a8 --- /dev/null +++ b/gdb/features/rx.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c index 4cbf919db9..b3398f122a 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 +#include "features/rx.c" + /* Certain important register numbers. */ enum { @@ -114,40 +118,21 @@ struct rx_prologue int reg_offset[RX_NUM_REGS]; }; +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", +}; + /* 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]; + if (regnr >= 0 && regnr < RX_NUM_REGS) + return rx_register_names[regnr]; + else + return NULL; } /* Construct the flags type for PSW and BPSW. */ @@ -1037,6 +1022,14 @@ rx_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg) return -1; } +static void +rx_register_g_packet_guesses (struct gdbarch *gdbarch) +{ + register_remote_g_packet_guess (gdbarch, + 4 * RX_NUM_REGS, + tdesc_rx); +} + /* Allocate and initialize a gdbarch object. */ static struct gdbarch * rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) @@ -1044,6 +1037,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,8 +1060,33 @@ 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; + int valid_p = 0; + int i = 0; + feature = tdesc_find_feature (tdesc, "org.gnu.gdb.rx.core"); + + if (feature != NULL) + { + tdesc_data = tdesc_data_alloc (); + valid_p = 1; + for (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; + } + } + tdep = XCNEW (struct gdbarch_tdep); gdbarch = gdbarch_alloc (&info, tdep); tdep->elf_flags = elf_flags; @@ -1083,15 +1103,6 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_sw_breakpoint_from_kind (gdbarch, rx_breakpoint::bp_from_kind); set_gdbarch_skip_prologue (gdbarch, rx_skip_prologue); - /* Target builtin data types. */ - set_gdbarch_char_signed (gdbarch, 0); - set_gdbarch_short_bit (gdbarch, 16); - set_gdbarch_int_bit (gdbarch, 32); - set_gdbarch_long_bit (gdbarch, 32); - set_gdbarch_long_long_bit (gdbarch, 64); - 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); @@ -1115,6 +1126,8 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) dwarf2_append_unwinders (gdbarch); frame_unwind_append_unwinder (gdbarch, &rx_frame_unwind); + rx_register_g_packet_guesses (gdbarch); + /* Methods setting up a dummy call, and extracting the return value from a call. */ set_gdbarch_push_dummy_call (gdbarch, rx_push_dummy_call); @@ -1123,6 +1136,9 @@ rx_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Virtual tables. */ set_gdbarch_vbit_in_delta (gdbarch, 1); + if (tdesc_data != NULL) + tdesc_use_registers (gdbarch, tdesc, tdesc_data); + return gdbarch; } @@ -1132,4 +1148,5 @@ void _initialize_rx_tdep (void) { register_gdbarch_init (bfd_arch_rx, rx_gdbarch_init); + initialize_tdesc_rx (); }