diff options
Diffstat (limited to 'gdb/target-descriptions.c')
-rw-r--r-- | gdb/target-descriptions.c | 404 |
1 files changed, 197 insertions, 207 deletions
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index b08a185..15933b4 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -42,8 +42,10 @@ struct property { property (const std::string &key_, const std::string &value_) - : key (key_), value (value_) - {} + : key (key_), + value (value_) + { + } std::string key; std::string value; @@ -57,15 +59,14 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) class gdb_type_creator : public tdesc_element_visitor { public: + gdb_type_creator (struct gdbarch *gdbarch) : m_gdbarch (gdbarch) - {} - - type *get_type () { - return m_type; } + type *get_type () { return m_type; } + void visit (const tdesc_type_builtin *e) override { switch (e->kind) @@ -148,8 +149,8 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) return; } - internal_error ("Type \"%s\" has an unknown kind %d", - e->name.c_str (), e->kind); + internal_error ("Type \"%s\" has an unknown kind %d", e->name.c_str (), + e->kind); } void visit (const tdesc_type_vector *e) override @@ -186,8 +187,8 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) return; } - internal_error ("Type \"%s\" has an unknown kind %d", - e->name.c_str (), e->kind); + internal_error ("Type \"%s\" has an unknown kind %d", e->name.c_str (), + e->kind); } private: @@ -215,8 +216,9 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) else field_gdb_type = builtin_type (m_gdbarch)->builtin_uint32; - fld = append_composite_type_field_raw - (m_type, xstrdup (f.name.c_str ()), field_gdb_type); + fld = append_composite_type_field_raw (m_type, + xstrdup (f.name.c_str ()), + field_gdb_type); /* For little-endian, BITPOS counts from the LSB of the structure and marks the LSB of the field. For @@ -237,8 +239,7 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) { gdb_assert (f.start == -1 && f.end == -1); type *field_gdb_type = make_gdb_type (m_gdbarch, f.type); - append_composite_type_field (m_type, - xstrdup (f.name.c_str ()), + append_composite_type_field (m_type, xstrdup (f.name.c_str ()), field_gdb_type); } } @@ -254,7 +255,7 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) for (const tdesc_type_field &f : e->fields) { - type* field_gdb_type = make_gdb_type (m_gdbarch, f.type); + type *field_gdb_type = make_gdb_type (m_gdbarch, f.type); append_composite_type_field (m_type, xstrdup (f.name.c_str ()), field_gdb_type); @@ -277,8 +278,8 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) gdb_assert (f.type != NULL); type *field_gdb_type = make_gdb_type (m_gdbarch, f.type); - append_flags_type_field (m_type, f.start, bitsize, - field_gdb_type, f.name.c_str ()); + append_flags_type_field (m_type, f.start, bitsize, field_gdb_type, + f.name.c_str ()); } } @@ -320,16 +321,18 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) class tdesc_compatible_info { public: + /* Constructor. */ explicit tdesc_compatible_info (const bfd_arch_info_type *arch) : m_arch (arch) - { /* Nothing. */ } + { /* Nothing. */ + } /* Access the contained pointer. */ - const bfd_arch_info_type *arch () const - { return m_arch; } + const bfd_arch_info_type *arch () const { return m_arch; } private: + /* Architecture information looked up from the <compatible> entity within a target description. */ const bfd_arch_info_type *m_arch; @@ -339,8 +342,7 @@ private: struct target_desc : tdesc_element { - target_desc () - {} + target_desc () {} virtual ~target_desc () = default; @@ -412,8 +414,10 @@ struct target_desc : tdesc_element struct tdesc_arch_reg { tdesc_arch_reg (tdesc_reg *reg_, struct type *type_) - : reg (reg_), type (type_) - {} + : reg (reg_), + type (type_) + { + } struct tdesc_reg *reg; struct type *type; @@ -479,18 +483,19 @@ target_find_description (void) file. */ tdesc_info->tdesc = nullptr; if (!tdesc_info->filename.empty ()) - tdesc_info->tdesc = file_read_description_xml (tdesc_info->filename.data ()); + tdesc_info->tdesc + = file_read_description_xml (tdesc_info->filename.data ()); /* Next try to read the description from the current target using target objects. */ if (tdesc_info->tdesc == nullptr) - tdesc_info->tdesc = target_read_description_xml - (current_inferior ()->top_target ()); + tdesc_info->tdesc + = target_read_description_xml (current_inferior ()->top_target ()); /* If that failed try a target-specific hook. */ if (tdesc_info->tdesc == nullptr) - tdesc_info->tdesc = target_read_description - (current_inferior ()->top_target ()); + tdesc_info->tdesc + = target_read_description (current_inferior ()->top_target ()); /* If a non-NULL description was returned, then update the current architecture. */ @@ -500,7 +505,7 @@ target_find_description (void) info.target_desc = tdesc_info->tdesc; if (!gdbarch_update_p (info)) - warning (_("Architecture rejected target-supplied description")); + warning (_ ("Architecture rejected target-supplied description")); else { struct tdesc_arch_data *data; @@ -508,8 +513,8 @@ target_find_description (void) data = get_arch_data (target_gdbarch ()); if (tdesc_has_registers (tdesc_info->tdesc) && data->arch_regs.empty ()) - warning (_("Target-supplied registers are not supported " - "by the current architecture")); + warning (_ ("Target-supplied registers are not supported " + "by the current architecture")); } } @@ -534,7 +539,7 @@ target_clear_description (void) gdbarch_info info; if (!gdbarch_update_p (info)) - internal_error (_("Could not remove target-supplied description")); + internal_error (_ ("Could not remove target-supplied description")); } /* Return the global current target description. This should only be @@ -561,15 +566,13 @@ tdesc_compatible_p (const struct target_desc *target_desc, { for (const tdesc_compatible_info_up &compat : target_desc->compatible) { - if (compat->arch () == arch - || arch->compatible (arch, compat->arch ()) + if (compat->arch () == arch || arch->compatible (arch, compat->arch ()) || compat->arch ()->compatible (compat->arch (), arch)) return 1; } return 0; } - /* Direct accessors for target descriptions. */ @@ -660,8 +663,7 @@ tdesc_has_registers (const struct target_desc *target_desc) the named feature is not found. */ const struct tdesc_feature * -tdesc_find_feature (const struct target_desc *target_desc, - const char *name) +tdesc_find_feature (const struct target_desc *target_desc, const char *name) { for (const tdesc_feature_up &feature : target_desc->features) if (feature->name == name) @@ -687,9 +689,7 @@ tdesc_find_type (struct gdbarch *gdbarch, const char *id) for (const tdesc_arch_reg ® : data->arch_regs) { - if (reg.reg - && reg.reg->tdesc_type - && reg.type + if (reg.reg && reg.reg->tdesc_type && reg.type && reg.reg->tdesc_type->name == id) return reg.type; } @@ -732,8 +732,8 @@ tdesc_find_register_early (const struct tdesc_feature *feature, int tdesc_numbered_register (const struct tdesc_feature *feature, - struct tdesc_arch_data *data, - int regno, const char *name) + struct tdesc_arch_data *data, int regno, + const char *name) { struct tdesc_reg *reg = tdesc_find_register_early (feature, name); @@ -769,8 +769,8 @@ tdesc_unnumbered_register (const struct tdesc_feature *feature, int tdesc_numbered_register_choices (const struct tdesc_feature *feature, - struct tdesc_arch_data *data, - int regno, const char *const names[]) + struct tdesc_arch_data *data, int regno, + const char *const names[]) { int i; @@ -822,7 +822,7 @@ tdesc_find_register (struct gdbarch *gdbarch, int regno) { struct tdesc_arch_reg *reg = tdesc_find_arch_register (gdbarch, regno); - return reg? reg->reg : NULL; + return reg ? reg->reg : NULL; } /* Return the name of register REGNO, from the target description or @@ -852,7 +852,7 @@ struct type * tdesc_register_type (struct gdbarch *gdbarch, int regno) { struct tdesc_arch_reg *arch_reg = tdesc_find_arch_register (gdbarch, regno); - struct tdesc_reg *reg = arch_reg? arch_reg->reg : NULL; + struct tdesc_reg *reg = arch_reg ? arch_reg->reg : NULL; int num_regs = gdbarch_num_regs (gdbarch); int num_pseudo_regs = gdbarch_num_pseudo_regs (gdbarch); @@ -885,7 +885,7 @@ tdesc_register_type (struct gdbarch *gdbarch, int regno) arch_reg->type = builtin_type (gdbarch)->builtin_long_double; else { - warning (_("Register \"%s\" has an unsupported size (%d bits)"), + warning (_ ("Register \"%s\" has an unsupported size (%d bits)"), reg->name.c_str (), reg->bitsize); arch_reg->type = builtin_type (gdbarch)->builtin_double; } @@ -903,11 +903,11 @@ tdesc_register_type (struct gdbarch *gdbarch, int regno) else if (reg->bitsize == gdbarch_long_long_bit (gdbarch)) arch_reg->type = builtin_type (gdbarch)->builtin_long_long; else if (reg->bitsize == gdbarch_ptr_bit (gdbarch)) - /* A bit desperate by this point... */ + /* A bit desperate by this point... */ arch_reg->type = builtin_type (gdbarch)->builtin_data_ptr; else { - warning (_("Register \"%s\" has an unsupported size (%d bits)"), + warning (_ ("Register \"%s\" has an unsupported size (%d bits)"), reg->name.c_str (), reg->bitsize); arch_reg->type = builtin_type (gdbarch)->builtin_long; } @@ -949,9 +949,8 @@ tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno, { struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno); - if (reg != NULL && !reg->group.empty () - && (reg->group == reggroup->name ())) - return 1; + if (reg != NULL && !reg->group.empty () && (reg->group == reggroup->name ())) + return 1; if (reg != NULL && (reggroup == save_reggroup || reggroup == restore_reggroup)) @@ -1010,9 +1009,9 @@ set_tdesc_pseudo_register_type (struct gdbarch *gdbarch, } void -set_tdesc_pseudo_register_reggroup_p - (struct gdbarch *gdbarch, - gdbarch_register_reggroup_p_ftype *pseudo_reggroup_p) +set_tdesc_pseudo_register_reggroup_p ( + struct gdbarch *gdbarch, + gdbarch_register_reggroup_p_ftype *pseudo_reggroup_p) { struct tdesc_arch_data *data = get_arch_data (gdbarch); @@ -1053,9 +1052,9 @@ tdesc_use_registers (struct gdbarch *gdbarch, /* Add reggroup if its new. */ if (!reg->group.empty ()) if (reggroup_find (gdbarch, reg->group.c_str ()) == NULL) - reggroup_add (gdbarch, reggroup_gdbarch_new (gdbarch, - reg->group.c_str (), - USER_REGGROUP)); + reggroup_add (gdbarch, + reggroup_gdbarch_new (gdbarch, reg->group.c_str (), + USER_REGGROUP)); } /* Remove any registers which were assigned numbers by the @@ -1113,8 +1112,7 @@ tdesc_use_registers (struct gdbarch *gdbarch, set_gdbarch_num_regs (gdbarch, num_regs); set_gdbarch_register_name (gdbarch, tdesc_register_name); set_gdbarch_register_type (gdbarch, tdesc_register_type); - set_gdbarch_remote_register_number (gdbarch, - tdesc_remote_register_number); + set_gdbarch_remote_register_number (gdbarch, tdesc_remote_register_number); set_gdbarch_register_reggroup_p (gdbarch, tdesc_register_reggroup_p); } @@ -1158,23 +1156,22 @@ tdesc_add_compatible (struct target_desc *target_desc, for (const tdesc_compatible_info_up &compat : target_desc->compatible) if (compat->arch () == compatible) - internal_error (_("Attempted to add duplicate " - "compatible architecture \"%s\""), + internal_error (_ ("Attempted to add duplicate " + "compatible architecture \"%s\""), compatible->printable_name); - target_desc->compatible.push_back - (std::unique_ptr<tdesc_compatible_info> - (new tdesc_compatible_info (compatible))); + target_desc->compatible.push_back (std::unique_ptr<tdesc_compatible_info> ( + new tdesc_compatible_info (compatible))); } void -set_tdesc_property (struct target_desc *target_desc, - const char *key, const char *value) +set_tdesc_property (struct target_desc *target_desc, const char *key, + const char *value) { gdb_assert (key != NULL && value != NULL); if (tdesc_property (target_desc, key) != NULL) - internal_error (_("Attempted to add duplicate property \"%s\""), key); + internal_error (_ ("Attempted to add duplicate property \"%s\""), key); target_desc->properties.emplace_back (key, value); } @@ -1182,8 +1179,7 @@ set_tdesc_property (struct target_desc *target_desc, /* See gdbsupport/tdesc.h. */ void -set_tdesc_architecture (struct target_desc *target_desc, - const char *name) +set_tdesc_architecture (struct target_desc *target_desc, const char *name) { set_tdesc_architecture (target_desc, bfd_scan_arch (name)); } @@ -1208,7 +1204,6 @@ set_tdesc_osabi (struct target_desc *target_desc, enum gdb_osabi osabi) { target_desc->osabi = osabi; } - static struct cmd_list_element *tdesc_set_cmdlist, *tdesc_show_cmdlist; static struct cmd_list_element *tdesc_unset_cmdlist; @@ -1229,19 +1224,16 @@ set_tdesc_filename_cmd (const char *args, int from_tty, static void show_tdesc_filename_cmd (struct ui_file *file, int from_tty, - struct cmd_list_element *c, - const char *value) + struct cmd_list_element *c, const char *value) { value = current_inferior ()->tdesc_info.filename.data (); if (value != NULL && *value != '\0') - gdb_printf (file, - _("The target description will be read from \"%s\".\n"), + gdb_printf (file, _ ("The target description will be read from \"%s\".\n"), value); else - gdb_printf (file, - _("The target description will be " - "read from the target.\n")); + gdb_printf (file, _ ("The target description will be " + "read from the target.\n")); } static void @@ -1259,6 +1251,7 @@ unset_tdesc_filename_cmd (const char *args, int from_tty) class print_c_tdesc : public tdesc_element_visitor { public: + print_c_tdesc (std::string &filename_after_features) : m_filename_after_features (filename_after_features) { @@ -1284,10 +1277,7 @@ public: ":set ro:\n"); } - ~print_c_tdesc () - { - xfree (m_function); - } + ~print_c_tdesc () { xfree (m_function); } void visit_pre (const target_desc *e) override { @@ -1303,29 +1293,28 @@ public: gdb_printf ("static void\n"); gdb_printf ("initialize_tdesc_%s (void)\n", m_function); gdb_printf ("{\n"); - gdb_printf - (" target_desc_up result = allocate_target_description ();\n"); + gdb_printf (" target_desc_up result = allocate_target_description ();\n"); if (tdesc_architecture (e) != NULL) { - gdb_printf - (" set_tdesc_architecture (result.get (), bfd_scan_arch (\"%s\"));\n", - tdesc_architecture (e)->printable_name); + gdb_printf (" set_tdesc_architecture (result.get (), bfd_scan_arch " + "(\"%s\"));\n", + tdesc_architecture (e)->printable_name); gdb_printf ("\n"); } if (tdesc_osabi (e) > GDB_OSABI_UNKNOWN && tdesc_osabi (e) < GDB_OSABI_INVALID) { - gdb_printf - (" set_tdesc_osabi (result.get (), osabi_from_tdesc_string (\"%s\"));\n", - gdbarch_osabi_name (tdesc_osabi (e))); + gdb_printf (" set_tdesc_osabi (result.get (), " + "osabi_from_tdesc_string (\"%s\"));\n", + gdbarch_osabi_name (tdesc_osabi (e))); gdb_printf ("\n"); } for (const tdesc_compatible_info_up &compatible : e->compatible) - gdb_printf - (" tdesc_add_compatible (result.get (), bfd_scan_arch (\"%s\"));\n", - compatible->arch ()->printable_name); + gdb_printf ( + " tdesc_add_compatible (result.get (), bfd_scan_arch (\"%s\"));\n", + compatible->arch ()->printable_name); if (!e->compatible.empty ()) gdb_printf ("\n"); @@ -1339,12 +1328,12 @@ public: void visit_pre (const tdesc_feature *e) override { - gdb_printf ("\n feature = tdesc_create_feature (result.get (), \"%s\");\n", - e->name.c_str ()); + gdb_printf ( + "\n feature = tdesc_create_feature (result.get (), \"%s\");\n", + e->name.c_str ()); } - void visit_post (const tdesc_feature *e) override - {} + void visit_post (const tdesc_feature *e) override {} void visit_post (const target_desc *e) override { @@ -1354,7 +1343,7 @@ public: void visit (const tdesc_type_builtin *type) override { - error (_("C output is not supported type \"%s\"."), type->name.c_str ()); + error (_ ("C output is not supported type \"%s\"."), type->name.c_str ()); } void visit (const tdesc_type_vector *type) override @@ -1365,12 +1354,10 @@ public: m_printed_element_type = true; } - gdb_printf - (" element_type = tdesc_named_type (feature, \"%s\");\n", - type->element_type->name.c_str ()); - gdb_printf - (" tdesc_create_vector (feature, \"%s\", element_type, %d);\n", - type->name.c_str (), type->count); + gdb_printf (" element_type = tdesc_named_type (feature, \"%s\");\n", + type->element_type->name.c_str ()); + gdb_printf (" tdesc_create_vector (feature, \"%s\", element_type, %d);\n", + type->name.c_str (), type->count); gdb_printf ("\n"); } @@ -1389,18 +1376,18 @@ public: case TDESC_TYPE_FLAGS: if (type->kind == TDESC_TYPE_STRUCT) { - gdb_printf - (" type_with_fields = tdesc_create_struct (feature, \"%s\");\n", - type->name.c_str ()); + gdb_printf ( + " type_with_fields = tdesc_create_struct (feature, \"%s\");\n", + type->name.c_str ()); if (type->size != 0) - gdb_printf - (" tdesc_set_struct_size (type_with_fields, %d);\n", type->size); + gdb_printf (" tdesc_set_struct_size (type_with_fields, %d);\n", + type->size); } else { - gdb_printf - (" type_with_fields = tdesc_create_flags (feature, \"%s\", %d);\n", - type->name.c_str (), type->size); + gdb_printf (" type_with_fields = tdesc_create_flags (feature, " + "\"%s\", %d);\n", + type->name.c_str (), type->size); } for (const tdesc_type_field &f : type->fields) { @@ -1417,65 +1404,65 @@ public: if (f.type->kind == TDESC_TYPE_BOOL) { gdb_assert (f.start == f.end); - gdb_printf - (" tdesc_add_flag (type_with_fields, %d, \"%s\");\n", - f.start, f.name.c_str ()); + gdb_printf ( + " tdesc_add_flag (type_with_fields, %d, \"%s\");\n", + f.start, f.name.c_str ()); } else if ((type->size == 4 && f.type->kind == TDESC_TYPE_UINT32) || (type->size == 8 && f.type->kind == TDESC_TYPE_UINT64)) { - gdb_printf - (" tdesc_add_bitfield (type_with_fields, \"%s\", %d, %d);\n", - f.name.c_str (), f.start, f.end); + gdb_printf (" tdesc_add_bitfield (type_with_fields, " + "\"%s\", %d, %d);\n", + f.name.c_str (), f.start, f.end); } else { - printf_field_type_assignment - ("tdesc_named_type (feature, \"%s\");\n", - type_name); - gdb_printf - (" tdesc_add_typed_bitfield (type_with_fields, \"%s\"," - " %d, %d, field_type);\n", - f.name.c_str (), f.start, f.end); + printf_field_type_assignment ( + "tdesc_named_type (feature, \"%s\");\n", type_name); + gdb_printf ( + " tdesc_add_typed_bitfield (type_with_fields, \"%s\"," + " %d, %d, field_type);\n", + f.name.c_str (), f.start, f.end); } } else /* Not a bitfield. */ { gdb_assert (f.end == -1); gdb_assert (type->kind == TDESC_TYPE_STRUCT); - printf_field_type_assignment - ("tdesc_named_type (feature, \"%s\");\n", type_name); - gdb_printf - (" tdesc_add_field (type_with_fields, \"%s\", field_type);\n", - f.name.c_str ()); + printf_field_type_assignment ( + "tdesc_named_type (feature, \"%s\");\n", type_name); + gdb_printf (" tdesc_add_field (type_with_fields, \"%s\", " + "field_type);\n", + f.name.c_str ()); } } break; case TDESC_TYPE_UNION: - gdb_printf - (" type_with_fields = tdesc_create_union (feature, \"%s\");\n", - type->name.c_str ()); + gdb_printf ( + " type_with_fields = tdesc_create_union (feature, \"%s\");\n", + type->name.c_str ()); for (const tdesc_type_field &f : type->fields) { - printf_field_type_assignment - ("tdesc_named_type (feature, \"%s\");\n", f.type->name.c_str ()); - gdb_printf - (" tdesc_add_field (type_with_fields, \"%s\", field_type);\n", - f.name.c_str ()); + printf_field_type_assignment ( + "tdesc_named_type (feature, \"%s\");\n", f.type->name.c_str ()); + gdb_printf ( + " tdesc_add_field (type_with_fields, \"%s\", field_type);\n", + f.name.c_str ()); } break; case TDESC_TYPE_ENUM: - gdb_printf - (" type_with_fields = tdesc_create_enum (feature, \"%s\", %d);\n", - type->name.c_str (), type->size); + gdb_printf ( + " type_with_fields = tdesc_create_enum (feature, \"%s\", %d);\n", + type->name.c_str (), type->size); for (const tdesc_type_field &f : type->fields) - gdb_printf - (" tdesc_add_enum_value (type_with_fields, %d, \"%s\");\n", - f.start, f.name.c_str ()); + gdb_printf ( + " tdesc_add_enum_value (type_with_fields, %d, \"%s\");\n", + f.start, f.name.c_str ()); break; default: - error (_("C output is not supported type \"%s\"."), type->name.c_str ()); + error (_ ("C output is not supported type \"%s\"."), + type->name.c_str ()); } gdb_printf ("\n"); @@ -1484,8 +1471,7 @@ public: void visit (const tdesc_reg *reg) override { gdb_printf (" tdesc_create_reg (feature, \"%s\", %ld, %d, ", - reg->name.c_str (), reg->target_regnum, - reg->save_restore); + reg->name.c_str (), reg->target_regnum, reg->save_restore); if (!reg->group.empty ()) gdb_printf ("\"%s\", ", reg->group.c_str ()); else @@ -1494,6 +1480,7 @@ public: } protected: + std::string m_filename_after_features; private: @@ -1501,6 +1488,7 @@ private: /* Print an assignment to the field_type variable. Print the declaration of field_type if that has not been done yet. */ ATTRIBUTE_PRINTF (2, 3) + void printf_field_type_assignment (const char *fmt, ...) { if (!m_printed_field_type) @@ -1534,6 +1522,7 @@ private: class print_c_feature : public print_c_tdesc { public: + print_c_feature (std::string &file) : print_c_tdesc (file) { @@ -1552,8 +1541,7 @@ public: gdb_printf ("\n"); } - void visit_post (const target_desc *e) override - {} + void visit_post (const target_desc *e) override {} void visit_pre (const tdesc_feature *e) override { @@ -1572,9 +1560,8 @@ public: gdb_printf ("{\n"); gdb_printf (" struct tdesc_feature *feature;\n"); - gdb_printf - ("\n feature = tdesc_create_feature (result, \"%s\");\n", - e->name.c_str ()); + gdb_printf ("\n feature = tdesc_create_feature (result, \"%s\");\n", + e->name.c_str ()); } void visit_post (const tdesc_feature *e) override @@ -1613,11 +1600,9 @@ public: and also print the message so that it can be saved in the generated c file. */ - gdb_printf ("ERROR: \"regnum\" attribute %ld ", - reg->target_regnum); - gdb_printf ("is not the largest number (%d).\n", - m_next_regnum); - error (_("\"regnum\" attribute %ld is not the largest number (%d)."), + gdb_printf ("ERROR: \"regnum\" attribute %ld ", reg->target_regnum); + gdb_printf ("is not the largest number (%d).\n", m_next_regnum); + error (_ ("\"regnum\" attribute %ld is not the largest number (%d)."), reg->target_regnum, m_next_regnum); } @@ -1639,6 +1624,7 @@ public: } private: + /* The register number to use for the next register we see. */ int m_next_regnum = 0; }; @@ -1674,14 +1660,13 @@ static const gdb::option::option_def maint_print_c_tdesc_opt_defs[] = { maint_print_c_tdesc_opt_def { "single-feature", [] (maint_print_c_tdesc_options *opt) { return &opt->single_feature; }, - N_("Print C description of just a single feature.") - }, + N_ ("Print C description of just a single feature.") }, }; static inline gdb::option::option_def_group make_maint_print_c_tdesc_options_def_group (maint_print_c_tdesc_options *opts) { - return {{maint_print_c_tdesc_opt_defs}, opts}; + return { { maint_print_c_tdesc_opt_defs }, opts }; } /* Implement 'maintenance print c-tdesc' command. */ @@ -1694,8 +1679,9 @@ maint_print_c_tdesc_cmd (const char *args, int from_tty) maint_print_c_tdesc_options opts; auto grp = make_maint_print_c_tdesc_options_def_group (&opts); - gdb::option::process_options - (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, grp); + gdb::option::process_options (&args, + gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, + grp); if (args == NULL) { @@ -1715,7 +1701,7 @@ maint_print_c_tdesc_cmd (const char *args, int from_tty) } if (tdesc == NULL) - error (_("There is no target description to print.")); + error (_ ("There is no target description to print.")); if (filename == NULL) filename = "fetched from target"; @@ -1732,8 +1718,8 @@ maint_print_c_tdesc_cmd (const char *args, int from_tty) if (opts.single_feature) { if (tdesc->features.size () != 1) - error (_("only target descriptions with 1 feature can be used " - "with -single-feature option")); + error (_ ("only target descriptions with 1 feature can be used " + "with -single-feature option")); print_c_feature v (filename_after_features); @@ -1755,8 +1741,8 @@ maint_print_c_tdesc_cmd_completer (struct cmd_list_element *ignore, const char *text, const char *word) { auto grp = make_maint_print_c_tdesc_options_def_group (nullptr); - if (gdb::option::complete_options - (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, grp)) + if (gdb::option::complete_options ( + tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, grp)) return; word = advance_to_filename_complete_word_point (tracker, text); @@ -1785,7 +1771,7 @@ maint_print_xml_tdesc_cmd (const char *args, int from_tty) } if (tdesc == NULL) - error (_("There is no target description to print.")); + error (_ ("There is no target description to print.")); std::string buf; print_xml_feature v (&buf); @@ -1793,15 +1779,18 @@ maint_print_xml_tdesc_cmd (const char *args, int from_tty) gdb_puts (buf.c_str ()); } -namespace selftests { +namespace selftests +{ /* A reference target description, used for testing (see record_xml_tdesc). */ struct xml_test_tdesc { xml_test_tdesc (const char *name, std::unique_ptr<const target_desc> &&tdesc) - : name (name), tdesc (std::move (tdesc)) - {} + : name (name), + tdesc (std::move (tdesc)) + { + } const char *name; std::unique_ptr<const target_desc> tdesc; @@ -1816,24 +1805,25 @@ static std::vector<xml_test_tdesc> xml_tdesc; void record_xml_tdesc (const char *xml_file, const struct target_desc *tdesc) { - xml_tdesc.emplace_back (xml_file, std::unique_ptr<const target_desc> (tdesc)); + xml_tdesc.emplace_back (xml_file, + std::unique_ptr<const target_desc> (tdesc)); } #endif -} +} // namespace selftests /* Test the conversion process of a target description to/from xml: Take a target description TDESC, convert to xml, back to a description, and confirm the new tdesc is identical to the original. */ static bool -maintenance_check_tdesc_xml_convert (const target_desc *tdesc, const char *name) +maintenance_check_tdesc_xml_convert (const target_desc *tdesc, + const char *name) { const char *xml = tdesc_get_features_xml (tdesc); if (xml == nullptr || *xml != '@') { - gdb_printf (_("Could not convert description for %s to xml.\n"), - name); + gdb_printf (_ ("Could not convert description for %s to xml.\n"), name); return false; } @@ -1841,20 +1831,18 @@ maintenance_check_tdesc_xml_convert (const target_desc *tdesc, const char *name) if (tdesc_trans == nullptr) { - gdb_printf (_("Could not convert description for %s from xml.\n"), + gdb_printf (_ ("Could not convert description for %s from xml.\n"), name); return false; } else if (*tdesc != *tdesc_trans) { - gdb_printf (_("Converted description for %s does not match.\n"), - name); + gdb_printf (_ ("Converted description for %s does not match.\n"), name); return false; } return true; } - /* Check that the target descriptions created dynamically by architecture-specific code equal the descriptions created from XML files found in the specified directory DIR. */ @@ -1863,7 +1851,7 @@ static void maintenance_check_xml_descriptions (const char *dir, int from_tty) { if (dir == NULL) - error (_("Missing dir name")); + error (_ ("Missing dir name")); gdb::unique_xmalloc_ptr<char> dir1 (tilde_expand (dir)); std::string feature_dir (dir1.get ()); @@ -1872,58 +1860,58 @@ maintenance_check_xml_descriptions (const char *dir, int from_tty) for (auto const &e : selftests::xml_tdesc) { std::string tdesc_xml = (feature_dir + SLASH_STRING + e.name); - const target_desc *tdesc - = file_read_description_xml (tdesc_xml.data ()); + const target_desc *tdesc = file_read_description_xml (tdesc_xml.data ()); if (tdesc == NULL || *tdesc != *e.tdesc) { - gdb_printf ( _("Descriptions for %s do not match.\n"), e.name); + gdb_printf (_ ("Descriptions for %s do not match.\n"), e.name); failed++; } else if (!maintenance_check_tdesc_xml_convert (tdesc, e.name) - || !maintenance_check_tdesc_xml_convert (e.tdesc.get (), e.name)) + || !maintenance_check_tdesc_xml_convert (e.tdesc.get (), + e.name)) failed++; } - gdb_printf (_("Tested %lu XML files, %d failed\n"), + gdb_printf (_ ("Tested %lu XML files, %d failed\n"), (long) selftests::xml_tdesc.size (), failed); } void _initialize_target_descriptions (); + void _initialize_target_descriptions () { cmd_list_element *cmd; add_setshow_prefix_cmd ("tdesc", class_maintenance, - _("Set target description specific variables."), - _("Show target description specific variables."), - &tdesc_set_cmdlist, &tdesc_show_cmdlist, - &setlist, &showlist); + _ ("Set target description specific variables."), + _ ("Show target description specific variables."), + &tdesc_set_cmdlist, &tdesc_show_cmdlist, &setlist, + &showlist); - add_basic_prefix_cmd ("tdesc", class_maintenance, _("\ + add_basic_prefix_cmd ("tdesc", class_maintenance, _ ("\ Unset target description specific variables."), - &tdesc_unset_cmdlist, - 0 /* allow-unknown */, &unsetlist); + &tdesc_unset_cmdlist, 0 /* allow-unknown */, + &unsetlist); add_setshow_filename_cmd ("filename", class_obscure, - &tdesc_filename_cmd_string, - _("\ -Set the file to read for an XML target description."), _("\ -Show the file to read for an XML target description."), _("\ + &tdesc_filename_cmd_string, _ ("\ +Set the file to read for an XML target description."), + _ ("\ +Show the file to read for an XML target description."), + _ ("\ When set, GDB will read the target description from a local\n\ file instead of querying the remote target."), - set_tdesc_filename_cmd, - show_tdesc_filename_cmd, + set_tdesc_filename_cmd, show_tdesc_filename_cmd, &tdesc_set_cmdlist, &tdesc_show_cmdlist); - add_cmd ("filename", class_obscure, unset_tdesc_filename_cmd, _("\ + add_cmd ("filename", class_obscure, unset_tdesc_filename_cmd, _ ("\ Unset the file to read for an XML target description.\n\ When unset, GDB will read the description from the target."), &tdesc_unset_cmdlist); auto grp = make_maint_print_c_tdesc_options_def_group (nullptr); - static std::string help_text - = gdb::option::build_help (_("\ + static std::string help_text = gdb::option::build_help (_ ("\ Print the current target description as a C source file.\n\ Usage: maintenance print c-tdesc [OPTION] [FILENAME]\n\ \n\ @@ -1936,18 +1924,20 @@ FILENAME and printed as a C function.\n\ \n\ When '-single-feature' is used then the target description should\n\ contain a single feature and the generated C code will only create\n\ -that feature within an already existing target_desc object."), grp); +that feature within an already existing target_desc object."), + grp); cmd = add_cmd ("c-tdesc", class_maintenance, maint_print_c_tdesc_cmd, help_text.c_str (), &maintenanceprintlist); set_cmd_completer_handle_brkchars (cmd, maint_print_c_tdesc_cmd_completer); - cmd = add_cmd ("xml-tdesc", class_maintenance, maint_print_xml_tdesc_cmd, _("\ + cmd + = add_cmd ("xml-tdesc", class_maintenance, maint_print_xml_tdesc_cmd, _ ("\ Print the current target description as an XML file."), - &maintenanceprintlist); + &maintenanceprintlist); set_cmd_completer (cmd, filename_completer); cmd = add_cmd ("xml-descriptions", class_maintenance, - maintenance_check_xml_descriptions, _("\ + maintenance_check_xml_descriptions, _ ("\ Check equality of GDB target descriptions and XML created descriptions.\n\ Check the target descriptions created in GDB equal the descriptions\n\ created from XML files in the directory.\n\ |