From: Anton Kolesov <Anton.Kolesov@synopsys.com>
To: gdb-patches@sourceware.org
Cc: Anton Kolesov <Anton.Kolesov@synopsys.com>,
Francois Bedard <Francois.Bedard@synopsys.com>
Subject: [PATCH 2/3] arc: Recognize registers available on Linux targets
Date: Wed, 11 Oct 2017 14:56:00 -0000 [thread overview]
Message-ID: <20171011145633.19343-2-Anton.Kolesov@synopsys.com> (raw)
In-Reply-To: <20171011145633.19343-1-Anton.Kolesov@synopsys.com>
For ARC there are registers that are not part of a required set in XML target
descriptions by default, but which are almost always present on ARC targets and
are universally exposed by the ptrace interface. This patch adds those
registers to those recognized by GDB:
- R30 - core register available in user-space on ARC HS processors only (used
to be a privileged only ILINK2 on ARC700).
- R58, R59 - accumulator register pair for a 64-multiplier and
double-precision FPU - only on ARC HS.
- LP_START, LP_END - AUX registers, hardware loop start and end. Formally
optional, though it is hard to find ARC configuration that doesn't have
them and is always present in processors that can run Linux. GDB needs to
know about those registers to implement proper software single stepping,
since they affect what instruction will be next.
- BTA - AUX register that contains branch target address. Value of this
register makes sense only when execution halts at the delay slot
instruction - in this case branch instruction is already committed,
STATUS32.DE is set to 1 and BTA contains address of next PC. GDB needs to
understand this register to properly handle situations when breakpoint has
been set in the delay slot (delay slot is stepped over when doing software
single stepping). Unfortunately, right now this doesn't work very well,
because Linux doesn't allow modifications of STATUS32 via ptrace and Linux
uses TRAP_S instruction to implement software breakpoints - this
instruction commits when executed, therefore when TRAP_S is set in the
delay slot and execution halts at it, PC is already advanced to BTA value
and STATUS32.DE is reset. BTA register will be more useful for debugger
after support for SWI instruction will be added to ARC Linux - this
breakpoint instruction doesn't commit, hence it doesn't change processor
state.
gdb/ChangeLog:
yyyy-mm-dd Anton Kolesov <Anton.Kolesov@synopsys.com>
* arc-tdep.c (core_v2_register_names): Fix names of R58 and R59.
(aux_minimal_register_names): Add LP_START, LP_END and BTA.
(arc_tdesc_init): Recognize those registers.
* arc-tdep.h (arc_regnum): Add R58, R59, LP_START, LP_END and BTA.
(gdbarch_tdep): New field has_hw_loops.
gdb/doc/ChangeLog:
yyyy-mm-dd Anton Kolesov <Anton.Kolesov@synopsys.com>
* gdb.texinfo (Synopsys ARC): Document LP_START, LP_END and BTA.
---
gdb/arc-tdep.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++-------
gdb/arc-tdep.h | 15 +++++++++++--
gdb/doc/gdb.texinfo | 3 ++-
3 files changed, 68 insertions(+), 11 deletions(-)
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index a825917..1643912 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -120,12 +120,12 @@ static const char *const core_v2_register_names[] = {
"r44", "r45", "r46", "r47",
"r48", "r49", "r50", "r51",
"r52", "r53", "r54", "r55",
- "r56", "r57", "accl", "acch",
+ "r56", "r57", "r58", "r59",
"lp_count", "reserved", "limm", "pcl",
};
static const char *const aux_minimal_register_names[] = {
- "pc", "status32",
+ "pc", "status32", "lp_start", "lp_end", "bta"
};
static const char *const core_arcompact_register_names[] = {
@@ -1768,7 +1768,7 @@ static const struct frame_base arc_normal_base = {
static int
arc_tdesc_init (struct gdbarch_info info, const struct target_desc **tdesc,
- struct tdesc_arch_data **tdesc_data)
+ struct tdesc_arch_data **tdesc_data, struct gdbarch_tdep *tdep)
{
if (arc_debug)
debug_printf ("arc: Target description initialization.\n");
@@ -1919,8 +1919,35 @@ arc_tdesc_init (struct gdbarch_info info, const struct target_desc **tdesc,
|| (i >= ARC_R16_REGNUM && i <= ARC_R25_REGNUM)))
continue;
- valid_p = tdesc_numbered_register (feature, tdesc_data_loc, i,
+ /* R58 and R59 can have special names: ACCL and ACCH, however which
+ one is which depends on target endianness - for little endian R58
+ is ACCL, R59 is ACCH; vice versa for big endian. */
+
+ const char *const r58_names[] = {
+ "r58",
+ (info.byte_order == BFD_ENDIAN_LITTLE ? "accl" : "acch"),
+ NULL
+ };
+ const char *const r59_names[] = {
+ "r59",
+ (info.byte_order == BFD_ENDIAN_LITTLE ? "acch" : "accl"),
+ NULL
+ };
+
+ switch (i)
+ {
+ case ARC_R58_REGNUM:
+ valid_p = tdesc_numbered_register_choices (feature, tdesc_data_loc,
+ i, r58_names);
+ break;
+ case ARC_R59_REGNUM:
+ valid_p = tdesc_numbered_register_choices (feature, tdesc_data_loc,
+ i, r59_names);
+ break;
+ default:
+ valid_p = tdesc_numbered_register (feature, tdesc_data_loc, i,
core_regs[i]);
+ }
/* - Ignore errors in extension registers - they are optional.
- Ignore missing ILINK because it doesn't make sense for Linux.
@@ -1956,7 +1983,9 @@ arc_tdesc_init (struct gdbarch_info info, const struct target_desc **tdesc,
{
const char *name = aux_minimal_register_names[i - ARC_FIRST_AUX_REGNUM];
valid_p = tdesc_numbered_register (feature, tdesc_data_loc, i, name);
- if (!valid_p)
+
+ /* Only STATUS32 and PC are mandatory. */
+ if (!valid_p && (i == ARC_PC_REGNUM || i == ARC_STATUS32_REGNUM))
{
arc_print (_("Error: Cannot find required register `%s' "
"in feature `%s'.\n"),
@@ -1964,6 +1993,11 @@ arc_tdesc_init (struct gdbarch_info info, const struct target_desc **tdesc,
tdesc_data_cleanup (tdesc_data_loc);
return FALSE;
}
+ /* Hardware loops present if both its registers are. */
+ else if (ARC_LP_START_REGNUM == i)
+ tdep->has_hw_loops = valid_p;
+ else if (ARC_LP_END_REGNUM == i)
+ tdep->has_hw_loops &= valid_p;
}
*tdesc = tdesc_loc;
@@ -1983,13 +2017,17 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
if (arc_debug)
debug_printf ("arc: Architecture initialization.\n");
- if (!arc_tdesc_init (info, &tdesc, &tdesc_data))
- return NULL;
-
/* Allocate the ARC-private target-dependent information structure, and the
GDB target-independent information structure. */
struct gdbarch_tdep *tdep = XCNEW (struct gdbarch_tdep);
tdep->jb_pc = -1; /* No longjmp support by default. */
+
+ if (!arc_tdesc_init (info, &tdesc, &tdesc_data, tdep))
+ {
+ XDELETE (tdep);
+ return NULL;
+ }
+
struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep);
/* Data types. */
@@ -2020,6 +2058,13 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_ps_regnum (gdbarch, ARC_STATUS32_REGNUM);
set_gdbarch_fp0_regnum (gdbarch, -1); /* No FPU registers. */
+ /* Confirm that register name lists have proper length. */
+ gdb_static_assert (ARC_LAST_REGNUM + 1
+ == (ARRAY_SIZE (core_v2_register_names)
+ + ARRAY_SIZE (aux_minimal_register_names)));
+ gdb_static_assert (ARRAY_SIZE (core_v2_register_names)
+ == ARRAY_SIZE (core_arcompact_register_names));
+
set_gdbarch_dummy_id (gdbarch, arc_dummy_id);
set_gdbarch_push_dummy_call (gdbarch, arc_push_dummy_call);
set_gdbarch_push_dummy_code (gdbarch, arc_push_dummy_code);
diff --git a/gdb/arc-tdep.h b/gdb/arc-tdep.h
index 580ccb7..4ea06f6 100644
--- a/gdb/arc-tdep.h
+++ b/gdb/arc-tdep.h
@@ -53,6 +53,8 @@ enum arc_regnum
ARC_R30_REGNUM,
/* Return address from function. */
ARC_BLINK_REGNUM,
+ ARC_R58_REGNUM = 58,
+ ARC_R59_REGNUM,
/* Zero-delay loop counter. */
ARC_LP_COUNT_REGNUM = 60,
/* Reserved register number. There should never be a register with such
@@ -74,8 +76,14 @@ enum arc_regnum
ARC_FIRST_AUX_REGNUM = ARC_PC_REGNUM,
/* Status register. */
ARC_STATUS32_REGNUM,
- ARC_LAST_REGNUM = ARC_STATUS32_REGNUM,
- ARC_LAST_AUX_REGNUM = ARC_STATUS32_REGNUM,
+ /* Zero-delay loop start instruction. */
+ ARC_LP_START_REGNUM,
+ /* Zero-delay loop next-after-last instruction. */
+ ARC_LP_END_REGNUM,
+ /* Branch target address. */
+ ARC_BTA_REGNUM,
+ ARC_LAST_AUX_REGNUM = ARC_BTA_REGNUM,
+ ARC_LAST_REGNUM = ARC_LAST_AUX_REGNUM,
/* Additional ABI constants. */
ARC_FIRST_ARG_REGNUM = ARC_R0_REGNUM,
@@ -100,6 +108,9 @@ struct gdbarch_tdep
/* Offset to PC value in jump buffer. If this is negative, longjmp
support will be disabled. */
int jb_pc;
+
+ /* Whether target has hardware (aka zero-delay) loops. */
+ bool has_hw_loops;
};
/* Utility functions used by other ARC-specific modules. */
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index bfeb7a9..69a4a70 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -41614,7 +41614,8 @@ difference with @samp{org.gnu.gdb.arc.core.v2} feature is in the names of
ARC v2, but @samp{ilink2} is optional on ARCompact.
The @samp{org.gnu.gdb.arc.aux-minimal} feature is required for all ARC
-targets. It should contain registers @samp{pc} and @samp{status32}.
+targets. It should contain registers @samp{pc} and @samp{status32}. It may
+contain registers @samp{lp_start}, @samp{lp_end} and @samp{bta}.
@node ARM Features
@subsection ARM Features
--
2.8.3
next prev parent reply other threads:[~2017-10-11 14:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-11 14:56 [PATCH 1/3] arc: Add XML target descriptions for " Anton Kolesov
2017-10-11 14:56 ` [PATCH 3/3] arc: Add GNU/Linux support for ARC Anton Kolesov
2017-10-11 14:56 ` Anton Kolesov [this message]
2017-10-21 8:23 ` [PATCH 2/3] arc: Recognize registers available on Linux targets Eli Zaretskii
2017-10-12 1:29 ` [PATCH 1/3] arc: Add XML target descriptions for " Yao Qi
2017-10-18 15:06 ` Anton Kolesov
2017-10-18 17:33 ` Anton Kolesov
2017-10-26 11:40 ` [PATCH v2 2/4] arc: Add XML target features " Anton Kolesov
2017-10-26 11:40 ` [PATCH v2 3/4] arc: Recognize registers available on " Anton Kolesov
2017-10-26 16:02 ` Eli Zaretskii
2017-10-26 11:40 ` [PATCH v2 4/4] arc: Add GNU/Linux support for ARC Anton Kolesov
2017-10-26 11:40 ` [PATCH v2 1/4] arc: Migrate to new target features Anton Kolesov
2017-11-08 11:13 ` Anton Kolesov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171011145633.19343-2-Anton.Kolesov@synopsys.com \
--to=anton.kolesov@synopsys.com \
--cc=Francois.Bedard@synopsys.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox