diff options
author | wtedeschi <wtedeschi> | 2013-04-30 12:33:51 +0000 |
---|---|---|
committer | wtedeschi <wtedeschi> | 2013-04-30 12:33:51 +0000 |
commit | 7278f246a92191c8fae5abd0c45bc00e6c35b1ca (patch) | |
tree | 3f595d2bf4e80537e6aad9c13c0bb96e8d42bd7a /gdb/target-descriptions.c | |
parent | 9fcd69680e6da8bd60cc1073d69d4604c63f3bd7 (diff) | |
download | gdb-7278f246a92191c8fae5abd0c45bc00e6c35b1ca.tar.gz |
Fix display of structures/bitfields in register description.
Add support for displaying structures and bitfields for registers when
executing "maint print c-tdesc". This command is also used when
converting the xml target description file into c file.
Example of the behaviour is given below reporting a snipet of the xml file
and a snippet of the c code generated.
XML file contains:
...
<union id="vecint">
<field name="v4" type="v4int8"/>
<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>
...
Setting this xml file as target description file and
issuing the maintenance print c-tdesc the following output
is obtained:
feature = tdesc_create_feature (result, "extra");
field_type = tdesc_named_type (feature, "int8");
tdesc_create_vector (feature, "v4int8", field_type, 4);
field_type = tdesc_named_type (feature, "int16");
tdesc_create_vector (feature, "v2int16", field_type, 2);
type = tdesc_create_union (feature, "vecint");
field_type = tdesc_named_type (feature, "v4int8");
tdesc_add_field (type, "v4", field_type);
field_type = tdesc_named_type (feature, "v2int16");
tdesc_add_field (type, "v2", field_type);
C output is not supported type "struct1".
This is finally the issue.
2013-03-27 Walfred Tedeschi <walfred.tedeschi@intel.com>
* target-descriptions.c (maint_print_c_tdesc_cmd):
Add case to parse structures as register types and
bitfields.
testsuite/
* gdb.xml/maint_print_struct.exp: New file.
* gdb.xml/maint_print_struct.xml: New file.
Change-Id: I2e20b095d508319c80275e724a9452c7e2834067
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
Diffstat (limited to 'gdb/target-descriptions.c')
-rw-r--r-- | gdb/target-descriptions.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 95980c53457..44ad40122f6 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -1675,7 +1675,8 @@ maint_print_c_tdesc_cmd (char *args, int from_tty) printed_field_type = 1; } - if (type->kind == TDESC_TYPE_UNION + if ((type->kind == TDESC_TYPE_UNION + || type->kind == TDESC_TYPE_STRUCT) && VEC_length (tdesc_type_field, type->u.u.fields) > 0) { printf_unfiltered (" struct tdesc_type *type;\n"); @@ -1746,6 +1747,36 @@ feature = tdesc_create_feature (result, \"%s\");\n", (" tdesc_create_vector (feature, \"%s\", field_type, %d);\n", type->name, type->u.v.count); break; + case TDESC_TYPE_STRUCT: + printf_unfiltered + (" type = tdesc_create_struct (feature, \"%s\");\n", + type->name); + if (type->u.u.size != 0) + printf_unfiltered + (" tdesc_set_struct_size (type, %s);\n", + plongest (type->u.u.size)); + for (ix3 = 0; + VEC_iterate (tdesc_type_field, type->u.u.fields, ix3, f); + ix3++) + { + /* Going first for implicitly sized types, else part handles + bitfields. As reported on xml-tdesc.c implicitly sized types + cannot contain a bitfield. */ + if (f->start == 0 && f->end == 0) + { + printf_unfiltered + (" field_type = tdesc_named_type (feature, \"%s\");\n", + f->type->name); + printf_unfiltered + (" tdesc_add_field (type, \"%s\", field_type);\n", + f->name); + } + else + printf_unfiltered + (" tdesc_add_bitfield (type, \"%s\", %d, %d);\n", + f->name, f->start, f->end); + } + break; case TDESC_TYPE_UNION: printf_unfiltered (" type = tdesc_create_union (feature, \"%s\");\n", |