From 9c6a1327ad9a92b8584f0501dd25bf8ba9e84ac6 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 24 Apr 2020 13:40:31 -0600 Subject: Rewrite the existing variant part code This rewrites the existing variant part code to follow the new model implemented in the previous patch. The old variant part code is removed. This only affects Rust for the moment. I tested this using various version of the Rust compiler, including one that emits old-style enum debuginfo, exercising the quirks code. gdb/ChangeLog 2020-04-24 Tom Tromey * dwarf2/read.c (struct variant_field): Rewrite. (struct variant_part_builder): New. (struct nextfield): Remove "variant" field. Add "offset". (struct field_info): Add "current_variant_part" and "variant_parts". (alloc_discriminant_info): Remove. (alloc_rust_variant): New function. (quirk_rust_enum): Update. (dwarf2_add_field): Set "offset" member. Don't handle DW_TAG_variant_part. (offset_map_type): New typedef. (convert_variant_range, create_one_variant) (create_one_variant_part, create_variant_parts) (add_variant_property): New functions. (dwarf2_attach_fields_to_type): Call add_variant_property. (read_structure_type): Don't handle DW_TAG_variant_part. (handle_variant_part, handle_variant): New functions. (handle_struct_member_die): Use them. (process_structure_scope): Don't handle variant parts. * gdbtypes.h (TYPE_FLAG_DISCRIMINATED_UNION): Remove. (struct discriminant_info): Remove. (enum dynamic_prop_node_kind) : Remove. (struct main_type) : Remove. * rust-lang.c (rust_enum_p, rust_empty_enum_p): Rewrite. (rust_enum_variant): Return int. Remove "contents". Rewrite. (rust_print_enum, rust_print_struct_def, rust_evaluate_subexp): Update. * valops.c (value_union_variant): Remove. * value.h (value_union_variant): Don't declare. --- gdb/value.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'gdb/value.h') diff --git a/gdb/value.h b/gdb/value.h index dfe3e8e..ae859ca 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -1226,14 +1226,6 @@ extern struct type *result_type_of_xmethod (struct value *method, extern struct value *call_xmethod (struct value *method, gdb::array_view argv); -/* Given a discriminated union type and some corresponding value - contents, this will return the field index of the currently active - variant. This will throw an exception if no active variant can be - found. */ - -extern int value_union_variant (struct type *union_type, - const gdb_byte *contents); - /* Destroy the values currently allocated. This is called when GDB is exiting (e.g., on quit_force). */ extern void finalize_values (); -- cgit v1.1