aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-typeprint.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2016-03-15 14:37:29 -0700
committerDoug Evans <dje@google.com>2016-03-15 14:37:29 -0700
commit8151645076ce927e0ee866c598a19f192e68e103 (patch)
treeb9270d1643c875c060e7d55746c50c69ee2e24bd /gdb/c-typeprint.c
parent54157a25aa28ba78e1da1dfa06e6c988d75e88f1 (diff)
Extend flags to support multibit and enum bitfields.
gdb/ChangeLog: Extend flags to support multibit and enum bitfields. NEWS: Document new features. * c-typeprint.c (c_type_print_varspec_prefix): Handle TYPE_CODE_FLAGS. (c_type_print_varspec_suffix, c_type_print_base): Ditto. * gdbtypes.c (arch_flags_type): Don't assume all fields are one bit. (append_flags_type_field): New function. (append_flags_type_flag): Call it. * gdbtypes.h (append_flags_type_field): Declare. * target-descriptions.c (struct tdesc_type_flag): Delete. (enum tdesc_type_kind) <TDESC_TYPE_BOOL>: New enum value. (enum tdesc_type_kind) <TDESC_TYPE_ENUM>: Ditto. (struct tdesc_type) <u.f>: Delete. (tdesc_predefined_types): Add "bool". (tdesc_predefined_type): New function. (tdesc_gdb_type): Handle TDESC_TYPE_BOOL, TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS support. (tdesc_free_type): Handle TDESC_TYPE_ENUM. Update TDESC_TYPE_FLAGS. (tdesc_create_flags): Update. (tdesc_create_enum): New function. (tdesc_add_field): Initialize start,end to -1. (tdesc_add_typed_bitfield): New function. (tdesc_add_bitfield): Call it. (tdesc_add_flag): Allow TDESC_TYPE_STRUCT. Update. (tdesc_add_enum_value): New function. (maint_print_c_tdesc_cmd): Fold TDESC_TYPE_FLAGS support into TDESC_TYPE_STRUCT. Handle TDESC_TYPE_ENUM. * target-descriptions.h (tdesc_create_enum): Declare. (tdesc_add_typed_bitfield, tdesc_add_enum_value): Declare. * valprint.c (generic_val_print_enum_1): New function. (generic_val_print_enum): Call it. (val_print_type_code_flags): Make static. Handle multibit bitfields and enum bitfields. * valprint.h (val_print_type_code_flags): Delete. * xml-tdesc.c (struct tdesc_parsing_data) <current_type_is_flags>: Delete. All uses removed. (tdesc_start_enum): New function. (tdesc_start_field): Handle multibit and enum bitfields. (tdesc_start_enum_value): New function. (enum_value_attributes, enum_children, enum_attributes): New static globals. (feature_children): Add "enum". * features/gdb-target.dtd (enum, evalue): New elements. gdb/doc/ChangeLog: * gdb.texinfo (Target Descriptions): New menu item "Enum Target Types". (Target Description Format): Mention enum types. Update docs on flags types. (Predefined Target Types): Add "bool". (Enum Target Types): New node. gdb/testsuite/ChangeLog: * gdb.xml/extra-regs.xml: Add enum, mixed_flags values. * gdb.xml/tdesc-regs.exp (load_description): New arg xml_file. All callers updated. Add tests for enums, mixed flags register.
Diffstat (limited to 'gdb/c-typeprint.c')
-rw-r--r--gdb/c-typeprint.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 6b9e6b3cf2..ed16fc3b8d 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -371,6 +371,7 @@ c_type_print_varspec_prefix (struct type *type,
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
case TYPE_CODE_ENUM:
+ case TYPE_CODE_FLAGS:
case TYPE_CODE_INT:
case TYPE_CODE_FLT:
case TYPE_CODE_VOID:
@@ -748,6 +749,7 @@ c_type_print_varspec_suffix (struct type *type,
case TYPE_CODE_UNDEF:
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
+ case TYPE_CODE_FLAGS:
case TYPE_CODE_ENUM:
case TYPE_CODE_INT:
case TYPE_CODE_FLT:
@@ -1402,6 +1404,54 @@ c_type_print_base (struct type *type, struct ui_file *stream,
}
break;
+ case TYPE_CODE_FLAGS:
+ {
+ struct type_print_options local_flags = *flags;
+
+ local_flags.local_typedefs = NULL;
+
+ c_type_print_modifier (type, stream, 0, 1);
+ fprintf_filtered (stream, "flag ");
+ print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
+ if (show > 0)
+ {
+ fputs_filtered (" ", stream);
+ fprintf_filtered (stream, "{\n");
+ if (TYPE_NFIELDS (type) == 0)
+ {
+ if (TYPE_STUB (type))
+ fprintfi_filtered (level + 4, stream,
+ _("<incomplete type>\n"));
+ else
+ fprintfi_filtered (level + 4, stream,
+ _("<no data fields>\n"));
+ }
+ len = TYPE_NFIELDS (type);
+ for (i = 0; i < len; i++)
+ {
+ QUIT;
+ print_spaces_filtered (level + 4, stream);
+ /* We pass "show" here and not "show - 1" to get enum types
+ printed. There's no other way to see them. */
+ c_print_type (TYPE_FIELD_TYPE (type, i),
+ TYPE_FIELD_NAME (type, i),
+ stream, show, level + 4,
+ &local_flags);
+ fprintf_filtered (stream, " @%d",
+ TYPE_FIELD_BITPOS (type, i));
+ if (TYPE_FIELD_BITSIZE (type, i) > 1)
+ {
+ fprintf_filtered (stream, "-%d",
+ TYPE_FIELD_BITPOS (type, i)
+ + TYPE_FIELD_BITSIZE (type, i) - 1);
+ }
+ fprintf_filtered (stream, ";\n");
+ }
+ fprintfi_filtered (level, stream, "}");
+ }
+ }
+ break;
+
case TYPE_CODE_VOID:
fprintf_filtered (stream, "void");
break;