diff options
author | Doug Evans <dje@google.com> | 2016-03-15 14:37:29 -0700 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2016-03-15 14:37:29 -0700 |
commit | 8151645076ce927e0ee866c598a19f192e68e103 (patch) | |
tree | b9270d1643c875c060e7d55746c50c69ee2e24bd /gdb/testsuite | |
parent | 54157a25aa28ba78e1da1dfa06e6c988d75e88f1 (diff) | |
download | gdb-8151645076ce927e0ee866c598a19f192e68e103.zip gdb-8151645076ce927e0ee866c598a19f192e68e103.tar.gz gdb-8151645076ce927e0ee866c598a19f192e68e103.tar.bz2 |
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/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.xml/extra-regs.xml | 25 | ||||
-rw-r--r-- | gdb/testsuite/gdb.xml/tdesc-regs.exp | 20 |
3 files changed, 41 insertions, 10 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 177b2d1..25154c6 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,11 @@ 2016-03-15 Doug Evans <dje@google.com> + * 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. + +2016-03-15 Doug Evans <dje@google.com> + * gdb.base/skip.c (main): Call test_skip_file_and_function. * gdb.base/skip.exp: Remove hand calling test_skip_file_and_function. diff --git a/gdb/testsuite/gdb.xml/extra-regs.xml b/gdb/testsuite/gdb.xml/extra-regs.xml index f0db04e..cbbaf76 100644 --- a/gdb/testsuite/gdb.xml/extra-regs.xml +++ b/gdb/testsuite/gdb.xml/extra-regs.xml @@ -23,6 +23,30 @@ <field name="Y" start="2" end="2"/> </flags> + <enum id="Z_values" size="4"> + <evalue name="yes" value="1"/> + <evalue name="no" value="0"/> + <evalue name="maybe" value="2"/> + <evalue name="so" value="3"/> + </enum> + + <flags id="mixed_flags" size="4"> + <!-- Elided end and type. --> + <field name="A" start="0"/> + <!-- Elided end, unsigned int. --> + <field name="B" start="1" type="uint32"/> + <!-- Elided end, bool. --> + <field name="C" start="2" type="bool"/> + <!-- Elided type, single bitfield. --> + <field name="D" start="3" end="3"/> + <!-- Anonymous field. --> + <field name="" start="4" end="5"/> + <!-- Multi-bit bitfield, elided type. --> + <field name="E" start="6" end="7"/> + <!-- Enum bitfield. --> + <field name="Z" start="8" end="9" type="Z_values"/> + </flags> + <reg name="extrareg" bitsize="32"/> <reg name="uintreg" bitsize="32" type="uint32"/> <reg name="vecreg" bitsize="32" type="v4int8"/> @@ -30,5 +54,6 @@ <reg name="structreg" bitsize="64" type="struct1"/> <reg name="bitfields" bitsize="64" type="struct2"/> <reg name="flags" bitsize="32" type="flags"/> + <reg name="mixed_flags" bitsize="32" type="mixed_flags"/> </feature> </target> diff --git a/gdb/testsuite/gdb.xml/tdesc-regs.exp b/gdb/testsuite/gdb.xml/tdesc-regs.exp index 80e1008..48204cd 100644 --- a/gdb/testsuite/gdb.xml/tdesc-regs.exp +++ b/gdb/testsuite/gdb.xml/tdesc-regs.exp @@ -106,7 +106,7 @@ foreach src ${core-regs} { } # Similarly, we need to copy files under test into the objdir. -proc load_description { file errmsg } { +proc load_description { file errmsg xml_file } { global srcdir global subdir global gdb_prompt @@ -114,7 +114,7 @@ proc load_description { file errmsg } { global architecture global remote_filename - set regs_file [standard_output_file regs.xml] + set regs_file [standard_output_file $xml_file] file delete $regs_file set ifd [open "$srcdir/$subdir/$file" r] @@ -135,22 +135,18 @@ proc load_description { file errmsg } { close $ofd if {[is_remote host]} { - set regs_file [remote_download host "$subdir/regs.xml" "regs.xml"] + set regs_file [remote_download host "$subdir/$xml_file" $xml_file] } # Anchor the test output, so that error messages are detected. set cmd "set tdesc filename [file tail $regs_file]" - set msg "set tdesc filename regs.xml - from $file" + set msg "set tdesc filename $xml_file - from $file" set cmd_regex [string_to_regexp $cmd] gdb_test_multiple $cmd $msg { -re "^$cmd_regex\r\n$errmsg$gdb_prompt $" { pass $msg } } - - if {[is_remote host]} { - remote_file host delete "regs.xml" - } } if {![is_remote host]} { @@ -158,7 +154,7 @@ if {![is_remote host]} { "cd to directory holding xml" } -load_description "extra-regs.xml" "" +load_description "extra-regs.xml" "" "test-extra-regs.xml" gdb_test "ptype \$extrareg" "type = (int|long|long long)" gdb_test "ptype \$uintreg" "type = uint32_t" gdb_test "ptype \$vecreg" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)" @@ -170,7 +166,11 @@ gdb_test "ptype \$structreg" \ gdb_test "ptype \$structreg.v4" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)" gdb_test "ptype \$bitfields" \ "type = struct struct2 {\r\n *uint64_t f1 : 35;\r\n *uint64_t f2 : 1;\r\n}" +gdb_test "ptype \$flags" \ + "type = flag flags {\r\n *uint32_t X @0;\r\n *uint32_t Y @2;\r\n}" +gdb_test "ptype \$mixed_flags" \ + "type = flag mixed_flags {\r\n *bool A @0;\r\n *uint32_t B @1;\r\n *bool C @2;\r\n *uint32_t D @3;\r\n *uint32_t @4-5;\r\n *uint32_t E @6-7;\r\n *enum {yes = 1, no = 0, maybe = 2, so} Z @8-9;\r\n}" -load_description "core-only.xml" "" +load_description "core-only.xml" "" "test-regs.xml" # The extra register from the previous description should be gone. gdb_test "ptype \$extrareg" "type = void" |