]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/target-descriptions.c
ChangeLog:
[thirdparty/binutils-gdb.git] / gdb / target-descriptions.c
index 024257b73400aff3f602fb64bd9a85b27ec69b60..b8bb48f6687a060bfeadad898ed878a0aa15614d 100644 (file)
@@ -158,6 +158,10 @@ typedef struct tdesc_feature
 } *tdesc_feature_p;
 DEF_VEC_P(tdesc_feature_p);
 
+/* A compatible architecture from a target description.  */
+typedef const struct bfd_arch_info *arch_p;
+DEF_VEC_P(arch_p);
+
 /* A target description.  */
 
 struct target_desc
@@ -169,6 +173,9 @@ struct target_desc
      otherwise.  */
   enum gdb_osabi osabi;
 
+  /* The list of compatible architectures reported by the target.  */
+  VEC(arch_p) *compatible;
+
   /* Any architecture-specific properties specified by the target.  */
   VEC(property_s) *properties;
 
@@ -326,6 +333,28 @@ target_current_description (void)
 
   return NULL;
 }
+
+/* Return non-zero if this target description is compatible
+   with the given BFD architecture.  */
+
+int
+tdesc_compatible_p (const struct target_desc *target_desc,
+                   const struct bfd_arch_info *arch)
+{
+  const struct bfd_arch_info *compat;
+  int ix;
+
+  for (ix = 0; VEC_iterate (arch_p, target_desc->compatible, ix, compat);
+       ix++)
+    {
+      if (compat == arch
+         || arch->compatible (arch, compat)
+         || compat->compatible (compat, arch))
+       return 1;
+    }
+
+  return 0;
+}
 \f
 
 /* Direct accessors for target descriptions.  */
@@ -1156,6 +1185,8 @@ free_target_description (void *arg)
     }
   VEC_free (property_s, target_desc->properties);
 
+  VEC_free (arch_p, target_desc->compatible);
+
   xfree (target_desc);
 }
 
@@ -1165,6 +1196,30 @@ make_cleanup_free_target_description (struct target_desc *target_desc)
   return make_cleanup (free_target_description, target_desc);
 }
 
+void
+tdesc_add_compatible (struct target_desc *target_desc,
+                     const struct bfd_arch_info *compatible)
+{
+  const struct bfd_arch_info *compat;
+  int ix;
+
+  /* If this instance of GDB is compiled without BFD support for the
+     compatible architecture, simply ignore it -- we would not be able
+     to handle it anyway.  */
+  if (compatible == NULL)
+    return;
+
+  for (ix = 0; VEC_iterate (arch_p, target_desc->compatible, ix, compat);
+       ix++)
+    if (compat == compatible)
+      internal_error (__FILE__, __LINE__,
+                     _("Attempted to add duplicate "
+                       "compatible architecture \"%s\""),
+                     compatible->printable_name);
+
+  VEC_safe_push (arch_p, target_desc->compatible, compatible);
+}
+
 void
 set_tdesc_property (struct target_desc *target_desc,
                    const char *key, const char *value)
@@ -1257,6 +1312,7 @@ static void
 maint_print_c_tdesc_cmd (char *args, int from_tty)
 {
   const struct target_desc *tdesc;
+  const struct bfd_arch_info *compatible;
   const char *filename, *inp;
   char *function, *outp;
   struct property *prop;
@@ -1313,6 +1369,16 @@ maint_print_c_tdesc_cmd (char *args, int from_tty)
       printf_unfiltered ("\n");
     }
 
+  for (ix = 0; VEC_iterate (arch_p, tdesc->compatible, ix, compatible);
+       ix++)
+    {
+      printf_unfiltered
+       ("  tdesc_add_compatible (result, bfd_scan_arch (\"%s\"));\n",
+        compatible->printable_name);
+    }
+  if (ix)
+    printf_unfiltered ("\n");
+
   for (ix = 0; VEC_iterate (property_s, tdesc->properties, ix, prop);
        ix++)
     {