diff options
author | Tom Tromey <tom@tromey.com> | 2018-01-10 13:53:18 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-02-26 09:21:08 -0700 |
commit | 2ddeaf8a7d64094f4caf6cdc412d8162f49f73a1 (patch) | |
tree | 74a0c3ecfeaebf20f7d1fb730dbafeb2648ab7ad /gdb/dbxread.c | |
parent | c9317f214b274b805190b8e878c79f4181d93bb4 (diff) | |
download | gdb-2ddeaf8a7d64094f4caf6cdc412d8162f49f73a1.zip gdb-2ddeaf8a7d64094f4caf6cdc412d8162f49f73a1.tar.gz gdb-2ddeaf8a7d64094f4caf6cdc412d8162f49f73a1.tar.bz2 |
Handle DW_TAG_variant_part and DW_TAG_variant
This changes dwarf2read to understand DW_TAG_variant_part and
DW_TAG_variant.
Note that DW_AT_discr_list is not handled. I did not need this for
Rust. I imagine this should not be too hard to add later, should
someone need it. Meanwhile I have gdb emit a complaint if it is seen.
There is a lurking issue concerning the placement of the discriminant
in the DWARF. For Rust, I ended up following the letter of the
standard and having the discriminant be a child of the
DW_TAG_variant_part. However, GCC's Ada support does not do this.
Pierre-Marie filed this with the DWARF committee:
http://dwarfstd.org/ShowIssue.php?issue=180123.1
However as that is read-only, if you have comments you might consider
adding them to the GCC bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83935
Finally, there is a DWARF extension lurking in here. In Rust, a
univariant enum will not have a discriminant. However, in order to
unify the representation of all data-carrying enums, I've made LLVM
(and my forthcoming rustc patch) emit a univariant enum using a
DW_TAG_variant with a single variant part and without DW_AT_discr.
The lack of this DW_AT_discr is the extension. I will submit an issue
on dwarfstd.org about this.
2018-02-26 Tom Tromey <tom@tromey.com>
* dwarf2read.c (struct variant_field): New.
(struct nextfield) <variant>: New field.
(dwarf2_add_field): Handle DW_TAG_variant_part.
(dwarf2_attach_fields_to_type): Attach a discriminant_info to a
discriminated union.
(read_structure_type): Handle DW_TAG_variant_part.
(handle_struct_member_die): New function, extracted from
process_structure_scope. Handle DW_TAG_variant.
(process_structure_scope): Handle discriminated unions. Call
handle_struct_member_die.
2018-02-26 Tom Tromey <tom@tromey.com>
* gdb.dwarf2/variant.c: New file.
* gdb.dwarf2/variant.exp: New file.
Diffstat (limited to 'gdb/dbxread.c')
0 files changed, 0 insertions, 0 deletions