s/get_regcache_arch (regcache)/regcache->arch ()/g
[deliverable/binutils-gdb.git] / gdb / target-descriptions.c
index bee8e004f4b04354383e7c09e71647a44b4acd7c..4f5e9d60a6d98b5855d6ee4ffeaa9fd7149d6395 100644 (file)
@@ -93,9 +93,7 @@ typedef struct tdesc_reg : tdesc_element
     xfree (group);
   }
 
-  /* Disable copying.  */
-  tdesc_reg (const tdesc_reg &) = delete;
-  tdesc_reg &operator= (const tdesc_reg &) = delete;
+  DISABLE_COPY_AND_ASSIGN (tdesc_reg);
 
   /* The name of this register.  In standard features, it may be
      recognized by the architecture support code, or it may be purely
@@ -229,9 +227,8 @@ typedef struct tdesc_type : tdesc_element
       }
     xfree ((char *) name);
   }
-  /* Disable copying.  */
-  tdesc_type (const tdesc_type &) = delete;
-  tdesc_type &operator= (const tdesc_type &) = delete;
+
+  DISABLE_COPY_AND_ASSIGN (tdesc_type);
 
   /* The name of this type.  If this type is a built-in type, this is
      a pointer to a constant string.  Otherwise, it's a
@@ -302,9 +299,7 @@ typedef struct tdesc_feature : tdesc_element
     xfree (name);
   }
 
-  /* Disable copying.  */
-  tdesc_feature (const tdesc_feature &) = delete;
-  tdesc_feature &operator= (const tdesc_feature &) = delete;
+  DISABLE_COPY_AND_ASSIGN (tdesc_feature);
 
   /* The name of this feature.  It may be recognized by the architecture
      support code.  */
@@ -846,8 +841,7 @@ tdesc_predefined_type (enum tdesc_type_kind kind)
   gdb_assert_not_reached ("bad predefined tdesc type");
 }
 
-/* Return the type associated with ID in the context of FEATURE, or
-   NULL if none.  */
+/* See arch/tdesc.h.  */
 
 struct tdesc_type *
 tdesc_named_type (const struct tdesc_feature *feature, const char *id)
@@ -1073,7 +1067,7 @@ tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
        int ix;
 
        type = arch_flags_type (gdbarch, tdesc_type->name,
-                               tdesc_type->u.u.size);
+                               tdesc_type->u.u.size * TARGET_CHAR_BIT);
        for (ix = 0;
             VEC_iterate (tdesc_type_field, tdesc_type->u.u.fields, ix, f);
             ix++)
@@ -1096,7 +1090,8 @@ tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
        int ix;
 
        type = arch_type (gdbarch, TYPE_CODE_ENUM,
-                         tdesc_type->u.u.size, tdesc_type->name);
+                         tdesc_type->u.u.size * TARGET_CHAR_BIT,
+                         tdesc_type->name);
        TYPE_UNSIGNED (type) = 1;
        for (ix = 0;
             VEC_iterate (tdesc_type_field, tdesc_type->u.u.fields, ix, f);
@@ -1566,6 +1561,8 @@ tdesc_use_registers (struct gdbarch *gdbarch,
 }
 \f
 
+/* See arch/tdesc.h.  */
+
 void
 tdesc_create_reg (struct tdesc_feature *feature, const char *name,
                  int regnum, int save_restore, const char *group,
@@ -1577,6 +1574,8 @@ tdesc_create_reg (struct tdesc_feature *feature, const char *name,
   VEC_safe_push (tdesc_reg_p, feature->registers, reg);
 }
 
+/* See arch/tdesc.h.  */
+
 struct tdesc_type *
 tdesc_create_vector (struct tdesc_feature *feature, const char *name,
                     struct tdesc_type *field_type, int count)
@@ -1590,6 +1589,8 @@ tdesc_create_vector (struct tdesc_feature *feature, const char *name,
   return type;
 }
 
+/* See arch/tdesc.h.  */
+
 struct tdesc_type *
 tdesc_create_struct (struct tdesc_feature *feature, const char *name)
 {
@@ -1599,9 +1600,7 @@ tdesc_create_struct (struct tdesc_feature *feature, const char *name)
   return type;
 }
 
-/* Set the total length of TYPE.  Structs which contain bitfields may
-   omit the reserved bits, so the end of the last field may not
-   suffice.  */
+/* See arch/tdesc.h.  */
 
 void
 tdesc_set_struct_size (struct tdesc_type *type, int size)
@@ -1611,6 +1610,8 @@ tdesc_set_struct_size (struct tdesc_type *type, int size)
   type->u.u.size = size;
 }
 
+/* See arch/tdesc.h.  */
+
 struct tdesc_type *
 tdesc_create_union (struct tdesc_feature *feature, const char *name)
 {
@@ -1620,6 +1621,8 @@ tdesc_create_union (struct tdesc_feature *feature, const char *name)
   return type;
 }
 
+/* See arch/tdesc.h.  */
+
 struct tdesc_type *
 tdesc_create_flags (struct tdesc_feature *feature, const char *name,
                    int size)
@@ -1648,7 +1651,7 @@ tdesc_create_enum (struct tdesc_feature *feature, const char *name,
   return type;
 }
 
-/* Add a new field to TYPE.  */
+/* See arch/tdesc.h.  */
 
 void
 tdesc_add_field (struct tdesc_type *type, const char *field_name,
@@ -1669,8 +1672,6 @@ tdesc_add_field (struct tdesc_type *type, const char *field_name,
   VEC_safe_push (tdesc_type_field, type->u.u.fields, &f);
 }
 
-/* Add a new typed bitfield to TYPE.  */
-
 void
 tdesc_add_typed_bitfield (struct tdesc_type *type, const char *field_name,
                          int start, int end, struct tdesc_type *field_type)
@@ -1689,9 +1690,7 @@ tdesc_add_typed_bitfield (struct tdesc_type *type, const char *field_name,
   VEC_safe_push (tdesc_type_field, type->u.u.fields, &f);
 }
 
-/* Add a new untyped bitfield to TYPE.
-   Untyped bitfields become either uint32 or uint64 depending on the size
-   of the underlying type.  */
+/* See arch/tdesc.h.  */
 
 void
 tdesc_add_bitfield (struct tdesc_type *type, const char *field_name,
@@ -1709,8 +1708,7 @@ tdesc_add_bitfield (struct tdesc_type *type, const char *field_name,
   tdesc_add_typed_bitfield (type, field_name, start, end, field_type);
 }
 
-/* A flag is just a typed(bool) single-bit bitfield.
-   This function is kept to minimize changes in generated files.  */
+/* See arch/tdesc.h.  */
 
 void
 tdesc_add_flag (struct tdesc_type *type, int start,
@@ -1745,8 +1743,11 @@ tdesc_add_enum_value (struct tdesc_type *type, int value,
   VEC_safe_push (tdesc_type_field, type->u.u.fields, &f);
 }
 
+/* See arch/tdesc.h.  */
+
 struct tdesc_feature *
-tdesc_create_feature (struct target_desc *tdesc, const char *name)
+tdesc_create_feature (struct target_desc *tdesc, const char *name,
+                     const char *xml)
 {
   struct tdesc_feature *new_feature = new tdesc_feature (name);
 
@@ -1818,6 +1819,15 @@ set_tdesc_property (struct target_desc *target_desc,
   VEC_safe_push (property_s, target_desc->properties, &new_prop);
 }
 
+/* See arch/tdesc.h.  */
+
+void
+set_tdesc_architecture (struct target_desc *target_desc,
+                       const char *name)
+{
+  set_tdesc_architecture (target_desc, bfd_scan_arch (name));
+}
+
 void
 set_tdesc_architecture (struct target_desc *target_desc,
                        const struct bfd_arch_info *arch)
@@ -1825,6 +1835,14 @@ set_tdesc_architecture (struct target_desc *target_desc,
   target_desc->arch = arch;
 }
 
+/* See arch/tdesc.h.  */
+
+void
+set_tdesc_osabi (struct target_desc *target_desc, const char *name)
+{
+  set_tdesc_osabi (target_desc, osabi_from_tdesc_string (name));
+}
+
 void
 set_tdesc_osabi (struct target_desc *target_desc, enum gdb_osabi osabi)
 {
@@ -1838,19 +1856,19 @@ static struct cmd_list_element *tdesc_unset_cmdlist;
 /* Helper functions for the CLI commands.  */
 
 static void
-set_tdesc_cmd (char *args, int from_tty)
+set_tdesc_cmd (const char *args, int from_tty)
 {
   help_list (tdesc_set_cmdlist, "set tdesc ", all_commands, gdb_stdout);
 }
 
 static void
-show_tdesc_cmd (char *args, int from_tty)
+show_tdesc_cmd (const char *args, int from_tty)
 {
   cmd_show_list (tdesc_show_cmdlist, from_tty, "");
 }
 
 static void
-unset_tdesc_cmd (char *args, int from_tty)
+unset_tdesc_cmd (const char *args, int from_tty)
 {
   help_list (tdesc_unset_cmdlist, "unset tdesc ", all_commands, gdb_stdout);
 }
@@ -1882,7 +1900,7 @@ show_tdesc_filename_cmd (struct ui_file *file, int from_tty,
 }
 
 static void
-unset_tdesc_filename_cmd (char *args, int from_tty)
+unset_tdesc_filename_cmd (const char *args, int from_tty)
 {
   xfree (target_description_filename);
   target_description_filename = NULL;
@@ -2175,7 +2193,7 @@ public:
     printf_unfiltered ("  Original: %s */\n\n",
                       lbasename (m_filename_after_features.c_str ()));
 
-    printf_unfiltered ("#include \"target-descriptions.h\"\n");
+    printf_unfiltered ("#include \"arch/tdesc.h\"\n");
     printf_unfiltered ("\n");
   }
 
@@ -2198,8 +2216,10 @@ public:
 
     printf_unfiltered ("{\n");
     printf_unfiltered ("  struct tdesc_feature *feature;\n");
-    printf_unfiltered ("\n  feature = tdesc_create_feature (result, \"%s\");\n",
-                      e->name);
+
+    printf_unfiltered
+      ("\n  feature = tdesc_create_feature (result, \"%s\", \"%s\");\n",
+       e->name, lbasename (m_filename_after_features.c_str ()));
   }
 
   void visit_post (const tdesc_feature *e) override
@@ -2269,7 +2289,7 @@ private:
 };
 
 static void
-maint_print_c_tdesc_cmd (char *args, int from_tty)
+maint_print_c_tdesc_cmd (const char *args, int from_tty)
 {
   const struct target_desc *tdesc;
   const char *filename;
@@ -2305,7 +2325,9 @@ maint_print_c_tdesc_cmd (char *args, int from_tty)
   /* Print c files for target features instead of target descriptions,
      because c files got from target features are more flexible than the
      counterparts.  */
-  if (startswith (filename_after_features.c_str (), "i386/32bit-"))
+  if (startswith (filename_after_features.c_str (), "i386/32bit-")
+      || startswith (filename_after_features.c_str (), "i386/64bit-")
+      || startswith (filename_after_features.c_str (), "i386/x32-core.xml"))
     {
       print_c_feature v (filename_after_features);
 
@@ -2341,7 +2363,7 @@ record_xml_tdesc (const char *xml_file, const struct target_desc *tdesc)
    found in the specified directory DIR.  */
 
 static void
-maintenance_check_xml_descriptions (char *dir, int from_tty)
+maintenance_check_xml_descriptions (const char *dir, int from_tty)
 {
   if (dir == NULL)
     error (_("Missing dir name"));
@@ -2363,9 +2385,6 @@ maintenance_check_xml_descriptions (char *dir, int from_tty)
                   (long) selftests::xml_tdesc.size (), failed);
 }
 
-/* Provide a prototype to silence -Wmissing-prototypes.  */
-extern initialize_file_ftype _initialize_target_descriptions;
-
 void
 _initialize_target_descriptions (void)
 {
This page took 0.027315 seconds and 4 git commands to generate.