public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Shahab Vahedi <shahab.vahedi@gmail.com>
To: gdb-patches@sourceware.org
Cc: Shahab Vahedi <shahab.vahedi@gmail.com>,
	Shahab Vahedi <shahab@synopsys.com>,
	Simon Marchi <simark@simark.ca>, Tom Tromey <tom@tromey.com>,
	Eli Zaretskii <eliz@gnu.org>,
	Anton Kolesov <anton.kolesov@synopsys.com>,
	Francois Bedard <fbedard@synopsys.com>
Subject: [PUSHED 3/4] arc: Add hardware loop detection
Date: Tue, 25 Aug 2020 17:47:03 +0200	[thread overview]
Message-ID: <20200825154704.29312-4-shahab.vahedi@gmail.com> (raw)
In-Reply-To: <20200825154704.29312-1-shahab.vahedi@gmail.com>

From: Shahab Vahedi <shahab@synopsys.com>

For ARC there are registers that are not part of a required set in XML
target descriptions by default, but are almost always present on ARC
targets and are universally exposed by the ptrace interface.  Hardware
loop registers being one of them.

LP_START and LP_END auxiliary registers are hardware loop start and end.
Formally, they are optional, but it is hard to find an ARC configuration
that doesn't have them.  They are always present in processors that can
run GNU/Linux.  GDB needs to know about those registers to implement
proper software single stepping, since they affect  what instruction
will be next.

This commit adds the code to check for the existance of "lp_start" and
"lp_end" in XML target descriptions. If they exist, then the function
reports that the target supports hardware loops.

gdb/ChangeLog:

	* arc-tdep.c (arc_check_for_hardware_loop): New.
	* arc-tdep.h (gdbarch_tdep): New field has_hw_loops.

gdb/doc/ChangeLog:

	* gdb.texinfo (Synopsys ARC): Document LP_START, LP_END and BTA.
---
 gdb/ChangeLog       |  5 +++++
 gdb/arc-tdep.c      | 39 +++++++++++++++++++++++++++++++++++----
 gdb/arc-tdep.h      |  3 +++
 gdb/doc/ChangeLog   |  4 ++++
 gdb/doc/gdb.texinfo | 11 +++++++++--
 5 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c7e8cfd3bf6..2e97cdc061c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2020-08-25  Shahab Vahedi  <shahab@synopsys.com>
+
+	* arc-tdep.c (arc_check_for_hardware_loop): New.
+	* arc-tdep.h (gdbarch_tdep): New field has_hw_loops.
+
 2020-08-25  Shahab Vahedi  <shahab@synopsys.com>
 
 	* arc-tdep.h: Include "gdbarch.h".
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index cb4941dec02..8b4e2857fb9 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -2041,6 +2041,35 @@ arc_check_tdesc_feature (struct tdesc_arch_data *tdesc_data,
   return true;
 }
 
+/* Check for the existance of "lp_start" and "lp_end" in target description.
+   If both are present, assume there is hardware loop support in the target.
+   This can be improved by looking into "lpc_size" field of "isa_config"
+   auxiliary register.  */
+
+static bool
+arc_check_for_hw_loops (const struct target_desc *tdesc,
+			struct tdesc_arch_data *data)
+{
+  const auto feature_aux = tdesc_find_feature (tdesc, ARC_AUX_FEATURE_NAME);
+  const auto aux_regset = determine_aux_reg_feature_set ();
+
+  if (feature_aux == nullptr)
+    return false;
+
+  bool hw_loop_p = false;
+  const auto lp_start_name =
+    aux_regset->registers[ARC_LP_START_REGNUM - ARC_FIRST_AUX_REGNUM].names[0];
+  const auto lp_end_name =
+    aux_regset->registers[ARC_LP_END_REGNUM - ARC_FIRST_AUX_REGNUM].names[0];
+
+  hw_loop_p = tdesc_numbered_register (feature_aux, data,
+				       ARC_LP_START_REGNUM, lp_start_name);
+  hw_loop_p &= tdesc_numbered_register (feature_aux, data,
+				       ARC_LP_END_REGNUM, lp_end_name);
+
+  return hw_loop_p;
+}
+
 /* Initialize target description for the ARC.
 
    Returns true if input TDESC was valid and in this case it will assign TDESC
@@ -2163,13 +2192,15 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     debug_printf ("arc: Architecture initialization.\n");
 
   if (!arc_tdesc_init (info, &tdesc, &tdesc_data))
-    return NULL;
+    return nullptr;
 
   /* Allocate the ARC-private target-dependent information structure, and the
      GDB target-independent information structure.  */
-  struct gdbarch_tdep *tdep = XCNEW (struct gdbarch_tdep);
+  gdb::unique_xmalloc_ptr<struct gdbarch_tdep> tdep
+    (XCNEW (struct gdbarch_tdep));
   tdep->jb_pc = -1; /* No longjmp support by default.  */
