* [patch] Add support for <struct> and <flags> in target descriptions
@ 2010-02-22 16:45 Daniel Jacobowitz
2010-02-22 19:32 ` Eli Zaretskii
2010-03-01 0:15 ` H.J. Lu
0 siblings, 2 replies; 9+ messages in thread
From: Daniel Jacobowitz @ 2010-02-22 16:45 UTC (permalink / raw)
To: gdb-patches, H.J. Lu; +Cc: Eli Zaretskii
Hi H.J.,
This patch adds <flags> support to the XML language. Could you try
using this to move the two x86 flags registers from out of
target-descriptions.c?
The flags support is straightforward and covered by the manual.
It's not tested because I couldn't find a way to do so; you can't
ptype a flags register, and you can't add dummy registers whose value
you can get at, only for ptype.
The patch also adds <struct>, which is a little more interesting.
It's got two forms:
* Register containing integer bitfields. Each field must be
explicitly positioned. The size must be pre-declared - otherwise
the representation GDB uses for big-endian bitfields can't figure out
how far from the MSB edge of the register the field is.
* Register containing typed non-bitfield structures. Each field must
be implicitly positioned. There's no support for padding.
These are somewhat annoying limitations, but they suffice for
everything I've needed this for since I wrote the patch, which was
originally several years ago; it's been stuck in my submission queue
because it was tangled up with other local patches. Since they are
"must" restrictions, they are easy to lift in the future; we can make
GDB more permissive.
These I was able to type, although I'd have liked more exhaustive
tests... for that, I'd need typeof, which turns out to be annoyingly
hard to implement in GDB's parser :-(
Eli, how's the documentation?
--
Daniel Jacobowitz
CodeSourcery
2010-02-22 Daniel Jacobowitz <dan@codesourcery.com>
* gdbtypes.c (append_composite_type_field_raw): New.
(append_composite_type_field_aligned): Use the new function.
* gdbtypes.h (append_composite_type_field_raw): Declare.
* target-descriptions.c (struct tdesc_type_field): Add start and end.
(struct tdesc_type_flag): New type.
(struct tdesc_type): Add TDESC_TYPE_STRUCT and TDESC_TYPE_FLAGS to
kind. Add size to u.u. Add u.f for flags.
(tdesc_gdb_type): Handle TDESC_TYPE_STRUCT and TDESC_TYPE_FLAGS.
(tdesc_free_type): Likewise.
(tdesc_create_struct, tdesc_set_struct_size, tdesc_create_flags): New.
(tdesc_add_field): Handle TDESC_TYPE_STRUCT.
(tdesc_add_bitfield, tdesc_add_flag): New.
* target-descriptions.h (tdesc_create_struct, tdesc_set_struct_size)
(tdesc_create_flags, tdesc_add_bitfield, tdesc_add_flag): Declare.
* xml-tdesc.c (struct tdesc_parsing_data): Rename current_union to
current_type. Add current_type_size and current_type_is_flags.
(tdesc_start_union): Clear the new fields.
(tdesc_start_struct, tdesc_start_flags): New.
(tdesc_start_field): Handle struct fields, including bitfields.
(field_attributes): Make type optional. Add start and end.
(union_children): Rename to struct_union_children.
(union_attributes): Rename to struct_union_attributes. Add optional
size.
(flags_attributes): New.
(feature_children): Add struct and flags.
* features/gdb-target.dtd: Add flags and struct to features.
Make field type optional. Add field start and end.
* gdb.texinfo (Types): Describe <struct> and <flags>.
* gdb.xml/extra-regs.xml: Add struct1, struct2, and flags
types. Add structreg, bitfields, and flags registers.
* gdb.xml/tdesc-regs.exp: Test structreg and bitfields
registers.
Index: gdbtypes.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.c,v
retrieving revision 1.187
diff -u -p -r1.187 gdbtypes.c
--- gdbtypes.c 19 Feb 2010 22:22:48 -0000 1.187
+++ gdbtypes.c 22 Feb 2010 16:38:46 -0000
@@ -3303,10 +3303,11 @@ arch_composite_type (struct gdbarch *gdb
}
/* Add new field with name NAME and type FIELD to composite type T.
- ALIGNMENT (if non-zero) specifies the minimum field alignment. */
-void
-append_composite_type_field_aligned (struct type *t, char *name,
- struct type *field, int alignment)
+ Do not set the field's position or adjust the type's length;
+ the caller should do so. Return the new field. */
+struct field *
+append_composite_type_field_raw (struct type *t, char *name,
+ struct type *field)
{
struct field *f;
TYPE_NFIELDS (t) = TYPE_NFIELDS (t) + 1;
@@ -3316,6 +3317,16 @@ append_composite_type_field_aligned (str
memset (f, 0, sizeof f[0]);
FIELD_TYPE (f[0]) = field;
FIELD_NAME (f[0]) = name;
+ return f;
+}
+
+/* Add new field with name NAME and type FIELD to composite type T.
+ ALIGNMENT (if non-zero) specifies the minimum field alignment. */
+void
+append_composite_type_field_aligned (struct type *t, char *name,
+ struct type *field, int alignment)
+{
+ struct field *f = append_composite_type_field_raw (t, name, field);
if (TYPE_CODE (t) == TYPE_CODE_UNION)
{
if (TYPE_LENGTH (t) < TYPE_LENGTH (field))
Index: gdbtypes.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.h,v
retrieving revision 1.123
diff -u -p -r1.123 gdbtypes.h
--- gdbtypes.h 19 Feb 2010 22:22:48 -0000 1.123
+++ gdbtypes.h 22 Feb 2010 16:38:46 -0000
@@ -1249,6 +1249,8 @@ extern void append_composite_type_field_
char *name,
struct type *field,
int alignment);
+struct field *append_composite_type_field_raw (struct type *t, char *name,
+ struct type *field);
/* Helper functions to construct a bit flags type. An initially empty
type is created using arch_flag_type(). Flags are then added using
Index: target-descriptions.c
===================================================================
RCS file: /cvs/src/src/gdb/target-descriptions.c,v
retrieving revision 1.31
diff -u -p -r1.31 target-descriptions.c
--- target-descriptions.c 10 Feb 2010 18:45:02 -0000 1.31
+++ target-descriptions.c 22 Feb 2010 16:38:46 -0000
@@ -90,9 +90,17 @@ typedef struct tdesc_type_field
{
char *name;
struct tdesc_type *type;
+ int start, end;
} tdesc_type_field;
DEF_VEC_O(tdesc_type_field);
+typedef struct tdesc_type_flag
+{
+ char *name;
+ int start;
+} tdesc_type_flag;
+DEF_VEC_O(tdesc_type_flag);
+
typedef struct tdesc_type
{
/* The name of this type. */
@@ -123,7 +131,9 @@ typedef struct tdesc_type
/* Types defined by a target feature. */
TDESC_TYPE_VECTOR,
- TDESC_TYPE_UNION
+ TDESC_TYPE_STRUCT,
+ TDESC_TYPE_UNION,
+ TDESC_TYPE_FLAGS
} kind;
/* Kind-specific data. */
@@ -136,11 +146,19 @@ typedef struct tdesc_type
int count;
} v;
- /* Union type. */
+ /* Struct or union type. */
struct
{
VEC(tdesc_type_field) *fields;
+ LONGEST size;
} u;
+
+ /* Flags type. */
+ struct
+ {
+ VEC(tdesc_type_flag) *flags;
+ LONGEST size;
+ } f;
} u;
} *tdesc_type_p;
DEF_VEC_P(tdesc_type_p);
@@ -652,6 +670,66 @@ tdesc_gdb_type (struct gdbarch *gdbarch,
return type;
}
+ case TDESC_TYPE_STRUCT:
+ {
+ struct type *type, *field_type;
+ struct tdesc_type_field *f;
+ int ix;
+
+ type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+ TYPE_NAME (type) = xstrdup (tdesc_type->name);
+ TYPE_TAG_NAME (type) = TYPE_NAME (type);
+
+ for (ix = 0;
+ VEC_iterate (tdesc_type_field, tdesc_type->u.u.fields, ix, f);
+ ix++)
+ {
+ if (f->type == NULL)
+ {
+ /* Bitfield. */
+ struct field *fld;
+ struct type *field_type;
+ int bitsize, total_size;
+
+ /* This invariant should be preserved while creating
+ types. */
+ gdb_assert (tdesc_type->u.u.size != 0);
+ if (tdesc_type->u.u.size > 4)
+ field_type = builtin_type (gdbarch)->builtin_uint64;
+ else
+ field_type = builtin_type (gdbarch)->builtin_uint32;
+
+ fld = append_composite_type_field_raw (type, xstrdup (f->name),
+ field_type);
+
+ /* For little-endian, BITPOS counts from the LSB of
+ the structure and marks the LSB of the field. For
+ big-endian, BITPOS counts from the MSB of the
+ structure and marks the MSB of the field. Either
+ way, it is the number of bits to the "left" of the
+ field. To calculate this in big-endian, we need
+ the total size of the structure. */
+ bitsize = f->end - f->start + 1;
+ total_size = tdesc_type->u.u.size * TARGET_CHAR_BIT;
+ if (gdbarch_bits_big_endian (gdbarch))
+ FIELD_BITPOS (fld[0]) = total_size - f->start - bitsize;
+ else
+ FIELD_BITPOS (fld[0]) = f->start;
+ FIELD_BITSIZE (fld[0]) = bitsize;
+ }
+ else
+ {
+ field_type = tdesc_gdb_type (gdbarch, f->type);
+ append_composite_type_field (type, xstrdup (f->name),
+ field_type);
+ }
+ }
+
+ if (tdesc_type->u.u.size != 0)
+ TYPE_LENGTH (type) = tdesc_type->u.u.size;
+ return type;
+ }
+
case TDESC_TYPE_UNION:
{
struct type *type, *field_type;
@@ -668,12 +746,30 @@ tdesc_gdb_type (struct gdbarch *gdbarch,
field_type = tdesc_gdb_type (gdbarch, f->type);
append_composite_type_field (type, xstrdup (f->name), field_type);
- /* If any of the children of this union are vectors, flag the
+ /* If any of the children of a union are vectors, flag the
union as a vector also. This allows e.g. a union of two
vector types to show up automatically in "info vector". */
if (TYPE_VECTOR (field_type))
TYPE_VECTOR (type) = 1;
}
+ return type;
+ }
+
+ case TDESC_TYPE_FLAGS:
+ {
+ struct type *type, *field_type;
+ struct tdesc_type_flag *f;
+ int ix;
+
+ type = arch_flags_type (gdbarch, xstrdup (tdesc_type->name),
+ tdesc_type->u.f.size);
+ for (ix = 0;
+ VEC_iterate (tdesc_type_flag, tdesc_type->u.f.flags, ix, f);
+ ix++)
+ /* Note that contrary to the function name, this call will
+ just set the properties of an already-allocated
+ field. */
+ append_flags_type_flag (type, f->start, f->name);
return type;
}
@@ -1161,6 +1257,7 @@ tdesc_free_type (struct tdesc_type *type
switch (type->kind)
{
+ case TDESC_TYPE_STRUCT:
case TDESC_TYPE_UNION:
{
struct tdesc_type_field *f;
@@ -1175,6 +1272,20 @@ tdesc_free_type (struct tdesc_type *type
}
break;
+ case TDESC_TYPE_FLAGS:
+ {
+ struct tdesc_type_flag *f;
+ int ix;
+
+ for (ix = 0;
+ VEC_iterate (tdesc_type_flag, type->u.f.flags, ix, f);
+ ix++)
+ xfree (f->name);
+
+ VEC_free (tdesc_type_flag, type->u.f.flags);
+ }
+ break;
+
default:
break;
}
@@ -1199,6 +1310,29 @@ tdesc_create_vector (struct tdesc_featur
}
struct tdesc_type *
+tdesc_create_struct (struct tdesc_feature *feature, const char *name)
+{
+ struct tdesc_type *type = XZALLOC (struct tdesc_type);
+
+ type->name = xstrdup (name);
+ type->kind = TDESC_TYPE_STRUCT;
+
+ VEC_safe_push (tdesc_type_p, feature->types, type);
+ 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. */
+
+void
+tdesc_set_struct_size (struct tdesc_type *type, LONGEST size)
+{
+ gdb_assert (type->kind == TDESC_TYPE_STRUCT);
+ type->u.u.size = size;
+}
+
+struct tdesc_type *
tdesc_create_union (struct tdesc_feature *feature, const char *name)
{
struct tdesc_type *type = XZALLOC (struct tdesc_type);
@@ -1210,13 +1344,32 @@ tdesc_create_union (struct tdesc_feature
return type;
}
+struct tdesc_type *
+tdesc_create_flags (struct tdesc_feature *feature, const char *name,
+ LONGEST size)
+{
+ struct tdesc_type *type = XZALLOC (struct tdesc_type);
+
+ type->name = xstrdup (name);
+ type->kind = TDESC_TYPE_FLAGS;
+ type->u.f.size = size;
+
+ VEC_safe_push (tdesc_type_p, feature->types, type);
+ return type;
+}
+
+/* Add a new field. Return a temporary pointer to the field, which
+ is only valid until the next call to tdesc_add_field (the vector
+ might be reallocated). */
+
void
tdesc_add_field (struct tdesc_type *type, const char *field_name,
struct tdesc_type *field_type)
{
struct tdesc_type_field f = { 0 };
- gdb_assert (type->kind == TDESC_TYPE_UNION);
+ gdb_assert (type->kind == TDESC_TYPE_UNION
+ || type->kind == TDESC_TYPE_STRUCT);
f.name = xstrdup (field_name);
f.type = field_type;
@@ -1224,6 +1377,37 @@ tdesc_add_field (struct tdesc_type *type
VEC_safe_push (tdesc_type_field, type->u.u.fields, &f);
}
+/* Add a new bitfield. */
+
+void
+tdesc_add_bitfield (struct tdesc_type *type, const char *field_name,
+ int start, int end)
+{
+ struct tdesc_type_field f = { 0 };
+
+ gdb_assert (type->kind == TDESC_TYPE_STRUCT);
+
+ f.name = xstrdup (field_name);
+ f.start = start;
+ f.end = end;
+
+ VEC_safe_push (tdesc_type_field, type->u.u.fields, &f);
+}
+
+void
+tdesc_add_flag (struct tdesc_type *type, int start,
+ const char *flag_name)
+{
+ struct tdesc_type_flag f = { 0 };
+
+ gdb_assert (type->kind == TDESC_TYPE_FLAGS);
+
+ f.name = xstrdup (flag_name);
+ f.start = start;
+
+ VEC_safe_push (tdesc_type_flag, type->u.f.flags, &f);
+}
+
static void
tdesc_free_feature (struct tdesc_feature *feature)
{
Index: target-descriptions.h
===================================================================
RCS file: /cvs/src/src/gdb/target-descriptions.h,v
retrieving revision 1.18
diff -u -p -r1.18 target-descriptions.h
--- target-descriptions.h 10 Feb 2010 18:45:03 -0000 1.18
+++ target-descriptions.h 22 Feb 2010 16:38:46 -0000
@@ -205,10 +205,20 @@ struct tdesc_type *tdesc_create_vector (
const char *name,
struct tdesc_type *field_type,
int count);
+struct tdesc_type *tdesc_create_struct (struct tdesc_feature *feature,
+ const char *name);
+void tdesc_set_struct_size (struct tdesc_type *type, LONGEST size);
struct tdesc_type *tdesc_create_union (struct tdesc_feature *feature,
const char *name);
+struct tdesc_type *tdesc_create_flags (struct tdesc_feature *feature,
+ const char *name,
+ LONGEST size);
void tdesc_add_field (struct tdesc_type *type, const char *field_name,
struct tdesc_type *field_type);
+void tdesc_add_bitfield (struct tdesc_type *type, const char *field_name,
+ int start, int end);
+void tdesc_add_flag (struct tdesc_type *type, int start,
+ const char *flag_name);
void tdesc_create_reg (struct tdesc_feature *feature, const char *name,
int regnum, int save_restore, const char *group,
int bitsize, const char *type);
Index: xml-tdesc.c
===================================================================
RCS file: /cvs/src/src/gdb/xml-tdesc.c,v
retrieving revision 1.19
diff -u -p -r1.19 xml-tdesc.c
--- xml-tdesc.c 1 Jan 2010 07:31:46 -0000 1.19
+++ xml-tdesc.c 22 Feb 2010 16:38:47 -0000
@@ -85,8 +85,15 @@ struct tdesc_parsing_data
it does not have its own. This starts at zero. */
int next_regnum;
- /* The union we are currently parsing, or last parsed. */
- struct tdesc_type *current_union;
+ /* The struct or union we are currently parsing, or last parsed. */
+ struct tdesc_type *current_type;
+
+ /* The byte size of the current struct type, if specified. Zero
+ if not specified. */
+ int current_type_size;
+
+ /* Whether the current type is a flags type. */
+ int current_type_is_flags;
};
/* Handle the end of an <architecture> element and its value. */
@@ -229,11 +236,57 @@ tdesc_start_union (struct gdb_xml_parser
struct tdesc_parsing_data *data = user_data;
char *id = VEC_index (gdb_xml_value_s, attributes, 0)->value;
- data->current_union = tdesc_create_union (data->current_feature, id);
+ data->current_type = tdesc_create_union (data->current_feature, id);
+ data->current_type_size = 0;
+ data->current_type_is_flags = 0;
+}
+
+/* Handle the start of a <struct> element. Initialize the type and
+ record it with the current feature. */
+
+static void
+tdesc_start_struct (struct gdb_xml_parser *parser,
+ const struct gdb_xml_element *element,
+ void *user_data, VEC(gdb_xml_value_s) *attributes)
+{
+ struct tdesc_parsing_data *data = user_data;
+ char *id = VEC_index (gdb_xml_value_s, attributes, 0)->value;
+ struct tdesc_type *type;
+
+ type = tdesc_create_struct (data->current_feature, id);
+ data->current_type = type;
+ data->current_type_size = 0;
+ data->current_type_is_flags = 0;
+
+ if (VEC_length (gdb_xml_value_s, attributes) > 1)
+ {
+ int size = (int) * (ULONGEST *)
+ VEC_index (gdb_xml_value_s, attributes, 1)->value;
+ tdesc_set_struct_size (type, size);
+ data->current_type_size = size;
+ }
+}
+
+static void
+tdesc_start_flags (struct gdb_xml_parser *parser,
+ const struct gdb_xml_element *element,
+ void *user_data, VEC(gdb_xml_value_s) *attributes)
+{
+ struct tdesc_parsing_data *data = user_data;
+ char *id = VEC_index (gdb_xml_value_s, attributes, 0)->value;
+ int length = (int) * (ULONGEST *)
+ VEC_index (gdb_xml_value_s, attributes, 1)->value;
+ struct tdesc_type *type;
+
+ type = tdesc_create_flags (data->current_feature, id, length);
+
+ data->current_type = type;
+ data->current_type_size = 0;
+ data->current_type_is_flags = 1;
}
/* Handle the start of a <field> element. Attach the field to the
- current union. */
+ current struct or union. */
static void
tdesc_start_field (struct gdb_xml_parser *parser,
@@ -241,20 +294,84 @@ tdesc_start_field (struct gdb_xml_parser
void *user_data, VEC(gdb_xml_value_s) *attributes)
{
struct tdesc_parsing_data *data = user_data;
+ int ix = 0, length;
struct gdb_xml_value *attrs = VEC_address (gdb_xml_value_s, attributes);
struct tdesc_type *field_type;
char *field_name, *field_type_id;
+ int start, end;
- field_name = attrs[0].value;
- field_type_id = attrs[1].value;
+ length = VEC_length (gdb_xml_value_s, attributes);
- field_type = tdesc_named_type (data->current_feature, field_type_id);
- if (field_type == NULL)
- gdb_xml_error (parser, _("Union field \"%s\" references undefined "
- "type \"%s\""),
- field_name, field_type_id);
+ field_name = attrs[ix++].value;
+
+ if (ix < length && strcmp (attrs[ix].name, "type") == 0)
+ field_type_id = attrs[ix++].value;
+ else
+ field_type_id = NULL;
+
+ if (ix < length && strcmp (attrs[ix].name, "start") == 0)
+ start = * (ULONGEST *) attrs[ix++].value;
+ else
+ start = -1;
+
+ if (ix < length && strcmp (attrs[ix].name, "end") == 0)
+ end = * (ULONGEST *) attrs[ix++].value;
+ else
+ end = -1;
+
+ if (field_type_id != NULL)
+ {
+ if (data->current_type_is_flags)
+ gdb_xml_error (parser, _("Cannot add typed field \"%s\" to flags"),
+ field_name);
+ if (data->current_type_size != 0)
+ gdb_xml_error (parser,
+ _("Explicitly sized type can not contain non-bitfield \"%s\""),
+ field_name);
+
+ field_type = tdesc_named_type (data->current_feature, field_type_id);
+ if (field_type == NULL)
+ gdb_xml_error (parser, _("Field \"%s\" references undefined "
+ "type \"%s\""),
+ field_name, field_type_id);
+
+ tdesc_add_field (data->current_type, field_name, field_type);
+ }
+ else if (start != -1 && end != -1)
+ {
+ struct tdesc_type *t = data->current_type;
+
+ if (data->current_type_is_flags)
+ tdesc_add_flag (t, start, field_name);
+ else
+ {
+ if (data->current_type_size == 0)
+ gdb_xml_error (parser,
+ _("Implicitly sized type can not contain bitfield \"%s\""),
+ field_name);
+
+ if (end >= 64)
+ gdb_xml_error (parser,
+ _("Bitfield \"%s\" goes past 64 bits (unsupported)"),
+ field_name);
+
+ /* Assume that the bit numbering in XML is "lsb-zero". Most
+ architectures other than PowerPC use this ordering. In
+ the future, we can add an XML tag to indicate "msb-zero"
+ numbering. */
+ if (start > end)
+ gdb_xml_error (parser, _("Bitfield \"%s\" has start after end"),
+ field_name);
- tdesc_add_field (data->current_union, field_name, field_type);
+ if (end >= data->current_type_size * TARGET_CHAR_BIT)
+ gdb_xml_error (parser, _("Bitfield \"%s\" does not fit in struct"));
+
+ tdesc_add_bitfield (t, field_name, start, end);
+ }
+ }
+ else
+ gdb_xml_error (parser, _("Field \"%s\" has neither type nor bit position"),
+ field_name);
}
/* Handle the start of a <vector> element. Initialize the type and
@@ -287,11 +404,13 @@ tdesc_start_vector (struct gdb_xml_parse
static const struct gdb_xml_attribute field_attributes[] = {
{ "name", GDB_XML_AF_NONE, NULL, NULL },
- { "type", GDB_XML_AF_NONE, NULL, NULL },
+ { "type", GDB_XML_AF_OPTIONAL, NULL, NULL },
+ { "start", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_ulongest, NULL },
+ { "end", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_ulongest, NULL },
{ NULL, GDB_XML_AF_NONE, NULL, NULL }
};
-static const struct gdb_xml_element union_children[] = {
+static const struct gdb_xml_element struct_union_children[] = {
{ "field", field_attributes, NULL, GDB_XML_EF_REPEATABLE,
tdesc_start_field, NULL },
{ NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
@@ -308,8 +427,15 @@ static const struct gdb_xml_attribute re
{ NULL, GDB_XML_AF_NONE, NULL, NULL }
};
-static const struct gdb_xml_attribute union_attributes[] = {
+static const struct gdb_xml_attribute struct_union_attributes[] = {
{ "id", GDB_XML_AF_NONE, NULL, NULL },
+ { "size", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_ulongest, NULL},
+ { NULL, GDB_XML_AF_NONE, NULL, NULL }
+};
+
+static const struct gdb_xml_attribute flags_attributes[] = {
+ { "id", GDB_XML_AF_NONE, NULL, NULL },
+ { "size", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL},
{ NULL, GDB_XML_AF_NONE, NULL, NULL }
};
@@ -329,9 +455,15 @@ static const struct gdb_xml_element feat
{ "reg", reg_attributes, NULL,
GDB_XML_EF_OPTIONAL | GDB_XML_EF_REPEATABLE,
tdesc_start_reg, NULL },
- { "union", union_attributes, union_children,
+ { "struct", struct_union_attributes, struct_union_children,
+ GDB_XML_EF_OPTIONAL | GDB_XML_EF_REPEATABLE,
+ tdesc_start_struct, NULL },
+ { "union", struct_union_attributes, struct_union_children,
GDB_XML_EF_OPTIONAL | GDB_XML_EF_REPEATABLE,
tdesc_start_union, NULL },
+ { "flags", flags_attributes, struct_union_children,
+ GDB_XML_EF_OPTIONAL | GDB_XML_EF_REPEATABLE,
+ tdesc_start_flags, NULL },
{ "vector", vector_attributes, NULL,
GDB_XML_EF_OPTIONAL | GDB_XML_EF_REPEATABLE,
tdesc_start_vector, NULL },
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.670
diff -u -p -r1.670 gdb.texinfo
--- doc/gdb.texinfo 12 Feb 2010 21:35:54 -0000 1.670
+++ doc/gdb.texinfo 22 Feb 2010 16:38:52 -0000
@@ -32691,6 +32691,47 @@ each of which has a @var{name} and a @va
</union>
@end smallexample
+@cindex <struct>
+If a register's value is composed from several separate values, define
+it with a structure type. There are two forms of the @samp{<struct>}
+element; a @samp{<struct>} element must either contain only bitfields
+or contain no bitfields. If the structure contains only bitfields,
+its total size in bytes must be specified, each bitfield must have an
+explicit start and end, and bitfields are automatically assigned an
+integer type. The field's @var{start} should be less than or
+equal to its @var{end}, and zero represents the least significant bit.
+
+@smallexample
+<struct id="@var{id}" size="@var{size}">
+ <field name="@var{name}" start="@var{start}" end="@var{end}"/>
+ @dots{}
+</struct>
+@end smallexample
+
+If the structure contains no bitfields, then each field has an
+explicit type, and no implicit padding is added.
+
+@smallexample
+<struct id="@var{id}">
+ <field name="@var{name}" type="@var{type}"/>
+ @dots{}
+</struct>
+@end smallexample
+
+@cindex <flags>
+If a register's value is a series of single-bit flags, define it with
+a flags type. The @samp{<flags>} element has an explicit @var{size}
+and contains one or more @samp{<field>} elements. Each field has a
+@var{name}, a @var{start}, and an @var{end}. Only single-bit flags
+are supported.
+
+@smallexample
+<flags id="@var{id}" size="@var{size}">
+ <field name="@var{name}" start="@var{start}" end="@var{end}"/>
+ @dots{}
+</flags>
+@end smallexample
+
@subsection Registers
@cindex <reg>
Index: features/gdb-target.dtd
===================================================================
RCS file: /cvs/src/src/gdb/features/gdb-target.dtd,v
retrieving revision 1.10
diff -u -p -r1.10 gdb-target.dtd
--- features/gdb-target.dtd 1 Jan 2010 07:31:48 -0000 1.10
+++ features/gdb-target.dtd 22 Feb 2010 16:38:52 -0000
@@ -19,7 +19,8 @@
<!ELEMENT compatible (#PCDATA)>
-<!ELEMENT feature ((vector | union)*, reg*)>
+<!ELEMENT feature
+ ((vector | flags | struct | union )*, reg*)>
<!ATTLIST feature
name ID #REQUIRED>
@@ -39,6 +40,16 @@
type CDATA #REQUIRED
count CDATA #REQUIRED>
+<!ELEMENT flags (field+)>
+<!ATTLIST flags
+ id CDATA #REQUIRED
+ size CDATA #REQUIRED>
+
+<!ELEMENT struct (field+)>
+<!ATTLIST struct
+ id CDATA #REQUIRED
+ size CDATA #IMPLIED>
+
<!ELEMENT union (field+)>
<!ATTLIST union
id CDATA #REQUIRED>
@@ -46,7 +57,9 @@
<!ELEMENT field EMPTY>
<!ATTLIST field
name CDATA #REQUIRED
- type CDATA #REQUIRED>
+ type CDATA #IMPLIED
+ start CDATA #IMPLIED
+ end CDATA #IMPLIED>
<!ENTITY % xinclude SYSTEM "xinclude.dtd">
%xinclude;
Index: testsuite/gdb.xml/extra-regs.xml
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.xml/extra-regs.xml,v
retrieving revision 1.1
diff -u -p -r1.1 extra-regs.xml
--- testsuite/gdb.xml/extra-regs.xml 8 Feb 2007 21:00:36 -0000 1.1
+++ testsuite/gdb.xml/extra-regs.xml 22 Feb 2010 16:38:52 -0000
@@ -8,9 +8,27 @@
<field name="v2" type="v2int16"/>
</union>
+ <struct id="struct1">
+ <field name="v4" type="v4int8"/>
+ <field name="v2" type="v2int16"/>
+ </struct>
+
+ <struct id="struct2" size="8">
+ <field name="f1" start="0" end="34"/>
+ <field name="f2" start="63" end="63"/>
+ </struct>
+
+ <flags id="flags" size="4">
+ <field name="X" start="0" end="0"/>
+ <field name="Y" start="2" end="2"/>
+ </flags>
+
<reg name="extrareg" bitsize="32"/>
<reg name="uintreg" bitsize="32" type="uint32"/>
<reg name="vecreg" bitsize="32" type="v4int8"/>
<reg name="unionreg" bitsize="32" type="vecint"/>
+ <reg name="structreg" bitsize="64" type="struct1"/>
+ <reg name="bitfields" bitsize="64" type="struct2"/>
+ <reg name="flags" bitsize="32" type="flags"/>
</feature>
</target>
Index: testsuite/gdb.xml/tdesc-regs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.xml/tdesc-regs.exp,v
retrieving revision 1.11
diff -u -p -r1.11 tdesc-regs.exp
--- testsuite/gdb.xml/tdesc-regs.exp 16 Feb 2010 21:26:48 -0000 1.11
+++ testsuite/gdb.xml/tdesc-regs.exp 22 Feb 2010 16:38:52 -0000
@@ -126,6 +126,11 @@ gdb_test "ptype \$vecreg" "type = int8_t
gdb_test "ptype \$unionreg" \
"type = union {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
gdb_test "ptype \$unionreg.v4" "type = int8_t \\\[4\\\]"
+gdb_test "ptype \$structreg" \
+ "type = struct struct1 {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
+gdb_test "ptype \$structreg.v4" "type = int8_t \\\[4\\\]"
+gdb_test "ptype \$bitfields" \
+ "type = struct struct2 {\r\n *uint64_t f1 : 35;\r\n *uint64_t f2 : 1;\r\n}"
load_description "core-only.xml" ""
# The extra register from the previous description should be gone.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Add support for <struct> and <flags> in target descriptions
2010-02-22 16:45 [patch] Add support for <struct> and <flags> in target descriptions Daniel Jacobowitz
@ 2010-02-22 19:32 ` Eli Zaretskii
2010-03-01 0:15 ` H.J. Lu
1 sibling, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2010-02-22 19:32 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches, hjl.tools
> Date: Mon, 22 Feb 2010 11:45:10 -0500
> From: Daniel Jacobowitz <dan@codesourcery.com>
> Cc: Eli Zaretskii <eliz@gnu.org>
>
> Eli, how's the documentation?
It's okay. Thanks.
> +and contains one or more @samp{<field>} elements. Each field has a
^^
Two spaces, please.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Add support for <struct> and <flags> in target descriptions
2010-02-22 16:45 [patch] Add support for <struct> and <flags> in target descriptions Daniel Jacobowitz
2010-02-22 19:32 ` Eli Zaretskii
@ 2010-03-01 0:15 ` H.J. Lu
2010-03-01 0:57 ` H.J. Lu
1 sibling, 1 reply; 9+ messages in thread
From: H.J. Lu @ 2010-03-01 0:15 UTC (permalink / raw)
To: gdb-patches, H.J. Lu, Eli Zaretskii
On Mon, Feb 22, 2010 at 8:45 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> Hi H.J.,
>
> This patch adds <flags> support to the XML language. Could you try
> using this to move the two x86 flags registers from out of
> target-descriptions.c?
>
> The flags support is straightforward and covered by the manual.
> It's not tested because I couldn't find a way to do so; you can't
> ptype a flags register, and you can't add dummy registers whose value
> you can get at, only for ptype.
>
> The patch also adds <struct>, which is a little more interesting.
> It's got two forms:
>
> * Register containing integer bitfields. Each field must be
> explicitly positioned. The size must be pre-declared - otherwise
> the representation GDB uses for big-endian bitfields can't figure out
> how far from the MSB edge of the register the field is.
>
> * Register containing typed non-bitfield structures. Each field must
> be implicitly positioned. There's no support for padding.
>
> These are somewhat annoying limitations, but they suffice for
> everything I've needed this for since I wrote the patch, which was
> originally several years ago; it's been stuck in my submission queue
> because it was tangled up with other local patches. Since they are
> "must" restrictions, they are easy to lift in the future; we can make
> GDB more permissive.
>
> These I was able to type, although I'd have liked more exhaustive
> tests... for that, I'd need typeof, which turns out to be annoyingly
> hard to implement in GDB's parser :-(
>
> Eli, how's the documentation?
>
> --
> Daniel Jacobowitz
> CodeSourcery
>
> 2010-02-22 Daniel Jacobowitz <dan@codesourcery.com>
>
> * gdbtypes.c (append_composite_type_field_raw): New.
> (append_composite_type_field_aligned): Use the new function.
> * gdbtypes.h (append_composite_type_field_raw): Declare.
> * target-descriptions.c (struct tdesc_type_field): Add start and end.
> (struct tdesc_type_flag): New type.
> (struct tdesc_type): Add TDESC_TYPE_STRUCT and TDESC_TYPE_FLAGS to
> kind. Add size to u.u. Add u.f for flags.
> (tdesc_gdb_type): Handle TDESC_TYPE_STRUCT and TDESC_TYPE_FLAGS.
> (tdesc_free_type): Likewise.
> (tdesc_create_struct, tdesc_set_struct_size, tdesc_create_flags): New.
> (tdesc_add_field): Handle TDESC_TYPE_STRUCT.
> (tdesc_add_bitfield, tdesc_add_flag): New.
> * target-descriptions.h (tdesc_create_struct, tdesc_set_struct_size)
> (tdesc_create_flags, tdesc_add_bitfield, tdesc_add_flag): Declare.
> * xml-tdesc.c (struct tdesc_parsing_data): Rename current_union to
> current_type. Add current_type_size and current_type_is_flags.
> (tdesc_start_union): Clear the new fields.
> (tdesc_start_struct, tdesc_start_flags): New.
> (tdesc_start_field): Handle struct fields, including bitfields.
> (field_attributes): Make type optional. Add start and end.
> (union_children): Rename to struct_union_children.
> (union_attributes): Rename to struct_union_attributes. Add optional
> size.
> (flags_attributes): New.
> (feature_children): Add struct and flags.
> * features/gdb-target.dtd: Add flags and struct to features.
> Make field type optional. Add field start and end.
>
> * gdb.texinfo (Types): Describe <struct> and <flags>.
>
> * gdb.xml/extra-regs.xml: Add struct1, struct2, and flags
> types. Add structreg, bitfields, and flags registers.
> * gdb.xml/tdesc-regs.exp: Test structreg and bitfields
> registers.
>
It doesn't work. "case TDESC_TYPE_FLAGS:" is missing in
maint_print_c_tdesc_cmd.
--
H.J.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Add support for <struct> and <flags> in target descriptions
2010-03-01 0:15 ` H.J. Lu
@ 2010-03-01 0:57 ` H.J. Lu
2010-03-01 2:20 ` H.J. Lu
2010-03-01 2:46 ` Daniel Jacobowitz
0 siblings, 2 replies; 9+ messages in thread
From: H.J. Lu @ 2010-03-01 0:57 UTC (permalink / raw)
To: gdb-patches, Daniel Jacobowitz
[-- Attachment #1: Type: text/plain, Size: 4398 bytes --]
On Sun, Feb 28, 2010 at 4:15 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Feb 22, 2010 at 8:45 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
>> Hi H.J.,
>>
>> This patch adds <flags> support to the XML language. Could you try
>> using this to move the two x86 flags registers from out of
>> target-descriptions.c?
>>
>> The flags support is straightforward and covered by the manual.
>> It's not tested because I couldn't find a way to do so; you can't
>> ptype a flags register, and you can't add dummy registers whose value
>> you can get at, only for ptype.
>>
>> The patch also adds <struct>, which is a little more interesting.
>> It's got two forms:
>>
>> * Register containing integer bitfields. Each field must be
>> explicitly positioned. The size must be pre-declared - otherwise
>> the representation GDB uses for big-endian bitfields can't figure out
>> how far from the MSB edge of the register the field is.
>>
>> * Register containing typed non-bitfield structures. Each field must
>> be implicitly positioned. There's no support for padding.
>>
>> These are somewhat annoying limitations, but they suffice for
>> everything I've needed this for since I wrote the patch, which was
>> originally several years ago; it's been stuck in my submission queue
>> because it was tangled up with other local patches. Since they are
>> "must" restrictions, they are easy to lift in the future; we can make
>> GDB more permissive.
>>
>> These I was able to type, although I'd have liked more exhaustive
>> tests... for that, I'd need typeof, which turns out to be annoyingly
>> hard to implement in GDB's parser :-(
>>
>> Eli, how's the documentation?
>>
>> --
>> Daniel Jacobowitz
>> CodeSourcery
>>
>> 2010-02-22 Daniel Jacobowitz <dan@codesourcery.com>
>>
>> * gdbtypes.c (append_composite_type_field_raw): New.
>> (append_composite_type_field_aligned): Use the new function.
>> * gdbtypes.h (append_composite_type_field_raw): Declare.
>> * target-descriptions.c (struct tdesc_type_field): Add start and end.
>> (struct tdesc_type_flag): New type.
>> (struct tdesc_type): Add TDESC_TYPE_STRUCT and TDESC_TYPE_FLAGS to
>> kind. Add size to u.u. Add u.f for flags.
>> (tdesc_gdb_type): Handle TDESC_TYPE_STRUCT and TDESC_TYPE_FLAGS.
>> (tdesc_free_type): Likewise.
>> (tdesc_create_struct, tdesc_set_struct_size, tdesc_create_flags): New.
>> (tdesc_add_field): Handle TDESC_TYPE_STRUCT.
>> (tdesc_add_bitfield, tdesc_add_flag): New.
>> * target-descriptions.h (tdesc_create_struct, tdesc_set_struct_size)
>> (tdesc_create_flags, tdesc_add_bitfield, tdesc_add_flag): Declare.
>> * xml-tdesc.c (struct tdesc_parsing_data): Rename current_union to
>> current_type. Add current_type_size and current_type_is_flags.
>> (tdesc_start_union): Clear the new fields.
>> (tdesc_start_struct, tdesc_start_flags): New.
>> (tdesc_start_field): Handle struct fields, including bitfields.
>> (field_attributes): Make type optional. Add start and end.
>> (union_children): Rename to struct_union_children.
>> (union_attributes): Rename to struct_union_attributes. Add optional
>> size.
>> (flags_attributes): New.
>> (feature_children): Add struct and flags.
>> * features/gdb-target.dtd: Add flags and struct to features.
>> Make field type optional. Add field start and end.
>>
>> * gdb.texinfo (Types): Describe <struct> and <flags>.
>>
>> * gdb.xml/extra-regs.xml: Add struct1, struct2, and flags
>> types. Add structreg, bitfields, and flags registers.
>> * gdb.xml/tdesc-regs.exp: Test structreg and bitfields
>> registers.
>>
>
> It doesn't work. "case TDESC_TYPE_FLAGS:" is missing in
> maint_print_c_tdesc_cmd.
>
>
This patch makes it to work. However, there is no equivalent of
append_flags_type_flag (type, 1, NULL);
I have
<flags id="i386_eflags" size="4">
<field name="CF" start="0" end="0"/>
<field name="" start="1" end="1"/>
<field name="PF" start="2" end="2"/>
....
I got
(gdb) p $eflags
$1 = [ PF ZF IF ]
^ extra white space
(gdb)
instead of
(gdb) p $eflags
$1 = [ PF ZF IF ]
(gdb)
--
H.J.
[-- Attachment #2: gdb-flag-1.patch --]
[-- Type: text/plain, Size: 2730 bytes --]
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 77dd37b..af87633 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -126,7 +126,6 @@ typedef struct tdesc_type
TDESC_TYPE_IEEE_DOUBLE,
TDESC_TYPE_ARM_FPA_EXT,
TDESC_TYPE_I387_EXT,
- TDESC_TYPE_I386_EFLAGS,
TDESC_TYPE_I386_MXCSR,
/* Types defined by a target feature. */
@@ -484,7 +483,6 @@ static struct tdesc_type tdesc_predefined_types[] =
{ "ieee_double", TDESC_TYPE_IEEE_DOUBLE },
{ "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT },
{ "i387_ext", TDESC_TYPE_I387_EXT },
- { "i386_eflags", TDESC_TYPE_I386_EFLAGS },
{ "i386_mxcsr", TDESC_TYPE_I386_MXCSR }
};
@@ -607,33 +605,6 @@ tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
return arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
floatformats_i387_ext);
- case TDESC_TYPE_I386_EFLAGS:
- {
- struct type *type;
-
- type = arch_flags_type (gdbarch, "builtin_type_i386_eflags", 4);
- append_flags_type_flag (type, 0, "CF");
- append_flags_type_flag (type, 1, NULL);
- append_flags_type_flag (type, 2, "PF");
- append_flags_type_flag (type, 4, "AF");
- append_flags_type_flag (type, 6, "ZF");
- append_flags_type_flag (type, 7, "SF");
- append_flags_type_flag (type, 8, "TF");
- append_flags_type_flag (type, 9, "IF");
- append_flags_type_flag (type, 10, "DF");
- append_flags_type_flag (type, 11, "OF");
- append_flags_type_flag (type, 14, "NT");
- append_flags_type_flag (type, 16, "RF");
- append_flags_type_flag (type, 17, "VM");
- append_flags_type_flag (type, 18, "AC");
- append_flags_type_flag (type, 19, "VIF");
- append_flags_type_flag (type, 20, "VIP");
- append_flags_type_flag (type, 21, "ID");
-
- return type;
- }
- break;
-
case TDESC_TYPE_I386_MXCSR:
{
struct type *type;
@@ -1602,6 +1573,7 @@ maint_print_c_tdesc_cmd (char *args, int from_tty)
struct tdesc_reg *reg;
struct tdesc_type *type;
struct tdesc_type_field *f;
+ struct tdesc_type_flag *flag;
int ix, ix2, ix3;
/* Use the global target-supplied description, not the current
@@ -1715,6 +1687,18 @@ maint_print_c_tdesc_cmd (char *args, int from_tty)
f->name);
}
break;
+ case TDESC_TYPE_FLAGS:
+ printf_unfiltered
+ (" field_type = tdesc_create_flags (feature, \"%s\", %d);\n",
+ type->name, (int) type->u.f.size);
+ for (ix3 = 0;
+ VEC_iterate (tdesc_type_flag, type->u.f.flags, ix3,
+ flag);
+ ix3++)
+ printf_unfiltered
+ (" tdesc_add_flag (field_type, %d, \"%s\");\n",
+ flag->start, flag->name);
+ break;
default:
error (_("C output is not supported type \"%s\"."), type->name);
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Add support for <struct> and <flags> in target descriptions
2010-03-01 0:57 ` H.J. Lu
@ 2010-03-01 2:20 ` H.J. Lu
2010-03-01 17:20 ` Daniel Jacobowitz
2010-03-01 2:46 ` Daniel Jacobowitz
1 sibling, 1 reply; 9+ messages in thread
From: H.J. Lu @ 2010-03-01 2:20 UTC (permalink / raw)
To: gdb-patches, Daniel Jacobowitz
[-- Attachment #1: Type: text/plain, Size: 4650 bytes --]
On Sun, Feb 28, 2010 at 4:56 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sun, Feb 28, 2010 at 4:15 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Mon, Feb 22, 2010 at 8:45 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
>>> Hi H.J.,
>>>
>>> This patch adds <flags> support to the XML language. Could you try
>>> using this to move the two x86 flags registers from out of
>>> target-descriptions.c?
>>>
>>> The flags support is straightforward and covered by the manual.
>>> It's not tested because I couldn't find a way to do so; you can't
>>> ptype a flags register, and you can't add dummy registers whose value
>>> you can get at, only for ptype.
>>>
>>> The patch also adds <struct>, which is a little more interesting.
>>> It's got two forms:
>>>
>>> * Register containing integer bitfields. Each field must be
>>> explicitly positioned. The size must be pre-declared - otherwise
>>> the representation GDB uses for big-endian bitfields can't figure out
>>> how far from the MSB edge of the register the field is.
>>>
>>> * Register containing typed non-bitfield structures. Each field must
>>> be implicitly positioned. There's no support for padding.
>>>
>>> These are somewhat annoying limitations, but they suffice for
>>> everything I've needed this for since I wrote the patch, which was
>>> originally several years ago; it's been stuck in my submission queue
>>> because it was tangled up with other local patches. Since they are
>>> "must" restrictions, they are easy to lift in the future; we can make
>>> GDB more permissive.
>>>
>>> These I was able to type, although I'd have liked more exhaustive
>>> tests... for that, I'd need typeof, which turns out to be annoyingly
>>> hard to implement in GDB's parser :-(
>>>
>>> Eli, how's the documentation?
>>>
>>> --
>>> Daniel Jacobowitz
>>> CodeSourcery
>>>
>>> 2010-02-22 Daniel Jacobowitz <dan@codesourcery.com>
>>>
>>> * gdbtypes.c (append_composite_type_field_raw): New.
>>> (append_composite_type_field_aligned): Use the new function.
>>> * gdbtypes.h (append_composite_type_field_raw): Declare.
>>> * target-descriptions.c (struct tdesc_type_field): Add start and end.
>>> (struct tdesc_type_flag): New type.
>>> (struct tdesc_type): Add TDESC_TYPE_STRUCT and TDESC_TYPE_FLAGS to
>>> kind. Add size to u.u. Add u.f for flags.
>>> (tdesc_gdb_type): Handle TDESC_TYPE_STRUCT and TDESC_TYPE_FLAGS.
>>> (tdesc_free_type): Likewise.
>>> (tdesc_create_struct, tdesc_set_struct_size, tdesc_create_flags): New.
>>> (tdesc_add_field): Handle TDESC_TYPE_STRUCT.
>>> (tdesc_add_bitfield, tdesc_add_flag): New.
>>> * target-descriptions.h (tdesc_create_struct, tdesc_set_struct_size)
>>> (tdesc_create_flags, tdesc_add_bitfield, tdesc_add_flag): Declare.
>>> * xml-tdesc.c (struct tdesc_parsing_data): Rename current_union to
>>> current_type. Add current_type_size and current_type_is_flags.
>>> (tdesc_start_union): Clear the new fields.
>>> (tdesc_start_struct, tdesc_start_flags): New.
>>> (tdesc_start_field): Handle struct fields, including bitfields.
>>> (field_attributes): Make type optional. Add start and end.
>>> (union_children): Rename to struct_union_children.
>>> (union_attributes): Rename to struct_union_attributes. Add optional
>>> size.
>>> (flags_attributes): New.
>>> (feature_children): Add struct and flags.
>>> * features/gdb-target.dtd: Add flags and struct to features.
>>> Make field type optional. Add field start and end.
>>>
>>> * gdb.texinfo (Types): Describe <struct> and <flags>.
>>>
>>> * gdb.xml/extra-regs.xml: Add struct1, struct2, and flags
>>> types. Add structreg, bitfields, and flags registers.
>>> * gdb.xml/tdesc-regs.exp: Test structreg and bitfields
>>> registers.
>>>
>>
>> It doesn't work. "case TDESC_TYPE_FLAGS:" is missing in
>> maint_print_c_tdesc_cmd.
>>
>>
>
> This patch makes it to work. However, there is no equivalent of
>
> append_flags_type_flag (type, 1, NULL);
>
> I have
>
> <flags id="i386_eflags" size="4">
> <field name="CF" start="0" end="0"/>
> <field name="" start="1" end="1"/>
> <field name="PF" start="2" end="2"/>
> ....
>
> I got
>
> (gdb) p $eflags
> $1 = [ PF ZF IF ]
> ^ extra white space
> (gdb)
>
> instead of
> (gdb) p $eflags
> $1 = [ PF ZF IF ]
> (gdb)
>
Hi Daniel,
This patch on top of yours works.
Thanks.
--
H.J.
[-- Attachment #2: gdb-flag-2.patch --]
[-- Type: text/plain, Size: 18608 bytes --]
2010-02-28 H.J. Lu <hongjiu.lu@intel.com>
* target-descriptions.c (tdesc_type): Remove
TDESC_TYPE_I386_EFLAGS and TDESC_TYPE_I386_MXCSR.
(tdesc_predefined_types): Likewise.
(tdesc_gdb_type): Likewise. Pass NULL to append_flags_type_flag
if flag name is empty.
(maint_print_c_tdesc_cmd): Handle TDESC_TYPE_FLAGS.
* features/i386/32bit-core.xml: Define i386_eflags.
* features/i386/64bit-core.xml: Likewise.
* features/i386/32bit-sse.xml: Define i386_mxcsr.
* features/i386/64bit-sse.xml: Likewise.
* features/i386/amd64-linux.c: Regenerated.
* features/i386/amd64.c: Likewise.
* features/i386/i386-linux.c: Likewise.
* features/i386/i386.c: Likewise.
diff --git a/gdb/features/i386/32bit-core.xml b/gdb/features/i386/32bit-core.xml
index b047074..4d0377e 100644
--- a/gdb/features/i386/32bit-core.xml
+++ b/gdb/features/i386/32bit-core.xml
@@ -7,6 +7,26 @@
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.i386.core">
+ <flags id="i386_eflags" size="4">
+ <field name="CF" start="0" end="0"/>
+ <field name="" start="1" end="1"/>
+ <field name="PF" start="2" end="2"/>
+ <field name="AF" start="4" end="4"/>
+ <field name="ZF" start="6" end="6"/>
+ <field name="SF" start="7" end="7"/>
+ <field name="TF" start="8" end="8"/>
+ <field name="IF" start="9" end="9"/>
+ <field name="DF" start="10" end="10"/>
+ <field name="OF" start="11" end="11"/>
+ <field name="NT" start="14" end="14"/>
+ <field name="RF" start="16" end="16"/>
+ <field name="VM" start="17" end="17"/>
+ <field name="AC" start="18" end="18"/>
+ <field name="VIF" start="19" end="19"/>
+ <field name="VIP" start="20" end="20"/>
+ <field name="ID" start="21" end="21"/>
+ </flags>
+
<reg name="eax" bitsize="32" type="int32"/>
<reg name="ecx" bitsize="32" type="int32"/>
<reg name="edx" bitsize="32" type="int32"/>
diff --git a/gdb/features/i386/32bit-sse.xml b/gdb/features/i386/32bit-sse.xml
index e849b8d..cca94b3 100644
--- a/gdb/features/i386/32bit-sse.xml
+++ b/gdb/features/i386/32bit-sse.xml
@@ -22,6 +22,22 @@
<field name="v2_int64" type="v2i64"/>
<field name="uint128" type="uint128"/>
</union>
+ <flags id="i386_mxcsr" size="4">
+ <field name="IE" start="0" end="0"/>
+ <field name="DE" start="1" end="1"/>
+ <field name="ZE" start="2" end="2"/>
+ <field name="OE" start="3" end="3"/>
+ <field name="UE" start="4" end="4"/>
+ <field name="PE" start="5" end="5"/>
+ <field name="DAZ" start="6" end="6"/>
+ <field name="IM" start="7" end="7"/>
+ <field name="DM" start="8" end="8"/>
+ <field name="ZM" start="9" end="9"/>
+ <field name="OM" start="10" end="10"/>
+ <field name="UM" start="11" end="11"/>
+ <field name="PM" start="12" end="12"/>
+ <field name="FZ" start="15" end="15"/>
+ </flags>
<reg name="xmm0" bitsize="128" type="vec128" regnum="32"/>
<reg name="xmm1" bitsize="128" type="vec128"/>
diff --git a/gdb/features/i386/64bit-core.xml b/gdb/features/i386/64bit-core.xml
index ae41cf2..8cfe3fe 100644
--- a/gdb/features/i386/64bit-core.xml
+++ b/gdb/features/i386/64bit-core.xml
@@ -7,6 +7,26 @@
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.i386.core">
+ <flags id="i386_eflags" size="4">
+ <field name="CF" start="0" end="0"/>
+ <field name="" start="1" end="1"/>
+ <field name="PF" start="2" end="2"/>
+ <field name="AF" start="4" end="4"/>
+ <field name="ZF" start="6" end="6"/>
+ <field name="SF" start="7" end="7"/>
+ <field name="TF" start="8" end="8"/>
+ <field name="IF" start="9" end="9"/>
+ <field name="DF" start="10" end="10"/>
+ <field name="OF" start="11" end="11"/>
+ <field name="NT" start="14" end="14"/>
+ <field name="RF" start="16" end="16"/>
+ <field name="VM" start="17" end="17"/>
+ <field name="AC" start="18" end="18"/>
+ <field name="VIF" start="19" end="19"/>
+ <field name="VIP" start="20" end="20"/>
+ <field name="ID" start="21" end="21"/>
+ </flags>
+
<reg name="rax" bitsize="64" type="int64"/>
<reg name="rbx" bitsize="64" type="int64"/>
<reg name="rcx" bitsize="64" type="int64"/>
diff --git a/gdb/features/i386/64bit-sse.xml b/gdb/features/i386/64bit-sse.xml
index a71fe78..d7f7925 100644
--- a/gdb/features/i386/64bit-sse.xml
+++ b/gdb/features/i386/64bit-sse.xml
@@ -22,6 +22,22 @@
<field name="v2_int64" type="v2i64"/>
<field name="uint128" type="uint128"/>
</union>
+ <flags id="i386_mxcsr" size="4">
+ <field name="IE" start="0" end="0"/>
+ <field name="DE" start="1" end="1"/>
+ <field name="ZE" start="2" end="2"/>
+ <field name="OE" start="3" end="3"/>
+ <field name="UE" start="4" end="4"/>
+ <field name="PE" start="5" end="5"/>
+ <field name="DAZ" start="6" end="6"/>
+ <field name="IM" start="7" end="7"/>
+ <field name="DM" start="8" end="8"/>
+ <field name="ZM" start="9" end="9"/>
+ <field name="OM" start="10" end="10"/>
+ <field name="UM" start="11" end="11"/>
+ <field name="PM" start="12" end="12"/>
+ <field name="FZ" start="15" end="15"/>
+ </flags>
<reg name="xmm0" bitsize="128" type="vec128" regnum="40"/>
<reg name="xmm1" bitsize="128" type="vec128"/>
diff --git a/gdb/features/i386/amd64-linux.c b/gdb/features/i386/amd64-linux.c
index 64a29ce..71efcbe 100644
--- a/gdb/features/i386/amd64-linux.c
+++ b/gdb/features/i386/amd64-linux.c
@@ -17,6 +17,25 @@ initialize_tdesc_amd64_linux (void)
set_tdesc_osabi (result, osabi_from_tdesc_string ("GNU/Linux"));
feature = tdesc_create_feature (result, "org.gnu.gdb.i386.core");
+ field_type = tdesc_create_flags (feature, "i386_eflags", 4);
+ tdesc_add_flag (field_type, 0, "CF");
+ tdesc_add_flag (field_type, 1, "");
+ tdesc_add_flag (field_type, 2, "PF");
+ tdesc_add_flag (field_type, 4, "AF");
+ tdesc_add_flag (field_type, 6, "ZF");
+ tdesc_add_flag (field_type, 7, "SF");
+ tdesc_add_flag (field_type, 8, "TF");
+ tdesc_add_flag (field_type, 9, "IF");
+ tdesc_add_flag (field_type, 10, "DF");
+ tdesc_add_flag (field_type, 11, "OF");
+ tdesc_add_flag (field_type, 14, "NT");
+ tdesc_add_flag (field_type, 16, "RF");
+ tdesc_add_flag (field_type, 17, "VM");
+ tdesc_add_flag (field_type, 18, "AC");
+ tdesc_add_flag (field_type, 19, "VIF");
+ tdesc_add_flag (field_type, 20, "VIP");
+ tdesc_add_flag (field_type, 21, "ID");
+
tdesc_create_reg (feature, "rax", 0, 1, NULL, 64, "int64");
tdesc_create_reg (feature, "rbx", 1, 1, NULL, 64, "int64");
tdesc_create_reg (feature, "rcx", 2, 1, NULL, 64, "int64");
@@ -93,6 +112,22 @@ initialize_tdesc_amd64_linux (void)
field_type = tdesc_named_type (feature, "uint128");
tdesc_add_field (type, "uint128", field_type);
+ field_type = tdesc_create_flags (feature, "i386_mxcsr", 4);
+ tdesc_add_flag (field_type, 0, "IE");
+ tdesc_add_flag (field_type, 1, "DE");
+ tdesc_add_flag (field_type, 2, "ZE");
+ tdesc_add_flag (field_type, 3, "OE");
+ tdesc_add_flag (field_type, 4, "UE");
+ tdesc_add_flag (field_type, 5, "PE");
+ tdesc_add_flag (field_type, 6, "DAZ");
+ tdesc_add_flag (field_type, 7, "IM");
+ tdesc_add_flag (field_type, 8, "DM");
+ tdesc_add_flag (field_type, 9, "ZM");
+ tdesc_add_flag (field_type, 10, "OM");
+ tdesc_add_flag (field_type, 11, "UM");
+ tdesc_add_flag (field_type, 12, "PM");
+ tdesc_add_flag (field_type, 15, "FZ");
+
tdesc_create_reg (feature, "xmm0", 40, 1, NULL, 128, "vec128");
tdesc_create_reg (feature, "xmm1", 41, 1, NULL, 128, "vec128");
tdesc_create_reg (feature, "xmm2", 42, 1, NULL, 128, "vec128");
diff --git a/gdb/features/i386/amd64.c b/gdb/features/i386/amd64.c
index af7b729..154e8df 100644
--- a/gdb/features/i386/amd64.c
+++ b/gdb/features/i386/amd64.c
@@ -15,6 +15,25 @@ initialize_tdesc_amd64 (void)
set_tdesc_architecture (result, bfd_scan_arch ("i386:x86-64"));
feature = tdesc_create_feature (result, "org.gnu.gdb.i386.core");
+ field_type = tdesc_create_flags (feature, "i386_eflags", 4);
+ tdesc_add_flag (field_type, 0, "CF");
+ tdesc_add_flag (field_type, 1, "");
+ tdesc_add_flag (field_type, 2, "PF");
+ tdesc_add_flag (field_type, 4, "AF");
+ tdesc_add_flag (field_type, 6, "ZF");
+ tdesc_add_flag (field_type, 7, "SF");
+ tdesc_add_flag (field_type, 8, "TF");
+ tdesc_add_flag (field_type, 9, "IF");
+ tdesc_add_flag (field_type, 10, "DF");
+ tdesc_add_flag (field_type, 11, "OF");
+ tdesc_add_flag (field_type, 14, "NT");
+ tdesc_add_flag (field_type, 16, "RF");
+ tdesc_add_flag (field_type, 17, "VM");
+ tdesc_add_flag (field_type, 18, "AC");
+ tdesc_add_flag (field_type, 19, "VIF");
+ tdesc_add_flag (field_type, 20, "VIP");
+ tdesc_add_flag (field_type, 21, "ID");
+
tdesc_create_reg (feature, "rax", 0, 1, NULL, 64, "int64");
tdesc_create_reg (feature, "rbx", 1, 1, NULL, 64, "int64");
tdesc_create_reg (feature, "rcx", 2, 1, NULL, 64, "int64");
@@ -91,6 +110,22 @@ initialize_tdesc_amd64 (void)
field_type = tdesc_named_type (feature, "uint128");
tdesc_add_field (type, "uint128", field_type);
+ field_type = tdesc_create_flags (feature, "i386_mxcsr", 4);
+ tdesc_add_flag (field_type, 0, "IE");
+ tdesc_add_flag (field_type, 1, "DE");
+ tdesc_add_flag (field_type, 2, "ZE");
+ tdesc_add_flag (field_type, 3, "OE");
+ tdesc_add_flag (field_type, 4, "UE");
+ tdesc_add_flag (field_type, 5, "PE");
+ tdesc_add_flag (field_type, 6, "DAZ");
+ tdesc_add_flag (field_type, 7, "IM");
+ tdesc_add_flag (field_type, 8, "DM");
+ tdesc_add_flag (field_type, 9, "ZM");
+ tdesc_add_flag (field_type, 10, "OM");
+ tdesc_add_flag (field_type, 11, "UM");
+ tdesc_add_flag (field_type, 12, "PM");
+ tdesc_add_flag (field_type, 15, "FZ");
+
tdesc_create_reg (feature, "xmm0", 40, 1, NULL, 128, "vec128");
tdesc_create_reg (feature, "xmm1", 41, 1, NULL, 128, "vec128");
tdesc_create_reg (feature, "xmm2", 42, 1, NULL, 128, "vec128");
diff --git a/gdb/features/i386/i386-linux.c b/gdb/features/i386/i386-linux.c
index 37447bd..cc1fb99 100644
--- a/gdb/features/i386/i386-linux.c
+++ b/gdb/features/i386/i386-linux.c
@@ -17,6 +17,25 @@ initialize_tdesc_i386_linux (void)
set_tdesc_osabi (result, osabi_from_tdesc_string ("GNU/Linux"));
feature = tdesc_create_feature (result, "org.gnu.gdb.i386.core");
+ field_type = tdesc_create_flags (feature, "i386_eflags", 4);
+ tdesc_add_flag (field_type, 0, "CF");
+ tdesc_add_flag (field_type, 1, "");
+ tdesc_add_flag (field_type, 2, "PF");
+ tdesc_add_flag (field_type, 4, "AF");
+ tdesc_add_flag (field_type, 6, "ZF");
+ tdesc_add_flag (field_type, 7, "SF");
+ tdesc_add_flag (field_type, 8, "TF");
+ tdesc_add_flag (field_type, 9, "IF");
+ tdesc_add_flag (field_type, 10, "DF");
+ tdesc_add_flag (field_type, 11, "OF");
+ tdesc_add_flag (field_type, 14, "NT");
+ tdesc_add_flag (field_type, 16, "RF");
+ tdesc_add_flag (field_type, 17, "VM");
+ tdesc_add_flag (field_type, 18, "AC");
+ tdesc_add_flag (field_type, 19, "VIF");
+ tdesc_add_flag (field_type, 20, "VIP");
+ tdesc_add_flag (field_type, 21, "ID");
+
tdesc_create_reg (feature, "eax", 0, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "ecx", 1, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "edx", 2, 1, NULL, 32, "int32");
@@ -88,6 +107,22 @@ initialize_tdesc_i386_linux (void)
field_type = tdesc_named_type (feature, "uint128");
tdesc_add_field (type, "uint128", field_type);
+ field_type = tdesc_create_flags (feature, "i386_mxcsr", 4);
+ tdesc_add_flag (field_type, 0, "IE");
+ tdesc_add_flag (field_type, 1, "DE");
+ tdesc_add_flag (field_type, 2, "ZE");
+ tdesc_add_flag (field_type, 3, "OE");
+ tdesc_add_flag (field_type, 4, "UE");
+ tdesc_add_flag (field_type, 5, "PE");
+ tdesc_add_flag (field_type, 6, "DAZ");
+ tdesc_add_flag (field_type, 7, "IM");
+ tdesc_add_flag (field_type, 8, "DM");
+ tdesc_add_flag (field_type, 9, "ZM");
+ tdesc_add_flag (field_type, 10, "OM");
+ tdesc_add_flag (field_type, 11, "UM");
+ tdesc_add_flag (field_type, 12, "PM");
+ tdesc_add_flag (field_type, 15, "FZ");
+
tdesc_create_reg (feature, "xmm0", 32, 1, NULL, 128, "vec128");
tdesc_create_reg (feature, "xmm1", 33, 1, NULL, 128, "vec128");
tdesc_create_reg (feature, "xmm2", 34, 1, NULL, 128, "vec128");
diff --git a/gdb/features/i386/i386.c b/gdb/features/i386/i386.c
index 5ac9ad9..7f7beb3 100644
--- a/gdb/features/i386/i386.c
+++ b/gdb/features/i386/i386.c
@@ -15,6 +15,25 @@ initialize_tdesc_i386 (void)
set_tdesc_architecture (result, bfd_scan_arch ("i386"));
feature = tdesc_create_feature (result, "org.gnu.gdb.i386.core");
+ field_type = tdesc_create_flags (feature, "i386_eflags", 4);
+ tdesc_add_flag (field_type, 0, "CF");
+ tdesc_add_flag (field_type, 1, "");
+ tdesc_add_flag (field_type, 2, "PF");
+ tdesc_add_flag (field_type, 4, "AF");
+ tdesc_add_flag (field_type, 6, "ZF");
+ tdesc_add_flag (field_type, 7, "SF");
+ tdesc_add_flag (field_type, 8, "TF");
+ tdesc_add_flag (field_type, 9, "IF");
+ tdesc_add_flag (field_type, 10, "DF");
+ tdesc_add_flag (field_type, 11, "OF");
+ tdesc_add_flag (field_type, 14, "NT");
+ tdesc_add_flag (field_type, 16, "RF");
+ tdesc_add_flag (field_type, 17, "VM");
+ tdesc_add_flag (field_type, 18, "AC");
+ tdesc_add_flag (field_type, 19, "VIF");
+ tdesc_add_flag (field_type, 20, "VIP");
+ tdesc_add_flag (field_type, 21, "ID");
+
tdesc_create_reg (feature, "eax", 0, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "ecx", 1, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "edx", 2, 1, NULL, 32, "int32");
@@ -83,6 +102,22 @@ initialize_tdesc_i386 (void)
field_type = tdesc_named_type (feature, "uint128");
tdesc_add_field (type, "uint128", field_type);
+ field_type = tdesc_create_flags (feature, "i386_mxcsr", 4);
+ tdesc_add_flag (field_type, 0, "IE");
+ tdesc_add_flag (field_type, 1, "DE");
+ tdesc_add_flag (field_type, 2, "ZE");
+ tdesc_add_flag (field_type, 3, "OE");
+ tdesc_add_flag (field_type, 4, "UE");
+ tdesc_add_flag (field_type, 5, "PE");
+ tdesc_add_flag (field_type, 6, "DAZ");
+ tdesc_add_flag (field_type, 7, "IM");
+ tdesc_add_flag (field_type, 8, "DM");
+ tdesc_add_flag (field_type, 9, "ZM");
+ tdesc_add_flag (field_type, 10, "OM");
+ tdesc_add_flag (field_type, 11, "UM");
+ tdesc_add_flag (field_type, 12, "PM");
+ tdesc_add_flag (field_type, 15, "FZ");
+
tdesc_create_reg (feature, "xmm0", 32, 1, NULL, 128, "vec128");
tdesc_create_reg (feature, "xmm1", 33, 1, NULL, 128, "vec128");
tdesc_create_reg (feature, "xmm2", 34, 1, NULL, 128, "vec128");
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 77dd37b..86adc9d 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -126,8 +126,6 @@ typedef struct tdesc_type
TDESC_TYPE_IEEE_DOUBLE,
TDESC_TYPE_ARM_FPA_EXT,
TDESC_TYPE_I387_EXT,
- TDESC_TYPE_I386_EFLAGS,
- TDESC_TYPE_I386_MXCSR,
/* Types defined by a target feature. */
TDESC_TYPE_VECTOR,
@@ -483,9 +481,7 @@ static struct tdesc_type tdesc_predefined_types[] =
{ "ieee_single", TDESC_TYPE_IEEE_SINGLE },
{ "ieee_double", TDESC_TYPE_IEEE_DOUBLE },
{ "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT },
- { "i387_ext", TDESC_TYPE_I387_EXT },
- { "i386_eflags", TDESC_TYPE_I386_EFLAGS },
- { "i386_mxcsr", TDESC_TYPE_I386_MXCSR }
+ { "i387_ext", TDESC_TYPE_I387_EXT }
};
/* Return the type associated with ID in the context of FEATURE, or
@@ -607,57 +603,6 @@ tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
return arch_float_type (gdbarch, -1, "builtin_type_i387_ext",
floatformats_i387_ext);
- case TDESC_TYPE_I386_EFLAGS:
- {
- struct type *type;
-
- type = arch_flags_type (gdbarch, "builtin_type_i386_eflags", 4);
- append_flags_type_flag (type, 0, "CF");
- append_flags_type_flag (type, 1, NULL);
- append_flags_type_flag (type, 2, "PF");
- append_flags_type_flag (type, 4, "AF");
- append_flags_type_flag (type, 6, "ZF");
- append_flags_type_flag (type, 7, "SF");
- append_flags_type_flag (type, 8, "TF");
- append_flags_type_flag (type, 9, "IF");
- append_flags_type_flag (type, 10, "DF");
- append_flags_type_flag (type, 11, "OF");
- append_flags_type_flag (type, 14, "NT");
- append_flags_type_flag (type, 16, "RF");
- append_flags_type_flag (type, 17, "VM");
- append_flags_type_flag (type, 18, "AC");
- append_flags_type_flag (type, 19, "VIF");
- append_flags_type_flag (type, 20, "VIP");
- append_flags_type_flag (type, 21, "ID");
-
- return type;
- }
- break;
-
- case TDESC_TYPE_I386_MXCSR:
- {
- struct type *type;
-
- type = arch_flags_type (gdbarch, "builtin_type_i386_mxcsr", 4);
- append_flags_type_flag (type, 0, "IE");
- append_flags_type_flag (type, 1, "DE");
- append_flags_type_flag (type, 2, "ZE");
- append_flags_type_flag (type, 3, "OE");
- append_flags_type_flag (type, 4, "UE");
- append_flags_type_flag (type, 5, "PE");
- append_flags_type_flag (type, 6, "DAZ");
- append_flags_type_flag (type, 7, "IM");
- append_flags_type_flag (type, 8, "DM");
- append_flags_type_flag (type, 9, "ZM");
- append_flags_type_flag (type, 10, "OM");
- append_flags_type_flag (type, 11, "UM");
- append_flags_type_flag (type, 12, "PM");
- append_flags_type_flag (type, 15, "FZ");
-
- return type;
- }
- break;
-
/* Types defined by a target feature. */
case TDESC_TYPE_VECTOR:
{
@@ -769,7 +714,8 @@ tdesc_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *tdesc_type)
/* Note that contrary to the function name, this call will
just set the properties of an already-allocated
field. */
- append_flags_type_flag (type, f->start, f->name);
+ append_flags_type_flag (type, f->start,
+ *f->name ? f->name : NULL);
return type;
}
@@ -1602,6 +1548,7 @@ maint_print_c_tdesc_cmd (char *args, int from_tty)
struct tdesc_reg *reg;
struct tdesc_type *type;
struct tdesc_type_field *f;
+ struct tdesc_type_flag *flag;
int ix, ix2, ix3;
/* Use the global target-supplied description, not the current
@@ -1715,6 +1662,18 @@ maint_print_c_tdesc_cmd (char *args, int from_tty)
f->name);
}
break;
+ case TDESC_TYPE_FLAGS:
+ printf_unfiltered
+ (" field_type = tdesc_create_flags (feature, \"%s\", %d);\n",
+ type->name, (int) type->u.f.size);
+ for (ix3 = 0;
+ VEC_iterate (tdesc_type_flag, type->u.f.flags, ix3,
+ flag);
+ ix3++)
+ printf_unfiltered
+ (" tdesc_add_flag (field_type, %d, \"%s\");\n",
+ flag->start, flag->name);
+ break;
default:
error (_("C output is not supported type \"%s\"."), type->name);
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Add support for <struct> and <flags> in target descriptions
2010-03-01 0:57 ` H.J. Lu
2010-03-01 2:20 ` H.J. Lu
@ 2010-03-01 2:46 ` Daniel Jacobowitz
2010-03-01 3:06 ` H.J. Lu
1 sibling, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2010-03-01 2:46 UTC (permalink / raw)
To: H.J. Lu; +Cc: gdb-patches
On Sun, Feb 28, 2010 at 04:56:50PM -0800, H.J. Lu wrote:
> This patch makes it to work. However, there is no equivalent of
>
> append_flags_type_flag (type, 1, NULL);
Is this to separate unknown bits (which should be displayed) from
don't-care bits (which are hidden)?
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Add support for <struct> and <flags> in target descriptions
2010-03-01 2:46 ` Daniel Jacobowitz
@ 2010-03-01 3:06 ` H.J. Lu
0 siblings, 0 replies; 9+ messages in thread
From: H.J. Lu @ 2010-03-01 3:06 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
On Sun, Feb 28, 2010 at 6:45 PM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Sun, Feb 28, 2010 at 04:56:50PM -0800, H.J. Lu wrote:
>> This patch makes it to work. However, there is no equivalent of
>>
>> append_flags_type_flag (type, 1, NULL);
>
> Is this to separate unknown bits (which should be displayed) from
> don't-care bits (which are hidden)?
>
I believe so.
--
H.J.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Add support for <struct> and <flags> in target descriptions
2010-03-01 2:20 ` H.J. Lu
@ 2010-03-01 17:20 ` Daniel Jacobowitz
2010-03-01 17:26 ` H.J. Lu
0 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2010-03-01 17:20 UTC (permalink / raw)
To: H.J. Lu; +Cc: gdb-patches
On Sun, Feb 28, 2010 at 06:20:25PM -0800, H.J. Lu wrote:
> Hi Daniel,
>
> This patch on top of yours works.
Thanks. I've checked in my patch; yours is OK also.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [patch] Add support for <struct> and <flags> in target descriptions
2010-03-01 17:20 ` Daniel Jacobowitz
@ 2010-03-01 17:26 ` H.J. Lu
0 siblings, 0 replies; 9+ messages in thread
From: H.J. Lu @ 2010-03-01 17:26 UTC (permalink / raw)
To: H.J. Lu, gdb-patches
On Mon, Mar 1, 2010 at 9:20 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Sun, Feb 28, 2010 at 06:20:25PM -0800, H.J. Lu wrote:
>> Hi Daniel,
>>
>> This patch on top of yours works.
>
> Thanks. I've checked in my patch; yours is OK also.
>
Done. Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-03-01 17:26 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-22 16:45 [patch] Add support for <struct> and <flags> in target descriptions Daniel Jacobowitz
2010-02-22 19:32 ` Eli Zaretskii
2010-03-01 0:15 ` H.J. Lu
2010-03-01 0:57 ` H.J. Lu
2010-03-01 2:20 ` H.J. Lu
2010-03-01 17:20 ` Daniel Jacobowitz
2010-03-01 17:26 ` H.J. Lu
2010-03-01 2:46 ` Daniel Jacobowitz
2010-03-01 3:06 ` H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox