Add tdesc osabi and architecture functions
authorAlan Hayward <alan.hayward@arm.com>
Wed, 18 Apr 2018 10:51:21 +0000 (11:51 +0100)
committerAlan Hayward <alan.hayward@arm.com>
Wed, 18 Apr 2018 13:00:43 +0000 (14:00 +0100)
gdb/
* common/tdesc.h (tdesc_architecture_name): Add new declaration.
(tdesc_osabi_name): Likewise.
* target-descriptions.c (tdesc_architecture_name): Add new function.
(tdesc_osabi_name): Likewise.

gdbserver/
* tdesc.c (tdesc_architecture_name): Add new function.
(tdesc_osabi_name): Likewise.
(tdesc_get_features_xml): Use new functions.

gdb/ChangeLog
gdb/common/tdesc.h
gdb/gdbserver/ChangeLog
gdb/gdbserver/tdesc.c
gdb/target-descriptions.c

index 83a2d01f9e77911f18627e2a37f9bb510b6f2220..624de26390a03152aab6ab673b3ac06ee3b86a69 100644 (file)
@@ -1,3 +1,11 @@
+2018-04-18  Alan Hayward  <alan.hayward@arm.com>
+
+       * common/tdesc.h (tdesc_architecture_name): Add new declaration.
+       (tdesc_osabi_name): Likewise.
+       * target-descriptions.c (tdesc_architecture_name): Add new
+       function.
+       (tdesc_osabi_name): Likewise.
+
 2018-04-18  Alan Hayward  <alan.hayward@arm.com>
 
        * common/tdesc.c (tdesc_predefined_type): Move to here.
index 7f4222b65397c66a1c2c14d0d5abcab30f54972c..8b826ec436c519113ec242afcb43ad67183a6042 100644 (file)
@@ -297,9 +297,17 @@ target_desc *allocate_target_description (void);
 void set_tdesc_architecture (target_desc *target_desc,
                             const char *name);
 
+/* Return the architecture associated with this target description as a string,
+   or NULL if no architecture was specified.  */
+const char *tdesc_architecture_name (const struct target_desc *target_desc);
+
 /* Set TARGET_DESC's osabi by NAME.  */
 void set_tdesc_osabi (target_desc *target_desc, const char *name);
 
+/* Return the osabi associated with this target description as a string,
+   or NULL if no osabi was specified.  */
+const char *tdesc_osabi_name (const struct target_desc *target_desc);
+
 /* Return the type associated with ID in the context of FEATURE, or
    NULL if none.  */
 struct tdesc_type *tdesc_named_type (const struct tdesc_feature *feature,
index a9de2ddb5044fea0fb49db5106ecbd9f6b939de1..96dc83cc7ee28f0545384678883222bb181de452 100644 (file)
@@ -1,3 +1,9 @@
+2018-04-18  Alan Hayward  <alan.hayward@arm.com>
+
+       * tdesc.c (tdesc_architecture_name): Add new function.
+       (tdesc_osabi_name): Likewise.
+       (tdesc_get_features_xml): Use new functions.
+
 2018-04-18  Alan Hayward  <alan.hayward@arm.com>
 
        * tdesc.c (tdesc_create_flags): Remove.
index aca27ea3b0c249129200f397af66d06cf7d158b6..7603a90a59cd7650ceaf3fe1af70c7095d2e00cc 100644 (file)
@@ -107,6 +107,14 @@ current_target_desc (void)
 
 /* See common/tdesc.h.  */
 
+const char *
+tdesc_architecture_name (const struct target_desc *target_desc)
+{
+  return target_desc->arch;
+}
+
+/* See common/tdesc.h.  */
+
 void
 set_tdesc_architecture (struct target_desc *target_desc,
                        const char *name)
@@ -116,6 +124,14 @@ set_tdesc_architecture (struct target_desc *target_desc,
 
 /* See common/tdesc.h.  */
 
+const char *
+tdesc_osabi_name (const struct target_desc *target_desc)
+{
+  return target_desc->osabi;
+}
+
+/* See common/tdesc.h.  */
+
 void
 set_tdesc_osabi (struct target_desc *target_desc, const char *name)
 {
@@ -140,13 +156,14 @@ tdesc_get_features_xml (target_desc *tdesc)
       buffer += "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">";
       buffer += "<target>";
       buffer += "<architecture>";
-      buffer += tdesc->arch;
+      buffer += tdesc_architecture_name (tdesc);
       buffer += "</architecture>";
 
-      if (tdesc->osabi != nullptr)
+      const char *osabi = tdesc_osabi_name (tdesc);
+      if (osabi != nullptr)
        {
          buffer += "<osabi>";
-         buffer += tdesc->osabi;
+         buffer += osabi;
          buffer += "</osabi>";
        }
 
index 2782ffaab9355e5a74da45e326ad468ff6bed796..da2c1ce34531c1b23281c42f2dacbc85444ef544 100644 (file)
@@ -628,6 +628,14 @@ tdesc_architecture (const struct target_desc *target_desc)
   return target_desc->arch;
 }
 
+/* See common/tdesc.h.  */
+
+const char *
+tdesc_architecture_name (const struct target_desc *target_desc)
+{
+  return target_desc->arch->printable_name;
+}
+
 /* Return the OSABI associated with this target description, or
    GDB_OSABI_UNKNOWN if no osabi was specified.  */
 
@@ -637,7 +645,16 @@ tdesc_osabi (const struct target_desc *target_desc)
   return target_desc->osabi;
 }
 
-\f
+/* See common/tdesc.h.  */
+
+const char *
+tdesc_osabi_name (const struct target_desc *target_desc)
+{
+  enum gdb_osabi osabi = tdesc_osabi (target_desc);
+  if (osabi > GDB_OSABI_UNKNOWN && osabi < GDB_OSABI_INVALID)
+    return gdbarch_osabi_name (osabi);
+  return nullptr;
+}
 
 /* Return 1 if this target description includes any registers.  */