public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Improve target description check for SVE in gdbserver
@ 2019-11-20 16:58 Luis Machado
  0 siblings, 0 replies; only message in thread
From: Luis Machado @ 2019-11-20 16:58 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6cdd651fda1315cb43a6a50223350da0da3f6dcf

commit 6cdd651fda1315cb43a6a50223350da0da3f6dcf
Author: Luis Machado <luis.machado@linaro.org>
Date:   Mon Nov 18 16:36:53 2019 -0300

    Improve target description check for SVE in gdbserver
    
    The current code checks for the presence of a SVE target description by
    comparing the number of registers.  This is a bit fragile since the number
    of registers can change whenever we add new sets. Like PAC, for example.
    
    If the comparison breaks, then we're left with SVE registers in the
    description, but gdbserver doesn't send the registers to GDB, which in
    turn displays stale information to the user.
    
    The following patch changes the check to use the SVE feature string instead,
    which hopefully should be more stable.
    
    gdb/gdbserver/ChangeLog:
    
    2019-11-20  Luis Machado  <luis.machado@linaro.org>
    
    	* linux-aarch64-low.c (is_sve_tdesc): Check against target feature
    	instead of register count.
    	* tdesc.c (tdesc_contains_feature): New function.
    	* tdesc.h (tdesc_contains_feature): New prototype.
    
    Change-Id: I28b782cb1677560ca9a06a1be442974b25aabae4

Diff:
---
 gdb/gdbserver/ChangeLog           |  7 +++++++
 gdb/gdbserver/linux-aarch64-low.c |  2 +-
 gdb/gdbserver/tdesc.c             | 16 ++++++++++++++++
 gdb/gdbserver/tdesc.h             |  5 +++++
 4 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index fde6abb..a5da6b5 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,10 @@
+2019-11-20  Luis Machado  <luis.machado@linaro.org>
+
+	* linux-aarch64-low.c (is_sve_tdesc): Check against target feature
+	instead of register count.
+	* tdesc.c (tdesc_contains_feature): New function.
+	* tdesc.h (tdesc_contains_feature): New prototype.
+
 2019-11-15  Christian Biesinger  <cbiesinger@google.com>
 
 	* Makefile.in: Add safe-strerror.c.
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index 87a21a0..9e234e0 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -83,7 +83,7 @@ is_sve_tdesc (void)
 {
   struct regcache *regcache = get_thread_regcache (current_thread, 0);
 
-  return regcache->tdesc->reg_defs.size () == AARCH64_SVE_NUM_REGS;
+  return tdesc_contains_feature (regcache->tdesc, "org.gnu.gdb.aarch64.sve");
 }
 
 static void
diff --git a/gdb/gdbserver/tdesc.c b/gdb/gdbserver/tdesc.c
index 92a0a60..817e69a 100644
--- a/gdb/gdbserver/tdesc.c
+++ b/gdb/gdbserver/tdesc.c
@@ -186,3 +186,19 @@ tdesc_create_feature (struct target_desc *tdesc, const char *name)
   tdesc->features.emplace_back (new_feature);
   return new_feature;
 }
+
+/* See gdbsupport/tdesc.h.  */
+
+bool
+tdesc_contains_feature (const target_desc *tdesc, const std::string &feature)
+{
+  gdb_assert (tdesc != nullptr);
+
+  for (const tdesc_feature_up &f : tdesc->features)
+    {
+      if (f->name == feature)
+	return true;
+    }
+
+  return false;
+}
diff --git a/gdb/gdbserver/tdesc.h b/gdb/gdbserver/tdesc.h
index b93f53c..da21cda 100644
--- a/gdb/gdbserver/tdesc.h
+++ b/gdb/gdbserver/tdesc.h
@@ -93,4 +93,9 @@ void init_target_desc (struct target_desc *tdesc,
 
 const struct target_desc *current_target_desc (void);
 
+/* Return true if TDESC contains the feature described by string FEATURE.
+   Return false otherwise.  */
+bool tdesc_contains_feature (const target_desc *tdesc,
+			     const std::string &feature);
+
 #endif /* GDBSERVER_TDESC_H */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-20 16:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-20 16:58 [binutils-gdb] Improve target description check for SVE in gdbserver Luis Machado

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).