-  struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep);
+  tdep->has_hw_loops = arc_check_for_hw_loops (tdesc, tdesc_data);
+  struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep.release ());
 
   /* Data types.  */
   set_gdbarch_short_bit (gdbarch, 16);
@@ -2250,7 +2281,7 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
      It can override functions set earlier.  */
   gdbarch_init_osabi (info, gdbarch);
 
-  if (tdep->jb_pc >= 0)
+  if (gdbarch_tdep (gdbarch)->jb_pc >= 0)
     set_gdbarch_get_longjmp_target (gdbarch, arc_get_longjmp_target);
 
   /* Disassembler options.  Enforce CPU if it was specified in XML target
diff --git a/gdb/arc-tdep.h b/gdb/arc-tdep.h
index 5968abd4600..e752348a262 100644
--- a/gdb/arc-tdep.h
+++ b/gdb/arc-tdep.h
@@ -111,6 +111,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/ChangeLog b/gdb/doc/ChangeLog
index 6a81351282f..badf7ae10b5 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,7 @@
+2020-08-25  Shahab Vahedi  <shahab@synopsys.com>
+
+	* gdb.texinfo (Synopsys ARC): Document LP_START, LP_END and BTA.
+
 2020-08-25  Shahab Vahedi  <shahab@synopsys.com>
 
 	* gdb.texinfo (Synopsys ARC): Update the documentation for ARC
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index a4f5b787503..77c5d895053 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -45298,8 +45298,15 @@ Extension core registers @samp{r32} through @samp{r59} are optional and their
 existence depends on the configuration.  When debugging GNU/Linux applications,
 i.e.@: user space debugging, these core registers are not available.
 
-The @samp{org.gnu.gdb.arc.aux} feature is required for all ARC targets.  It
-should at least contain @samp{pc} and @samp{status32} registers.
+The @samp{org.gnu.gdb.arc.aux} feature is required for all ARC targets.  Here
+is the list of registers pertinent to this feature:
+
+@itemize @minus
+@item
+mandatory: @samp{pc} and @samp{status32}.
+@item
+optional: @samp{lp_start}, @samp{lp_end}, and @samp{bta}.
+@end itemize
 
 @node ARM Features
 @subsection ARM Features
-- 
2.28.0


  parent reply	other threads:[~2020-08-25 15:47 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26 12:52 [PATCH 0/4] arc: Add GNU/Linux support Shahab Vahedi
2020-03-26 12:52 ` [PATCH 1/4] arc: Add XML target features for Linux targets Shahab Vahedi
2020-04-24 13:46   ` Tom Tromey
2020-03-26 12:52 ` [PATCH 2/4] arc: Recognize registers available on " Shahab Vahedi
2020-04-24 13:50   ` Tom Tromey
2020-03-26 12:52 ` [PATCH 3/4] arc: Add GNU/Linux support for ARC Shahab Vahedi
2020-04-24 14:00   ` Tom Tromey
2020-03-26 12:52 ` [PATCH 4/4] arc: Add arc-*-linux regformats Shahab Vahedi
2020-04-24 14:01   ` Tom Tromey
2020-04-06  9:13 ` [PING][PATCH 0/4] arc: Add GNU/Linux support Shahab Vahedi
2020-04-20 16:51 ` [PING^2][PATCH " Shahab Vahedi
2020-04-28 16:04 ` [PATCH v2 " Shahab Vahedi
2020-04-28 16:04   ` [PATCH v2 1/4] arc: Add XML target features for Linux targets Shahab Vahedi
2020-05-14 14:49     ` Simon Marchi
2020-04-28 16:04   ` [PATCH v2 2/4] arc: Recognize registers available on " Shahab Vahedi
2020-04-28 16:56     ` Eli Zaretskii
2020-05-14 15:01     ` Simon Marchi
2020-06-17 15:46       ` Shahab Vahedi
2020-07-13 15:48         ` Simon Marchi
2020-07-14  9:05           ` Shahab Vahedi
2020-04-28 16:04   ` [PATCH v2 3/4] arc: Add GNU/Linux support for ARC Shahab Vahedi
2020-05-14 15:09     ` Simon Marchi
2020-06-15 23:13       ` Shahab Vahedi
2020-06-16  0:58         ` Simon Marchi
2020-04-28 16:04   ` [PATCH v2 4/4] arc: Add arc-*-linux regformats Shahab Vahedi
2020-05-14 15:12     ` Simon Marchi
2020-06-15 23:37       ` Shahab Vahedi
2020-06-16  2:08         ` Simon Marchi
2020-05-14 11:43   ` [PATCH v2 0/4] arc: Add GNU/Linux support Shahab Vahedi
2020-07-13 15:45   ` [PATCH v3 0/3] " Shahab Vahedi
2020-07-13 15:45     ` [PATCH v3 1/3] arc: Add ARCv2 XML target along with refactoring Shahab Vahedi
2020-07-15  2:52       ` Simon Marchi
2020-07-15 20:35         ` Shahab Vahedi
2020-07-15 21:23           ` Christian Biesinger
2020-07-16  1:59             ` Simon Marchi
2020-07-16 13:28           ` Simon Marchi
2020-07-22 13:36             ` Shahab Vahedi
2020-07-22 13:49               ` Simon Marchi
2020-07-22 14:33                 ` Shahab Vahedi
2020-07-22 14:54                   ` Simon Marchi
2020-07-13 15:45     ` [PATCH v3 2/3] arc: Add hardware loop detection Shahab Vahedi
2020-07-15  2:55       ` Simon Marchi
2020-07-13 15:45     ` [PATCH v3 3/3] arc: Add GNU/Linux support for ARC Shahab Vahedi
2020-07-15  3:03       ` Simon Marchi
2020-07-23 19:35     ` [PATCH v4 0/3] arc: Add GNU/Linux support Shahab Vahedi
2020-07-23 19:35       ` [PATCH v4 1/3] arc: Add ARCv2 XML target along with refactoring Shahab Vahedi
2020-07-30 23:34         ` Simon Marchi
2020-07-23 19:35       ` [PATCH v4 2/3] arc: Add hardware loop detection Shahab Vahedi
2020-08-01 14:53         ` Simon Marchi
2020-07-23 19:35       ` [PATCH v4 3/3] arc: Add GNU/Linux support for ARC Shahab Vahedi
2020-08-01 15:01         ` Simon Marchi
2020-08-01 23:31       ` [PATCH v4 0/3] arc: Add GNU/Linux support Simon Marchi
2020-08-04  7:59         ` Shahab Vahedi
2020-08-04 12:42           ` Simon Marchi
2020-08-04  8:57 ` [PATCH v5 0/4] " Shahab Vahedi
2020-08-04  8:57   ` [PATCH v5 1/4] arc: Add ARCv2 XML target along with refactoring Shahab Vahedi
2020-08-04 13:08     ` Simon Marchi
2020-08-04 13:18       ` Shahab Vahedi
2020-08-04 13:20         ` Simon Marchi
2020-08-04 14:12           ` Shahab Vahedi
2020-08-04  8:57   ` [PATCH v5 2/4] arc: Add inclusion of "gdbarch.h" in "arc-tdep.h" Shahab Vahedi
2020-08-04  8:57   ` [PATCH v5 3/4] arc: Add hardware loop detection Shahab Vahedi
2020-08-04 14:28     ` Eli Zaretskii
2020-08-04 16:17       ` Shahab Vahedi
2020-08-04 16:42         ` Eli Zaretskii
2020-08-04 18:15           ` Shahab Vahedi
2020-08-04  8:57   ` [PATCH v5 4/4] arc: Add GNU/Linux support for ARC Shahab Vahedi
2020-08-04 12:49   ` [PATCH v5 0/4] arc: Add GNU/Linux support Simon Marchi
2020-08-04 13:05     ` Shahab Vahedi
2020-08-05 11:09 ` [PATCH v6 " Shahab Vahedi
2020-08-05 11:09   ` [PATCH v6 1/4] arc: Add ARCv2 XML target along with refactoring Shahab Vahedi
2020-08-05 14:31     ` Eli Zaretskii
2020-08-21 16:16     ` Simon Marchi
2020-08-24 20:14       ` Shahab Vahedi
2020-08-05 11:09   ` [PATCH v6 2/4] arc: Add inclusion of "gdbarch.h" in "arc-tdep.h" Shahab Vahedi
2020-08-05 11:09   ` [PATCH v6 3/4] arc: Add hardware loop detection Shahab Vahedi
2020-08-05 11:09   ` [PATCH v6 4/4] arc: Add GNU/Linux support for ARC Shahab Vahedi
2020-08-17  8:07   ` [PATCH v6 0/4] arc: Add GNU/Linux support Shahab Vahedi
2020-08-17 14:12     ` Eli Zaretskii
2020-08-25 15:47 ` [PUSHED " Shahab Vahedi
2020-08-25 15:47   ` [PUSHED 1/4] arc: Add ARCv2 XML target along with refactoring Shahab Vahedi
2020-08-25 16:00     ` Eli Zaretskii
2020-08-25 15:47   ` [PUSHED 2/4] arc: Add inclusion of "gdbarch.h" in "arc-tdep.h" Shahab Vahedi
2020-08-25 15:47   ` Shahab Vahedi [this message]
2020-08-25 15:58     ` [PUSHED 3/4] arc: Add hardware loop detection Eli Zaretskii
2020-08-25 15:47   ` [PUSHED 4/4] arc: Add GNU/Linux support for ARC Shahab Vahedi

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=20200825154704.29312-4-shahab.vahedi@gmail.com \
    --to=shahab.vahedi@gmail.com \
    --cc=anton.kolesov@synopsys.com \
    --cc=eliz@gnu.org \
    --cc=fbedard@synopsys.com \
    --cc=gdb-patches@sourceware.org \
    --cc=shahab@synopsys.com \
    --cc=simark@simark.ca \
    --cc=tom@tromey.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).