struct tdesc_type : tdesc_element
{
- tdesc_type (const char *name_, enum tdesc_type_kind kind_)
- : name (xstrdup (name_)), kind (kind_)
+ tdesc_type (const std::string &name_, enum tdesc_type_kind kind_)
+ : name (name_), kind (kind_)
{
memset (&u, 0, sizeof (u));
}
default:
break;
}
- xfree ((char *) name);
}
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
- malloc-allocated string (and thus must be freed). */
- const char *name;
+ /* The name of this type. */
+ std::string name;
/* Identify the kind of this type. */
enum tdesc_type_kind kind;
bool operator== (const tdesc_type &other) const
{
- return (streq (name, other.name) && kind == other.kind);
+ return name == other.name && kind == other.kind;
}
bool operator!= (const tdesc_type &other) const
{
/* First try target-defined types. */
for (const tdesc_type_up &type : feature->types)
- if (strcmp (type->name, id) == 0)
+ if (type->name == id)
return type.get ();
/* Next try the predefined types. */
for (int ix = 0; ix < ARRAY_SIZE (tdesc_predefined_types); ix++)
- if (strcmp (tdesc_predefined_types[ix].name, id) == 0)
+ if (tdesc_predefined_types[ix].name == id)
return &tdesc_predefined_types[ix];
return NULL;
if (reg->reg
&& reg->reg->tdesc_type
&& reg->type
- && strcmp (id, reg->reg->tdesc_type->name) == 0)
+ && reg->reg->tdesc_type->name == id)
return reg->type;
}
break;
}
- type = tdesc_find_type (gdbarch, tdesc_type->name);
+ type = tdesc_find_type (gdbarch, tdesc_type->name.c_str ());
if (type)
return type;
field_type = tdesc_gdb_type (gdbarch, tdesc_type->u.v.type);
type = init_vector_type (field_type, tdesc_type->u.v.count);
- TYPE_NAME (type) = xstrdup (tdesc_type->name);
+ TYPE_NAME (type) = xstrdup (tdesc_type->name.c_str ());
return type;
}
int ix;
type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
- TYPE_NAME (type) = xstrdup (tdesc_type->name);
+ TYPE_NAME (type) = xstrdup (tdesc_type->name.c_str ());
TYPE_TAG_NAME (type) = TYPE_NAME (type);
for (ix = 0;
int ix;
type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
- TYPE_NAME (type) = xstrdup (tdesc_type->name);
+ TYPE_NAME (type) = xstrdup (tdesc_type->name.c_str ());
for (ix = 0;
VEC_iterate (tdesc_type_field, tdesc_type->u.u.fields, ix, f);
struct tdesc_type_field *f;
int ix;
- type = arch_flags_type (gdbarch, tdesc_type->name,
+ type = arch_flags_type (gdbarch, tdesc_type->name.c_str (),
tdesc_type->u.u.size * TARGET_CHAR_BIT);
for (ix = 0;
VEC_iterate (tdesc_type_field, tdesc_type->u.u.fields, ix, f);
type = arch_type (gdbarch, TYPE_CODE_ENUM,
tdesc_type->u.u.size * TARGET_CHAR_BIT,
- tdesc_type->name);
+ tdesc_type->name.c_str ());
TYPE_UNSIGNED (type) = 1;
for (ix = 0;
VEC_iterate (tdesc_type_field, tdesc_type->u.u.fields, ix, f);
internal_error (__FILE__, __LINE__,
"Type \"%s\" has an unknown kind %d",
- tdesc_type->name, tdesc_type->kind);
+ tdesc_type->name.c_str (), tdesc_type->kind);
}
\f
case TDESC_TYPE_VECTOR:
printf_unfiltered
(" field_type = tdesc_named_type (feature, \"%s\");\n",
- type->u.v.type->name);
+ type->u.v.type->name.c_str ());
printf_unfiltered
(" tdesc_create_vector (feature, \"%s\", field_type, %d);\n",
- type->name, type->u.v.count);
+ type->name.c_str (), type->u.v.count);
break;
case TDESC_TYPE_STRUCT:
case TDESC_TYPE_FLAGS:
{
printf_unfiltered
(" type = tdesc_create_struct (feature, \"%s\");\n",
- type->name);
+ type->name.c_str ());
if (type->u.u.size != 0)
printf_unfiltered
(" tdesc_set_struct_size (type, %d);\n",
{
printf_unfiltered
(" type = tdesc_create_flags (feature, \"%s\", %d);\n",
- type->name, type->u.u.size);
+ type->name.c_str (), type->u.u.size);
}
for (int ix3 = 0;
VEC_iterate (tdesc_type_field, type->u.u.fields, ix3, f);
const char *type_name;
gdb_assert (f->type != NULL);
- type_name = f->type->name;
+ type_name = f->type->name.c_str ();
/* To minimize changes to generated files, don't emit type
info for fields that have defaulted types. */
case TDESC_TYPE_UNION:
printf_unfiltered
(" type = tdesc_create_union (feature, \"%s\");\n",
- type->name);
+ type->name.c_str ());
for (int ix3 = 0;
VEC_iterate (tdesc_type_field, type->u.u.fields, ix3, f);
ix3++)
{
printf_unfiltered
(" field_type = tdesc_named_type (feature, \"%s\");\n",
- f->type->name);
+ f->type->name.c_str ());
printf_unfiltered
(" tdesc_add_field (type, \"%s\", field_type);\n",
f->name);
case TDESC_TYPE_ENUM:
printf_unfiltered
(" type = tdesc_create_enum (feature, \"%s\", %d);\n",
- type->name, type->u.u.size);
+ type->name.c_str (), type->u.u.size);
for (int ix3 = 0;
VEC_iterate (tdesc_type_field, type->u.u.fields, ix3, f);
ix3++)
f->start, f->name);
break;
default:
- error (_("C output is not supported type \"%s\"."), type->name);
+ error (_("C output is not supported type \"%s\"."), type->name.c_str ());
}
printf_unfiltered ("\n");
}