From 2ddeaf8a7d64094f4caf6cdc412d8162f49f73a1 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 10 Jan 2018 13:53:18 -0700 Subject: 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 * dwarf2read.c (struct variant_field): New. (struct nextfield) : 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 * gdb.dwarf2/variant.c: New file. * gdb.dwarf2/variant.exp: New file. --- gdb/ChangeLog | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gdb/ChangeLog') diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 31fbe9a..0897d59 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,18 @@ 2018-02-26 Tom Tromey + * dwarf2read.c (struct variant_field): New. + (struct nextfield) : 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 + * rust-lang.h (rust_last_path_segment): Declare. * rust-lang.c (rust_last_path_segment): Now public. Change contract. -- cgit v1.1