From patchwork Wed Oct 11 14:56:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Kolesov X-Patchwork-Id: 23480 Received: (qmail 108634 invoked by alias); 11 Oct 2017 14:56:45 -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 108604 invoked by uid 89); 11 Oct 2017 14:56:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=r61, WHICH, BTA, bta X-HELO: smtprelay.synopsys.com Received: from smtprelay.synopsys.com (HELO smtprelay.synopsys.com) (198.182.47.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Oct 2017 14:56:41 +0000 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id EA8EB24E1EA6 for ; Wed, 11 Oct 2017 07:56:39 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id CB9FA128; Wed, 11 Oct 2017 07:56:39 -0700 (PDT) Received: from akolesov-lab.internal.synopsys.com (akolesov-lab.internal.synopsys.com [10.121.14.106]) by mailhost.synopsys.com (Postfix) with ESMTP id 56A91FB; Wed, 11 Oct 2017 07:56:37 -0700 (PDT) From: Anton Kolesov To: gdb-patches@sourceware.org Cc: Anton Kolesov , Francois Bedard Subject: [PATCH 1/3] arc: Add XML target descriptions for Linux targets Date: Wed, 11 Oct 2017 17:56:31 +0300 Message-Id: <20171011145633.19343-1-Anton.Kolesov@synopsys.com> Add XML target descriptions for Linux targets. Compared to default Linux descriptions: - Explicitly specify CPU machine. - Remove baremetal only ILINK{,1,2} registers. - Add LP_START and LP_END registers for hardware loops - required to properly evaluate possible next instruction during software single instruction stepping. - Add BTA register which contains branch target address - address of next instruction when processor is in the delay slot. - ARC HS description also adds R30, R58 and R59 registers, specific to this architecture. gdb/ChangeLog: yyyy-mm-dd Anton Kolesov * arc-tdep (arc_tdesc_init): Use tdesc_arc_arcompact_linux and tdesc_arc_v2_linux. (_initialize_arc_tdep): Invoke initialize_tdesc_arc_v2_linux and initialize_tdesc_arc_arcompact_linux. * features/Makefile: Add targets to generate new files. * features/arc-arcompact-linux.xml: New file. * features/arc-v2-linux.xml: Likewise. * features/arc-arcompact-linux.c: Generate. * features/arc-v2-linux.c: Likewise. * regformats/arc-arcompact-linux.dat: Likewise. * regformats/arc-v2-linux.dat: Likewise. --- gdb/arc-tdep.c | 17 ++++++- gdb/features/Makefile | 5 ++ gdb/features/arc-arcompact-linux.c | 76 ++++++++++++++++++++++++++++ gdb/features/arc-arcompact-linux.xml | 84 +++++++++++++++++++++++++++++++ gdb/features/arc-v2-linux.c | 83 +++++++++++++++++++++++++++++++ gdb/features/arc-v2-linux.xml | 91 ++++++++++++++++++++++++++++++++++ gdb/regformats/arc-arcompact-linux.dat | 42 ++++++++++++++++ gdb/regformats/arc-v2-linux.dat | 45 +++++++++++++++++ 8 files changed, 441 insertions(+), 2 deletions(-) create mode 100644 gdb/features/arc-arcompact-linux.c create mode 100644 gdb/features/arc-arcompact-linux.xml create mode 100644 gdb/features/arc-v2-linux.c create mode 100644 gdb/features/arc-v2-linux.xml create mode 100644 gdb/regformats/arc-arcompact-linux.dat create mode 100644 gdb/regformats/arc-v2-linux.dat diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c index 771d6df..a825917 100644 --- a/gdb/arc-tdep.c +++ b/gdb/arc-tdep.c @@ -42,6 +42,8 @@ /* Default target descriptions. */ #include "features/arc-v2.c" #include "features/arc-arcompact.c" +#include "features/arc-v2-linux.c" +#include "features/arc-arcompact-linux.c" /* The frame unwind cache for ARC. */ @@ -1799,13 +1801,22 @@ arc_tdesc_init (struct gdbarch_info info, const struct target_desc **tdesc, { if (is_arcv2) { - tdesc_loc = tdesc_arc_v2; + /* Usually Linux-specific target description would be provided by + the gdbserver, but it has to be selected manually when debugging + core files. */ + if (info.osabi == GDB_OSABI_LINUX) + tdesc_loc = tdesc_arc_v2_linux; + else + tdesc_loc = tdesc_arc_v2; if (arc_debug) debug_printf ("arc: Using default register set for ARC v2.\n"); } else { - tdesc_loc = tdesc_arc_arcompact; + if (info.osabi == GDB_OSABI_LINUX) + tdesc_loc = tdesc_arc_arcompact_linux; + else + tdesc_loc = tdesc_arc_arcompact; if (arc_debug) debug_printf ("arc: Using default register set for ARCompact.\n"); } @@ -2172,6 +2183,8 @@ _initialize_arc_tdep (void) initialize_tdesc_arc_v2 (); initialize_tdesc_arc_arcompact (); + initialize_tdesc_arc_v2_linux (); + initialize_tdesc_arc_arcompact_linux (); /* Register ARC-specific commands with gdb. */ diff --git a/gdb/features/Makefile b/gdb/features/Makefile index 8a7f377..8d5e3d3 100644 --- a/gdb/features/Makefile +++ b/gdb/features/Makefile @@ -44,6 +44,7 @@ # make GDB=/path/to/gdb XMLTOC="xml files" cfiles WHICH = aarch64 \ + arc-v2-linux arc-arcompact-linux \ arm/arm-with-iwmmxt arm/arm-with-vfpv2 arm/arm-with-vfpv3 \ arm/arm-with-neon \ i386/i386 i386/i386-linux \ @@ -84,6 +85,8 @@ WHICH = aarch64 \ # Record which registers should be sent to GDB by default after stop. aarch64-expedite = x29,sp,pc +arc-v2-linux-expedite = sp,pc +arc-arcompact-linux-expedite = sp,pc arm-expedite = r11,sp,pc i386-expedite = ebp,esp,eip amd64-expedite = rbp,rsp,rip @@ -133,7 +136,9 @@ OUTPUTS = $(patsubst %,$(outdir)/%.dat,$(WHICH)) XMLTOC = \ aarch64.xml \ arc-v2.xml \ + arc-v2-linux.xml \ arc-arcompact.xml \ + arc-arcompact-linux.xml \ arm/arm-with-iwmmxt.xml \ arm/arm-with-m-fpa-layout.xml \ arm/arm-with-m-vfp-d16.xml \ diff --git a/gdb/features/arc-arcompact-linux.c b/gdb/features/arc-arcompact-linux.c new file mode 100644 index 0000000..de8da32 --- /dev/null +++ b/gdb/features/arc-arcompact-linux.c @@ -0,0 +1,76 @@ +/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: + Original: arc-arcompact-linux.xml */ + +#include "defs.h" +#include "osabi.h" +#include "target-descriptions.h" + +struct target_desc *tdesc_arc_arcompact_linux; +static void +initialize_tdesc_arc_arcompact_linux (void) +{ + struct target_desc *result = allocate_target_description (); + set_tdesc_architecture (result, bfd_scan_arch ("ARC700")); + + struct tdesc_feature *feature; + + feature = tdesc_create_feature (result, "org.gnu.gdb.arc.core.arcompact"); + tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r13", 13, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r14", 14, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r15", 15, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r16", 16, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r17", 17, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r18", 18, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r19", 19, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r20", 20, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r21", 21, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r22", 22, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r23", 23, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r24", 24, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r25", 25, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "gp", 26, 1, NULL, 32, "data_ptr"); + tdesc_create_reg (feature, "fp", 27, 1, NULL, 32, "data_ptr"); + tdesc_create_reg (feature, "sp", 28, 1, NULL, 32, "data_ptr"); + tdesc_create_reg (feature, "blink", 29, 1, NULL, 32, "code_ptr"); + tdesc_create_reg (feature, "lp_count", 30, 1, NULL, 32, "uint32"); + tdesc_create_reg (feature, "pcl", 31, 1, "", 32, "code_ptr"); + + feature = tdesc_create_feature (result, "org.gnu.gdb.arc.aux-minimal"); + struct tdesc_type *field_type; + struct tdesc_type *type; + type = tdesc_create_flags (feature, "status32_type", 4); + tdesc_add_flag (type, 0, "H"); + tdesc_add_bitfield (type, "E", 1, 2); + tdesc_add_bitfield (type, "A", 3, 4); + tdesc_add_flag (type, 5, "AE"); + tdesc_add_flag (type, 6, "DE"); + tdesc_add_flag (type, 7, "U"); + tdesc_add_flag (type, 8, "V"); + tdesc_add_flag (type, 9, "C"); + tdesc_add_flag (type, 10, "N"); + tdesc_add_flag (type, 11, "Z"); + tdesc_add_flag (type, 12, "L"); + tdesc_add_flag (type, 13, "R"); + tdesc_add_flag (type, 14, "SE"); + + tdesc_create_reg (feature, "pc", 32, 1, NULL, 32, "code_ptr"); + tdesc_create_reg (feature, "status32", 33, 1, NULL, 32, "status32_type"); + tdesc_create_reg (feature, "lp_start", 34, 1, NULL, 32, "code_ptr"); + tdesc_create_reg (feature, "lp_end", 35, 1, NULL, 32, "code_ptr"); + tdesc_create_reg (feature, "bta", 36, 1, NULL, 32, "code_ptr"); + + tdesc_arc_arcompact_linux = result; +} diff --git a/gdb/features/arc-arcompact-linux.xml b/gdb/features/arc-arcompact-linux.xml new file mode 100644 index 0000000..84847ed --- /dev/null +++ b/gdb/features/arc-arcompact-linux.xml @@ -0,0 +1,84 @@ + + + + + + arc:ARC700 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/features/arc-v2-linux.c b/gdb/features/arc-v2-linux.c new file mode 100644 index 0000000..8d93786 --- /dev/null +++ b/gdb/features/arc-v2-linux.c @@ -0,0 +1,83 @@ +/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: + Original: arc-v2-linux.xml */ + +#include "defs.h" +#include "osabi.h" +#include "target-descriptions.h" + +struct target_desc *tdesc_arc_v2_linux; +static void +initialize_tdesc_arc_v2_linux (void) +{ + struct target_desc *result = allocate_target_description (); + set_tdesc_architecture (result, bfd_scan_arch ("HS")); + + struct tdesc_feature *feature; + + feature = tdesc_create_feature (result, "org.gnu.gdb.arc.core.v2"); + tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r13", 13, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r14", 14, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r15", 15, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r16", 16, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r17", 17, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r18", 18, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r19", 19, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r20", 20, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r21", 21, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r22", 22, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r23", 23, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r24", 24, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r25", 25, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "gp", 26, 1, NULL, 32, "data_ptr"); + tdesc_create_reg (feature, "fp", 27, 1, NULL, 32, "data_ptr"); + tdesc_create_reg (feature, "sp", 28, 1, NULL, 32, "data_ptr"); + tdesc_create_reg (feature, "r30", 29, 1, "", 32, "int"); + tdesc_create_reg (feature, "blink", 30, 1, NULL, 32, "code_ptr"); + tdesc_create_reg (feature, "r58", 31, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r59", 32, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "lp_count", 33, 1, NULL, 32, "uint32"); + tdesc_create_reg (feature, "pcl", 34, 1, "", 32, "code_ptr"); + + feature = tdesc_create_feature (result, "org.gnu.gdb.arc.aux-minimal"); + struct tdesc_type *field_type; + struct tdesc_type *type; + type = tdesc_create_flags (feature, "status32_type", 4); + tdesc_add_flag (type, 0, "H"); + tdesc_add_bitfield (type, "E", 1, 4); + tdesc_add_flag (type, 5, "AE"); + tdesc_add_flag (type, 6, "DE"); + tdesc_add_flag (type, 7, "U"); + tdesc_add_flag (type, 8, "V"); + tdesc_add_flag (type, 9, "C"); + tdesc_add_flag (type, 10, "N"); + tdesc_add_flag (type, 11, "Z"); + tdesc_add_flag (type, 12, "L"); + tdesc_add_flag (type, 13, "DZ"); + tdesc_add_flag (type, 14, "SC"); + tdesc_add_flag (type, 15, "ES"); + tdesc_add_bitfield (type, "RB", 16, 18); + tdesc_add_flag (type, 19, "AD"); + tdesc_add_flag (type, 20, "US"); + tdesc_add_flag (type, 31, "IE"); + + tdesc_create_reg (feature, "pc", 35, 1, NULL, 32, "code_ptr"); + tdesc_create_reg (feature, "status32", 36, 1, NULL, 32, "status32_type"); + tdesc_create_reg (feature, "lp_start", 37, 1, NULL, 32, "code_ptr"); + tdesc_create_reg (feature, "lp_end", 38, 1, NULL, 32, "code_ptr"); + tdesc_create_reg (feature, "bta", 39, 1, NULL, 32, "code_ptr"); + + tdesc_arc_v2_linux = result; +} diff --git a/gdb/features/arc-v2-linux.xml b/gdb/features/arc-v2-linux.xml new file mode 100644 index 0000000..4bd17ac --- /dev/null +++ b/gdb/features/arc-v2-linux.xml @@ -0,0 +1,91 @@ + + + + + + arc:HS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gdb/regformats/arc-arcompact-linux.dat b/gdb/regformats/arc-arcompact-linux.dat new file mode 100644 index 0000000..1d35860 --- /dev/null +++ b/gdb/regformats/arc-arcompact-linux.dat @@ -0,0 +1,42 @@ +# THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi :set ro: +# Generated from: arc-arcompact-linux.xml +name:arc_arcompact_linux +xmltarget:arc-arcompact-linux.xml +expedite:sp,pc +32:r0 +32:r1 +32:r2 +32:r3 +32:r4 +32:r5 +32:r6 +32:r7 +32:r8 +32:r9 +32:r10 +32:r11 +32:r12 +32:r13 +32:r14 +32:r15 +32:r16 +32:r17 +32:r18 +32:r19 +32:r20 +32:r21 +32:r22 +32:r23 +32:r24 +32:r25 +32:gp +32:fp +32:sp +32:blink +32:lp_count +32:pcl +32:pc +32:status32 +32:lp_start +32:lp_end +32:bta diff --git a/gdb/regformats/arc-v2-linux.dat b/gdb/regformats/arc-v2-linux.dat new file mode 100644 index 0000000..7e5d190 --- /dev/null +++ b/gdb/regformats/arc-v2-linux.dat @@ -0,0 +1,45 @@ +# THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi :set ro: +# Generated from: arc-v2-linux.xml +name:arc_v2_linux +xmltarget:arc-v2-linux.xml +expedite:sp,pc +32:r0 +32:r1 +32:r2 +32:r3 +32:r4 +32:r5 +32:r6 +32:r7 +32:r8 +32:r9 +32:r10 +32:r11 +32:r12 +32:r13 +32:r14 +32:r15 +32:r16 +32:r17 +32:r18 +32:r19 +32:r20 +32:r21 +32:r22 +32:r23 +32:r24 +32:r25 +32:gp +32:fp +32:sp +32:r30 +32:blink +32:r58 +32:r59 +32:lp_count +32:pcl +32:pc +32:status32 +32:lp_start +32:lp_end +32:bta