]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add tdesc osabi and architecture functions
authorAlan Hayward <alan.hayward@arm.com>
Mon, 26 Feb 2018 14:20:41 +0000 (14:20 +0000)
committerAlan Hayward <alan.hayward@arm.com>
Wed, 21 Mar 2018 15:57:08 +0000 (15:57 +0000)
Add functions to access to printable names for osabi and architecture in
target_desc.

I wanted to add these as member functions of target_desc, but cannot until
target_desc is moved into the header files.

Identical to V3 version.

Alan.

2018-03-21  Alan Hayward  <alan.hayward@arm.com>

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.

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

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

index 986625e68518567958c0aae08fbf1057c8f44364..8ab77e365f1b900a400eb1fc65630059bbe00131 100644 (file)
@@ -303,9 +303,18 @@ 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 1f30a3243191b34204d85b4dd7837491433943b2..69bde2ae42bcc32df5a954f1bd058a8a717cae37 100644 (file)
@@ -131,6 +131,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)
@@ -140,6 +148,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)
 {
@@ -164,13 +180,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.  */