From patchwork Tue Apr 17 19:51:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 26768 Received: (qmail 75530 invoked by alias); 17 Apr 2018 19:51:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 75400 invoked by uid 89); 17 Apr 2018 19:51:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Search, fake, Method, consists X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.179.30) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 17 Apr 2018 19:51:30 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 2865514CFC for ; Tue, 17 Apr 2018 14:51:29 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 8WdVf8goMy2aL8WdVfVsxD; Tue, 17 Apr 2018 14:51:29 -0500 X-Authority-Reason: nr=8 Received: from 97-122-176-117.hlrn.qwest.net ([97.122.176.117]:37488 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1f8WdU-000KUt-QS; Tue, 17 Apr 2018 14:51:29 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 3/4] Remove TYPE_TAG_NAME Date: Tue, 17 Apr 2018 13:51:24 -0600 Message-Id: <20180417195125.14200-4-tom@tromey.com> In-Reply-To: <20180417195125.14200-1-tom@tromey.com> References: <20180417195125.14200-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1f8WdU-000KUt-QS X-Source-Sender: 97-122-176-117.hlrn.qwest.net (bapiya.Home) [97.122.176.117]:37488 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes TYPE_TAG_NAME has been an occasional source of confusion and bugs. It seems to me that it is only useful for C and C++ -- but even there, not so much, because at least with DWARF there doesn't seem to be any way to wind up with a type where the name and the tag name are both non-NULL and different. So, this patch removes TYPE_TAG_NAME entirely. This should save a little memory, but more importantly, it simplifies this part of gdb. A few minor test suite adjustments were needed. In some situations the new code does not yield identical output to the old code. ChangeLog 2018-04-17 Tom Tromey * valops.c (enum_constant_from_type, value_namespace_elt) (value_maybe_namespace_elt): Update. * valarith.c (find_size_for_pointer_math): Update. * target-descriptions.c (make_gdb_type): Update. * symmisc.c (print_symbol): Update. * stabsread.c (define_symbol, read_type) (complain_about_struct_wipeout, add_undefined_type) (cleanup_undefined_types_1): Update. * rust-lang.c (rust_tuple_type_p, rust_slice_type_p) (rust_range_type_p, val_print_struct, rust_print_struct_def) (rust_internal_print_type, rust_composite_type) (rust_evaluate_funcall, rust_evaluate_subexp): Update. * python/py-type.c (typy_get_tag): Update. * p-typeprint.c (pascal_type_print_base): Update. * mdebugread.c (parse_symbol, parse_type): Update. * m2-typeprint.c (m2_long_set, m2_record_fields, m2_enum): Update. * guile/scm-type.c (gdbscm_type_tag): Update. * go-lang.c (sixg_string_p): Update. * gnu-v3-abi.c (build_gdb_vtable_type, build_std_type_info_type): Update. * gdbtypes.h (struct main_type) : Remove. (TYPE_TAG_NAME): Remove. * gdbtypes.c (type_name_no_tag): Simplify. (check_typedef, check_types_equal, recursive_dump_type) (copy_type_recursive, arch_composite_type): Update. * f-typeprint.c (f_type_print_base): Update. Print "Type" prefix in summary mode when needed. * eval.c (evaluate_funcall): Update. * dwarf2read.c (fixup_go_packaging, read_structure_type) (process_structure_scope, read_enumeration_type) (read_namespace_type, read_module_type, determine_prefix): Update. * cp-support.c (inspect_type): Update. * coffread.c (process_coff_symbol, decode_base_type): Update. * c-varobj.c (c_is_path_expr_parent): Update. * c-typeprint.c (c_type_print_base_struct_union): Update. (c_type_print_base_1): Update. Print struct/class/union/enum in summary when using C language. * ax-gdb.c (gen_struct_ref, gen_namespace_elt) (gen_maybe_namespace_elt): Update. * ada-lang.c (ada_type_name): Simplify. (empty_record, ada_template_to_fixed_record_type_1) (template_to_static_fixed_type) (to_record_with_fixed_variant_part, ada_check_typedef): Update. testsuite/ChangeLog 2018-04-17 Tom Tromey * gdb.xml/tdesc-regs.exp (load_description): Update expected results. * gdb.dwarf2/method-ptr.exp: Set language to C++. * gdb.dwarf2/member-ptr-forwardref.exp: Set language to C++. * gdb.cp/typeid.exp (do_typeid_tests): Update type_re. * gdb.base/maint.exp (maint_pass_if): Update. --- gdb/ChangeLog | 47 +++++++++++++++++++ gdb/ada-lang.c | 17 ++----- gdb/ax-gdb.c | 6 +-- gdb/c-typeprint.c | 46 +++++++++++++------ gdb/c-varobj.c | 3 +- gdb/coffread.c | 16 +------ gdb/cp-support.c | 2 +- gdb/dwarf2read.c | 31 ++++--------- gdb/eval.c | 4 +- gdb/f-typeprint.c | 13 ++++-- gdb/gdbtypes.c | 29 ++---------- gdb/gdbtypes.h | 21 ++------- gdb/gnu-v3-abi.c | 4 +- gdb/go-lang.c | 4 +- gdb/guile/scm-type.c | 10 +++- gdb/m2-typeprint.c | 22 +++------ gdb/mdebugread.c | 14 +++--- gdb/p-typeprint.c | 20 ++++---- gdb/python/py-type.c | 10 +++- gdb/rust-lang.c | 53 +++++++++++----------- gdb/stabsread.c | 20 +++----- gdb/symmisc.c | 2 +- gdb/target-descriptions.c | 1 - gdb/testsuite/ChangeLog | 9 ++++ gdb/testsuite/gdb.base/maint.exp | 2 +- gdb/testsuite/gdb.cp/typeid.exp | 2 +- gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp | 1 + gdb/testsuite/gdb.dwarf2/method-ptr.exp | 1 + gdb/testsuite/gdb.xml/tdesc-regs.exp | 4 +- gdb/valarith.c | 2 - gdb/valops.c | 6 +-- 31 files changed, 215 insertions(+), 207 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index de20c43bed..41235def3e 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -8136,18 +8136,15 @@ ada_prefer_type (struct type *type0, struct type *type1) return 0; } -/* The name of TYPE, which is either its TYPE_NAME, or, if that is - null, its TYPE_TAG_NAME. Null if TYPE is null. */ +/* The name of TYPE, which is its TYPE_NAME. Null if TYPE is + null. */ const char * ada_type_name (struct type *type) { if (type == NULL) return NULL; - else if (TYPE_NAME (type) != NULL) - return TYPE_NAME (type); - else - return TYPE_TAG_NAME (type); + return TYPE_NAME (type); } /* Search the list of "descriptive" types associated to TYPE for a type @@ -8316,7 +8313,6 @@ empty_record (struct type *templ) TYPE_FIELDS (type) = NULL; INIT_CPLUS_SPECIFIC (type); TYPE_NAME (type) = ""; - TYPE_TAG_NAME (type) = NULL; TYPE_LENGTH (type) = 0; return type; } @@ -8375,7 +8371,6 @@ ada_template_to_fixed_record_type_1 (struct type *type, TYPE_ALLOC (rtype, nfields * sizeof (struct field)); memset (TYPE_FIELDS (rtype), 0, sizeof (struct field) * nfields); TYPE_NAME (rtype) = ada_type_name (type); - TYPE_TAG_NAME (rtype) = NULL; TYPE_FIXED_INSTANCE (rtype) = 1; off = 0; @@ -8652,7 +8647,6 @@ template_to_static_fixed_type (struct type *type0) memcpy (TYPE_FIELDS (type), TYPE_FIELDS (type0), sizeof (struct field) * nfields); TYPE_NAME (type) = ada_type_name (type0); - TYPE_TAG_NAME (type) = NULL; TYPE_FIXED_INSTANCE (type) = 1; TYPE_LENGTH (type) = 0; } @@ -8702,7 +8696,6 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr, memcpy (TYPE_FIELDS (rtype), TYPE_FIELDS (type), sizeof (struct field) * nfields); TYPE_NAME (rtype) = ada_type_name (type); - TYPE_TAG_NAME (rtype) = NULL; TYPE_FIXED_INSTANCE (rtype) = 1; TYPE_LENGTH (rtype) = TYPE_LENGTH (type); @@ -9313,11 +9306,11 @@ ada_check_typedef (struct type *type) type = check_typedef (type); if (type == NULL || TYPE_CODE (type) != TYPE_CODE_ENUM || !TYPE_STUB (type) - || TYPE_TAG_NAME (type) == NULL) + || TYPE_NAME (type) == NULL) return type; else { - const char *name = TYPE_TAG_NAME (type); + const char *name = TYPE_NAME (type); struct type *type1 = ada_find_any_type (name); if (type1 == NULL) diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 9a44d4b750..2468061aad 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -1533,7 +1533,7 @@ gen_struct_ref (struct agent_expr *ax, struct axs_value *value, if (!found) error (_("Couldn't find member named `%s' in struct/union/class `%s'"), - field, TYPE_TAG_NAME (type)); + field, TYPE_NAME (type)); } static int @@ -1629,7 +1629,7 @@ gen_namespace_elt (struct agent_expr *ax, struct axs_value *value, if (!found) error (_("No symbol \"%s\" in namespace \"%s\"."), - name, TYPE_TAG_NAME (curtype)); + name, TYPE_NAME (curtype)); return found; } @@ -1644,7 +1644,7 @@ static int gen_maybe_namespace_elt (struct agent_expr *ax, struct axs_value *value, const struct type *curtype, char *name) { - const char *namespace_name = TYPE_TAG_NAME (curtype); + const char *namespace_name = TYPE_NAME (curtype); struct block_symbol sym; sym = cp_lookup_symbol_namespace (namespace_name, name, diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index a53331aefc..846727f298 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -1174,13 +1174,13 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream, spurious "{unnamed struct}"/"{unnamed union}"/"{unnamed enum}" tag for unnamed struct/union/enum's, which we don't want to print. */ - if (TYPE_TAG_NAME (type) != NULL - && !startswith (TYPE_TAG_NAME (type), "{unnamed")) + if (TYPE_NAME (type) != NULL + && !startswith (TYPE_NAME (type), "{unnamed")) { /* When printing the tag name, we are still effectively printing in the outer context, hence the use of FLAGS here. */ - print_name_maybe_canonical (TYPE_TAG_NAME (type), flags, stream); + print_name_maybe_canonical (TYPE_NAME (type), flags, stream); if (show > 0) fputs_filtered (" ", stream); } @@ -1189,10 +1189,10 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream, { /* If we just printed a tag name, no need to print anything else. */ - if (TYPE_TAG_NAME (type) == NULL) + if (TYPE_NAME (type) == NULL) fprintf_filtered (stream, "{...}"); } - else if (show > 0 || TYPE_TAG_NAME (type) == NULL) + else if (show > 0 || TYPE_NAME (type) == NULL) { struct type *basetype; int vptr_fieldno; @@ -1602,15 +1602,31 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream, /* When SHOW is zero or less, and there is a valid type name, then always just print the type name directly from the type. */ - /* If we have "typedef struct foo {. . .} bar;" do we want to print - it as "struct foo" or as "bar"? Pick the latter, because C++ - folk tend to expect things like "class5 *foo" rather than "struct - class5 *foo". */ if (show <= 0 && TYPE_NAME (type) != NULL) { c_type_print_modifier (type, stream, 0, 1); + + /* If we have "typedef struct foo {. . .} bar;" do we want to + print it as "struct foo" or as "bar"? Pick the latter for + C++, because C++ folk tend to expect things like "class5 + *foo" rather than "struct class5 *foo". */ + if (language == language_c || language == language_minimal) + { + if (TYPE_CODE (type) == TYPE_CODE_UNION) + fprintf_filtered (stream, "union "); + else if (TYPE_CODE (type) == TYPE_CODE_STRUCT) + { + if (TYPE_DECLARED_CLASS (type)) + fprintf_filtered (stream, "class "); + else + fprintf_filtered (stream, "struct "); + } + else if (TYPE_CODE (type) == TYPE_CODE_ENUM) + fprintf_filtered (stream, "enum "); + } + print_name_maybe_canonical (TYPE_NAME (type), flags, stream); return; } @@ -1661,10 +1677,10 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream, "{unnamed struct}"/"{unnamed union}"/"{unnamed enum}" tag for unnamed struct/union/enum's, which we don't want to print. */ - if (TYPE_TAG_NAME (type) != NULL - && !startswith (TYPE_TAG_NAME (type), "{unnamed")) + if (TYPE_NAME (type) != NULL + && !startswith (TYPE_NAME (type), "{unnamed")) { - print_name_maybe_canonical (TYPE_TAG_NAME (type), flags, stream); + print_name_maybe_canonical (TYPE_NAME (type), flags, stream); if (show > 0) fputs_filtered (" ", stream); } @@ -1674,10 +1690,10 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream, { /* If we just printed a tag name, no need to print anything else. */ - if (TYPE_TAG_NAME (type) == NULL) + if (TYPE_NAME (type) == NULL) fprintf_filtered (stream, "{...}"); } - else if (show > 0 || TYPE_TAG_NAME (type) == NULL) + else if (show > 0 || TYPE_NAME (type) == NULL) { LONGEST lastval = 0; @@ -1786,7 +1802,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream, case TYPE_CODE_NAMESPACE: fputs_filtered ("namespace ", stream); - fputs_filtered (TYPE_TAG_NAME (type), stream); + fputs_filtered (TYPE_NAME (type), stream); break; default: diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c index 03656c0a81..7f12989979 100644 --- a/gdb/c-varobj.c +++ b/gdb/c-varobj.c @@ -145,8 +145,7 @@ c_is_path_expr_parent (const struct varobj *var) /* Anonymous unions and structs are also not path_expr parents. */ if ((TYPE_CODE (type) == TYPE_CODE_STRUCT || TYPE_CODE (type) == TYPE_CODE_UNION) - && TYPE_NAME (type) == NULL - && TYPE_TAG_NAME (type) == NULL) + && TYPE_NAME (type) == NULL) { const struct varobj *parent = var->parent; diff --git a/gdb/coffread.c b/gdb/coffread.c index cad3e7e2f1..e07a440443 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1787,11 +1787,11 @@ process_coff_symbol (struct coff_symbol *cs, /* Some compilers try to be helpful by inventing "fake" names for anonymous enums, structures, and unions, like "~0fake" or ".0fake". Thanks, but no thanks... */ - if (TYPE_TAG_NAME (SYMBOL_TYPE (sym)) == 0) + if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0) if (SYMBOL_LINKAGE_NAME (sym) != NULL && *SYMBOL_LINKAGE_NAME (sym) != '~' && *SYMBOL_LINKAGE_NAME (sym) != '.') - TYPE_TAG_NAME (SYMBOL_TYPE (sym)) = + TYPE_NAME (SYMBOL_TYPE (sym)) = concat (SYMBOL_LINKAGE_NAME (sym), (char *)NULL); add_symbol_to_list (sym, &file_symbols); @@ -1957,10 +1957,6 @@ decode_base_type (struct coff_symbol *cs, type = coff_alloc_type (cs->c_symnum); TYPE_CODE (type) = TYPE_CODE_STRUCT; TYPE_NAME (type) = NULL; - /* This used to set the tag to "". But I think - setting it to NULL is right, and the printing code can - print it as "struct {...}". */ - TYPE_TAG_NAME (type) = NULL; INIT_CPLUS_SPECIFIC (type); TYPE_LENGTH (type) = 0; TYPE_FIELDS (type) = 0; @@ -1981,10 +1977,6 @@ decode_base_type (struct coff_symbol *cs, /* Anonymous union type. */ type = coff_alloc_type (cs->c_symnum); TYPE_NAME (type) = NULL; - /* This used to set the tag to "". But I think - setting it to NULL is right, and the printing code can - print it as "union {...}". */ - TYPE_TAG_NAME (type) = NULL; INIT_CPLUS_SPECIFIC (type); TYPE_LENGTH (type) = 0; TYPE_FIELDS (type) = 0; @@ -2007,10 +1999,6 @@ decode_base_type (struct coff_symbol *cs, type = coff_alloc_type (cs->c_symnum); TYPE_CODE (type) = TYPE_CODE_ENUM; TYPE_NAME (type) = NULL; - /* This used to set the tag to "". But I think - setting it to NULL is right, and the printing code can - print it as "enum {...}". */ - TYPE_TAG_NAME (type) = NULL; TYPE_LENGTH (type) = 0; TYPE_FIELDS (type) = 0; TYPE_NFIELDS (type) = 0; diff --git a/gdb/cp-support.c b/gdb/cp-support.c index dde417be80..c16b67171f 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -199,7 +199,7 @@ inspect_type (struct demangle_parse_info *info, && strcmp (TYPE_NAME (type), name) == 0) return 0; - is_anon = (TYPE_TAG_NAME (type) == NULL + is_anon = (TYPE_NAME (type) == NULL && (TYPE_CODE (type) == TYPE_CODE_ENUM || TYPE_CODE (type) == TYPE_CODE_STRUCT || TYPE_CODE (type) == TYPE_CODE_UNION)); diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 8dbe12db02..78c36887ee 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -9778,8 +9778,6 @@ fixup_go_packaging (struct dwarf2_cu *cu) saved_package_name); struct symbol *sym; - TYPE_TAG_NAME (type) = TYPE_NAME (type); - sym = allocate_symbol (objfile); SYMBOL_SET_LANGUAGE (sym, language_go, &objfile->objfile_obstack); SYMBOL_SET_NAMES (sym, saved_package_name, @@ -15621,18 +15619,13 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) if (get_die_type (die, cu) != NULL) return get_die_type (die, cu); - TYPE_TAG_NAME (type) = full_name; - if (die->tag == DW_TAG_structure_type - || die->tag == DW_TAG_class_type) - TYPE_NAME (type) = TYPE_TAG_NAME (type); + TYPE_NAME (type) = full_name; } else { /* The name is already allocated along with this objfile, so we don't need to duplicate it for the type. */ - TYPE_TAG_NAME (type) = name; - if (die->tag == DW_TAG_class_type) - TYPE_NAME (type) = TYPE_TAG_NAME (type); + TYPE_NAME (type) = name; } } @@ -15913,7 +15906,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) complaint (&symfile_complaints, _("virtual function table pointer " "not found when defining class '%s'"), - TYPE_TAG_NAME (type) ? TYPE_TAG_NAME (type) : + TYPE_NAME (type) ? TYPE_NAME (type) : ""); } else @@ -16104,7 +16097,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) TYPE_CODE (type) = TYPE_CODE_ENUM; name = dwarf2_full_name (NULL, die, cu); if (name != NULL) - TYPE_TAG_NAME (type) = name; + TYPE_NAME (type) = name; attr = dwarf2_attr (die, DW_AT_type, cu); if (attr != NULL) @@ -16649,7 +16642,6 @@ read_namespace_type (struct die_info *die, struct dwarf2_cu *cu) /* Create the type. */ type = init_type (objfile, TYPE_CODE_NAMESPACE, 0, name); - TYPE_TAG_NAME (type) = TYPE_NAME (type); return set_die_type (die, type, cu); } @@ -16715,9 +16707,6 @@ read_module_type (struct die_info *die, struct dwarf2_cu *cu) sect_offset_str (die->sect_off)); type = init_type (objfile, TYPE_CODE_MODULE, 0, module_name); - /* determine_prefix uses TYPE_TAG_NAME. */ - TYPE_TAG_NAME (type) = TYPE_NAME (type); - return set_die_type (die, type, cu); } @@ -22155,18 +22144,18 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) DW_TAG_namespace DIEs with a name of "::" for the global namespace. Work around this problem here. */ if (cu->language == language_cplus - && strcmp (TYPE_TAG_NAME (parent_type), "::") == 0) + && strcmp (TYPE_NAME (parent_type), "::") == 0) return ""; /* We give a name to even anonymous namespaces. */ - return TYPE_TAG_NAME (parent_type); + return TYPE_NAME (parent_type); case DW_TAG_class_type: case DW_TAG_interface_type: case DW_TAG_structure_type: case DW_TAG_union_type: case DW_TAG_module: parent_type = read_type_die (parent, cu); - if (TYPE_TAG_NAME (parent_type) != NULL) - return TYPE_TAG_NAME (parent_type); + if (TYPE_NAME (parent_type) != NULL) + return TYPE_NAME (parent_type); else /* An anonymous structure is only allowed non-static data members; no typedefs, no member functions, et cetera. @@ -22191,8 +22180,8 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) parent_type = read_type_die (parent, cu); if (TYPE_DECLARED_CLASS (parent_type)) { - if (TYPE_TAG_NAME (parent_type) != NULL) - return TYPE_TAG_NAME (parent_type); + if (TYPE_NAME (parent_type) != NULL) + return TYPE_NAME (parent_type); return ""; } /* Fall through. */ diff --git a/gdb/eval.c b/gdb/eval.c index b6fbfcf6c9..0bed4aa3fc 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -984,13 +984,13 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos, function_name = NULL; if (TYPE_CODE (type) == TYPE_CODE_NAMESPACE) { - function = cp_lookup_symbol_namespace (TYPE_TAG_NAME (type), + function = cp_lookup_symbol_namespace (TYPE_NAME (type), name, get_selected_block (0), VAR_DOMAIN).symbol; if (function == NULL) error (_("No symbol \"%s\" in namespace \"%s\"."), - name, TYPE_TAG_NAME (type)); + name, TYPE_NAME (type)); tem = 1; /* arg2 is left as NULL on purpose. */ diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c index f14f1811f4..3f13c111ac 100644 --- a/gdb/f-typeprint.c +++ b/gdb/f-typeprint.c @@ -290,7 +290,12 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show, if ((show <= 0) && (TYPE_NAME (type) != NULL)) { - fprintfi_filtered (level, stream, "%s", TYPE_NAME (type)); + const char *prefix = ""; + if (TYPE_CODE (type) == TYPE_CODE_UNION) + prefix = "Type, C_Union :: "; + else if (TYPE_CODE (type) == TYPE_CODE_STRUCT) + prefix = "Type "; + fprintfi_filtered (level, stream, "%s%s", prefix, TYPE_NAME (type)); return; } @@ -370,7 +375,7 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show, fprintfi_filtered (level, stream, "Type, C_Union :: "); else fprintfi_filtered (level, stream, "Type "); - fputs_filtered (TYPE_TAG_NAME (type), stream); + fputs_filtered (TYPE_NAME (type), stream); /* According to the definition, we only print structure elements in case show > 0. */ if (show > 0) @@ -387,12 +392,12 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show, fputs_filtered ("\n", stream); } fprintfi_filtered (level, stream, "End Type "); - fputs_filtered (TYPE_TAG_NAME (type), stream); + fputs_filtered (TYPE_NAME (type), stream); } break; case TYPE_CODE_MODULE: - fprintfi_filtered (level, stream, "module %s", TYPE_TAG_NAME (type)); + fprintfi_filtered (level, stream, "module %s", TYPE_NAME (type)); break; default_case: diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index b3a037971e..b3a388656e 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1469,12 +1469,6 @@ smash_to_method_type (struct type *type, struct type *self_type, const char * type_name_no_tag (const struct type *type) { - if (TYPE_TAG_NAME (type) != NULL) - return TYPE_TAG_NAME (type); - - /* Is there code which expects this to return the name if there is - no tag name? My guess is that this is mainly used for C++ in - cases where the two will always be the same. */ return TYPE_NAME (type); } @@ -2445,10 +2439,8 @@ check_typedef (struct type *type) return make_qualified_type (type, instance_flags, NULL); name = type_name_no_tag (type); - /* FIXME: shouldn't we separately check the TYPE_NAME and - the TYPE_TAG_NAME, and look in STRUCT_DOMAIN and/or - VAR_DOMAIN as appropriate? (this code was written before - TYPE_NAME and TYPE_TAG_NAME were separate). */ + /* FIXME: shouldn't we look in STRUCT_DOMAIN and/or + VAR_DOMAIN as appropriate? */ if (name == NULL) { stub_noname_complaint (); @@ -2534,10 +2526,8 @@ check_typedef (struct type *type) else if (TYPE_STUB (type) && !currently_reading_symtab) { const char *name = type_name_no_tag (type); - /* FIXME: shouldn't we separately check the TYPE_NAME and the - TYPE_TAG_NAME, and look in STRUCT_DOMAIN and/or VAR_DOMAIN - as appropriate? (this code was written before TYPE_NAME and - TYPE_TAG_NAME were separate). */ + /* FIXME: shouldn't we look in STRUCT_DOMAIN and/or VAR_DOMAIN + as appropriate? */ struct symbol *sym; if (name == NULL) @@ -3547,9 +3537,6 @@ check_types_equal (struct type *type1, struct type *type2, || TYPE_NFIELDS (type1) != TYPE_NFIELDS (type2)) return 0; - if (!compare_maybe_null_strings (TYPE_TAG_NAME (type1), - TYPE_TAG_NAME (type2))) - return 0; if (!compare_maybe_null_strings (TYPE_NAME (type1), TYPE_NAME (type2))) return 0; @@ -4419,10 +4406,6 @@ recursive_dump_type (struct type *type, int spaces) TYPE_NAME (type) ? TYPE_NAME (type) : ""); gdb_print_host_address (TYPE_NAME (type), gdb_stdout); printf_filtered (")\n"); - printfi_filtered (spaces, "tagname '%s' (", - TYPE_TAG_NAME (type) ? TYPE_TAG_NAME (type) : ""); - gdb_print_host_address (TYPE_TAG_NAME (type), gdb_stdout); - printf_filtered (")\n"); printfi_filtered (spaces, "code 0x%x ", TYPE_CODE (type)); switch (TYPE_CODE (type)) { @@ -4806,8 +4789,6 @@ copy_type_recursive (struct objfile *objfile, if (TYPE_NAME (type)) TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type)); - if (TYPE_TAG_NAME (type)) - TYPE_TAG_NAME (new_type) = xstrdup (TYPE_TAG_NAME (type)); TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type); TYPE_LENGTH (new_type) = TYPE_LENGTH (type); @@ -5145,7 +5126,7 @@ arch_composite_type (struct gdbarch *gdbarch, const char *name, gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION); t = arch_type (gdbarch, code, 0, NULL); - TYPE_TAG_NAME (t) = name; + TYPE_NAME (t) = name; INIT_CPLUS_SPECIFIC (t); return t; } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 552a2a2a16..70dac75855 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -721,26 +721,12 @@ struct main_type /* * Name of this type, or NULL if none. - This is used for printing only, except by poorly designed C++ - code. For looking up a name, look for a symbol in the - VAR_DOMAIN. This is generally allocated in the objfile's - obstack. However coffread.c uses malloc. */ + This is used for printing only. For looking up a name, look for + a symbol in the VAR_DOMAIN. This is generally allocated in the + objfile's obstack. However coffread.c uses malloc. */ const char *name; - /* * Tag name for this type, or NULL if none. This means that the - name of the type consists of a keyword followed by the tag name. - Which keyword is determined by the type code ("struct" for - TYPE_CODE_STRUCT, etc.). As far as I know C/C++ are the only - languages with this feature. - - This is used for printing only, except by poorly designed C++ code. - For looking up a name, look for a symbol in the STRUCT_DOMAIN. - One more legitimate use is that if TYPE_STUB is set, this is - the name to use to look for definitions in other files. */ - - const char *tag_name; - /* * Every type is now associated with a particular objfile, and the type is allocated on the objfile_obstack for that objfile. One problem however, is that there are times when gdb allocates new @@ -1281,7 +1267,6 @@ extern void allocate_gnat_aux_type (struct type *); #define TYPE_INSTANCE_FLAGS(thistype) (thistype)->instance_flags #define TYPE_MAIN_TYPE(thistype) (thistype)->main_type #define TYPE_NAME(thistype) TYPE_MAIN_TYPE(thistype)->name -#define TYPE_TAG_NAME(type) TYPE_MAIN_TYPE(type)->tag_name #define TYPE_TARGET_TYPE(thistype) TYPE_MAIN_TYPE(thistype)->target_type #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 859187f2e9..781acaa409 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -164,7 +164,7 @@ build_gdb_vtable_type (struct gdbarch *arch) t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL); TYPE_NFIELDS (t) = field - field_list; TYPE_FIELDS (t) = field_list; - TYPE_TAG_NAME (t) = "gdb_gnu_v3_abi_vtable"; + TYPE_NAME (t) = "gdb_gnu_v3_abi_vtable"; INIT_CPLUS_SPECIFIC (t); return make_type_with_address_space (t, TYPE_INSTANCE_FLAG_CODE_SPACE); @@ -1028,7 +1028,7 @@ build_std_type_info_type (struct gdbarch *arch) t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL); TYPE_NFIELDS (t) = field - field_list; TYPE_FIELDS (t) = field_list; - TYPE_TAG_NAME (t) = "gdb_gnu_v3_type_info"; + TYPE_NAME (t) = "gdb_gnu_v3_type_info"; INIT_CPLUS_SPECIFIC (t); return t; diff --git a/gdb/go-lang.c b/gdb/go-lang.c index e9cba7713c..60ab2f3dc3 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -106,8 +106,8 @@ static int sixg_string_p (struct type *type) { if (TYPE_NFIELDS (type) == 2 - && TYPE_TAG_NAME (type) != NULL - && strcmp (TYPE_TAG_NAME (type), "string") == 0) + && TYPE_NAME (type) != NULL + && strcmp (TYPE_NAME (type), "string") == 0) return 1; return 0; diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index ce67695b76..949e0dca82 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -576,10 +576,16 @@ gdbscm_type_tag (SCM self) type_smob *t_smob = tyscm_get_type_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct type *type = t_smob->type; + const char *tagname = nullptr; - if (!TYPE_TAG_NAME (type)) + if (TYPE_CODE (type) == TYPE_CODE_STRUCT + || TYPE_CODE (type) == TYPE_CODE_UNION + || TYPE_CODE (type) == TYPE_CODE_ENUM) + tagname = TYPE_NAME (type); + + if (tagname == nullptr) return SCM_BOOL_F; - return gdbscm_scm_from_c_string (TYPE_TAG_NAME (type)); + return gdbscm_scm_from_c_string (tagname); } /* (type-name ) -> string diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c index 27e9429211..7279ab5b54 100644 --- a/gdb/m2-typeprint.c +++ b/gdb/m2-typeprint.c @@ -439,22 +439,14 @@ m2_long_set (struct type *type, struct ui_file *stream, int show, int level, if (m2_is_long_set (type)) { - if (TYPE_TAG_NAME (type) != NULL) - { - fputs_filtered (TYPE_TAG_NAME (type), stream); - if (show == 0) - return 1; - } - else if (TYPE_NAME (type) != NULL) + if (TYPE_NAME (type) != NULL) { fputs_filtered (TYPE_NAME (type), stream); if (show == 0) return 1; + fputs_filtered (" = ", stream); } - if (TYPE_TAG_NAME (type) != NULL || TYPE_NAME (type) != NULL) - fputs_filtered (" = ", stream); - if (get_long_set_bounds (type, &low, &high)) { fprintf_filtered(stream, "SET OF "); @@ -537,11 +529,11 @@ m2_record_fields (struct type *type, struct ui_file *stream, int show, int level, const struct type_print_options *flags) { /* Print the tag if it exists. */ - if (TYPE_TAG_NAME (type) != NULL) + if (TYPE_NAME (type) != NULL) { - if (!startswith (TYPE_TAG_NAME (type), "$$")) + if (!startswith (TYPE_NAME (type), "$$")) { - fputs_filtered (TYPE_TAG_NAME (type), stream); + fputs_filtered (TYPE_NAME (type), stream); if (show > 0) fprintf_filtered (stream, " = "); } @@ -601,10 +593,10 @@ m2_enum (struct type *type, struct ui_file *stream, int show, int level) if (show < 0) { /* If we just printed a tag name, no need to print anything else. */ - if (TYPE_TAG_NAME (type) == NULL) + if (TYPE_NAME (type) == NULL) fprintf_filtered (stream, "(...)"); } - else if (show > 0 || TYPE_TAG_NAME (type) == NULL) + else if (show > 0 || TYPE_NAME (type) == NULL) { fprintf_filtered (stream, "("); len = TYPE_NFIELDS (type); diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index c0bce55148..a760fd9692 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1031,10 +1031,10 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, (.Fxx or .xxfake or empty) for unnamed struct/union/enums. Alpha cc puts out an sh->iss of zero for those. */ if (sh->iss == 0 || name[0] == '.' || name[0] == '\0') - TYPE_TAG_NAME (t) = NULL; + TYPE_NAME (t) = NULL; else - TYPE_TAG_NAME (t) = obconcat (&mdebugread_objfile->objfile_obstack, - name, (char *) NULL); + TYPE_NAME (t) = obconcat (&mdebugread_objfile->objfile_obstack, + name, (char *) NULL); TYPE_CODE (t) = type_code; TYPE_LENGTH (t) = sh->value; @@ -1699,10 +1699,10 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs, /* Do not set the tag name if it is a compiler generated tag name (.Fxx or .xxfake or empty) for unnamed struct/union/enums. */ if (name[0] == '.' || name[0] == '\0') - TYPE_TAG_NAME (tp) = NULL; - else if (TYPE_TAG_NAME (tp) == NULL - || strcmp (TYPE_TAG_NAME (tp), name) != 0) - TYPE_TAG_NAME (tp) + TYPE_NAME (tp) = NULL; + else if (TYPE_NAME (tp) == NULL + || strcmp (TYPE_NAME (tp), name) != 0) + TYPE_NAME (tp) = ((const char *) obstack_copy0 (&mdebugread_objfile->objfile_obstack, name, strlen (name))); diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c index e35e0fbd80..f82a2bc981 100644 --- a/gdb/p-typeprint.c +++ b/gdb/p-typeprint.c @@ -522,9 +522,9 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, only after args !! */ break; case TYPE_CODE_STRUCT: - if (TYPE_TAG_NAME (type) != NULL) + if (TYPE_NAME (type) != NULL) { - fputs_filtered (TYPE_TAG_NAME (type), stream); + fputs_filtered (TYPE_NAME (type), stream); fputs_filtered (" = ", stream); } if (HAVE_CPLUS_STRUCT (type)) @@ -538,9 +538,9 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, goto struct_union; case TYPE_CODE_UNION: - if (TYPE_TAG_NAME (type) != NULL) + if (TYPE_NAME (type) != NULL) { - fputs_filtered (TYPE_TAG_NAME (type), stream); + fputs_filtered (TYPE_NAME (type), stream); fputs_filtered (" = ", stream); } fprintf_filtered (stream, "case of "); @@ -550,10 +550,10 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, if (show < 0) { /* If we just printed a tag name, no need to print anything else. */ - if (TYPE_TAG_NAME (type) == NULL) + if (TYPE_NAME (type) == NULL) fprintf_filtered (stream, "{...}"); } - else if (show > 0 || TYPE_TAG_NAME (type) == NULL) + else if (show > 0 || TYPE_NAME (type) == NULL) { pascal_type_print_derivation_info (stream, type); @@ -740,9 +740,9 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, break; case TYPE_CODE_ENUM: - if (TYPE_TAG_NAME (type) != NULL) + if (TYPE_NAME (type) != NULL) { - fputs_filtered (TYPE_TAG_NAME (type), stream); + fputs_filtered (TYPE_NAME (type), stream); if (show > 0) fputs_filtered (" ", stream); } @@ -753,10 +753,10 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, if (show < 0) { /* If we just printed a tag name, no need to print anything else. */ - if (TYPE_TAG_NAME (type) == NULL) + if (TYPE_NAME (type) == NULL) fprintf_filtered (stream, "(...)"); } - else if (show > 0 || TYPE_TAG_NAME (type) == NULL) + else if (show > 0 || TYPE_NAME (type) == NULL) { fprintf_filtered (stream, "("); len = TYPE_NFIELDS (type); diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 8a948eeaa6..6cbb1b663d 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -416,10 +416,16 @@ static PyObject * typy_get_tag (PyObject *self, void *closure) { struct type *type = ((type_object *) self)->type; + const char *tagname = nullptr; - if (!TYPE_TAG_NAME (type)) + if (TYPE_CODE (type) == TYPE_CODE_STRUCT + || TYPE_CODE (type) == TYPE_CODE_UNION + || TYPE_CODE (type) == TYPE_CODE_ENUM) + tagname = TYPE_NAME (type); + + if (tagname == nullptr) Py_RETURN_NONE; - return PyString_FromString (TYPE_TAG_NAME (type)); + return PyString_FromString (tagname); } /* Return the type, stripped of typedefs. */ diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index cf8a15ee43..aa02ede52f 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -95,8 +95,8 @@ rust_tuple_type_p (struct type *type) nothing else in the debuginfo to distinguish a tuple from a struct. */ return (TYPE_CODE (type) == TYPE_CODE_STRUCT - && TYPE_TAG_NAME (type) != NULL - && TYPE_TAG_NAME (type)[0] == '('); + && TYPE_NAME (type) != NULL + && TYPE_NAME (type)[0] == '('); } /* Return true if all non-static fields of a structlike type are in a @@ -143,9 +143,9 @@ static bool rust_slice_type_p (struct type *type) { return (TYPE_CODE (type) == TYPE_CODE_STRUCT - && TYPE_TAG_NAME (type) != NULL - && (strncmp (TYPE_TAG_NAME (type), "&[", 2) == 0 - || strcmp (TYPE_TAG_NAME (type), "&str") == 0)); + && TYPE_NAME (type) != NULL + && (strncmp (TYPE_NAME (type), "&[", 2) == 0 + || strcmp (TYPE_NAME (type), "&str") == 0)); } /* Return true if TYPE is a range type, otherwise false. */ @@ -157,8 +157,8 @@ rust_range_type_p (struct type *type) if (TYPE_CODE (type) != TYPE_CODE_STRUCT || TYPE_NFIELDS (type) > 2 - || TYPE_TAG_NAME (type) == NULL - || strstr (TYPE_TAG_NAME (type), "::Range") == NULL) + || TYPE_NAME (type) == NULL + || strstr (TYPE_NAME (type), "::Range") == NULL) return false; if (TYPE_NFIELDS (type) == 0) @@ -342,13 +342,13 @@ val_print_struct (struct type *type, int embedded_offset, if (!is_tuple) { - if (TYPE_TAG_NAME (type) != NULL) - fprintf_filtered (stream, "%s", TYPE_TAG_NAME (type)); + if (TYPE_NAME (type) != NULL) + fprintf_filtered (stream, "%s", TYPE_NAME (type)); if (TYPE_NFIELDS (type) == 0) return; - if (TYPE_TAG_NAME (type) != NULL) + if (TYPE_NAME (type) != NULL) fputs_filtered (" ", stream); } @@ -617,7 +617,7 @@ rust_print_struct_def (struct type *type, const char *varstring, /* Print a tuple type simply. */ if (rust_tuple_type_p (type)) { - fputs_filtered (TYPE_TAG_NAME (type), stream); + fputs_filtered (TYPE_NAME (type), stream); return; } @@ -627,7 +627,7 @@ rust_print_struct_def (struct type *type, const char *varstring, /* Compute properties of TYPE here because, in the enum case, the rest of the code ends up looking only at the variant part. */ - const char *tagname = TYPE_TAG_NAME (type); + const char *tagname = TYPE_NAME (type); bool is_tuple_struct = rust_tuple_struct_type_p (type); bool is_tuple = rust_tuple_type_p (type); bool is_enum = rust_enum_p (type); @@ -808,11 +808,11 @@ rust_internal_print_type (struct type *type, const char *varstring, int i, len = 0; fputs_filtered ("enum ", stream); - if (TYPE_TAG_NAME (type) != NULL) + if (TYPE_NAME (type) != NULL) { - fputs_filtered (TYPE_TAG_NAME (type), stream); + fputs_filtered (TYPE_NAME (type), stream); fputs_filtered (" ", stream); - len = strlen (TYPE_TAG_NAME (type)); + len = strlen (TYPE_NAME (type)); } fputs_filtered ("{\n", stream); @@ -823,7 +823,7 @@ rust_internal_print_type (struct type *type, const char *varstring, QUIT; if (len > 0 - && strncmp (name, TYPE_TAG_NAME (type), len) == 0 + && strncmp (name, TYPE_NAME (type), len) == 0 && name[len] == ':' && name[len + 1] == ':') name += len + 2; @@ -912,7 +912,6 @@ rust_composite_type (struct type *original, TYPE_CODE (result) = TYPE_CODE_STRUCT; TYPE_NAME (result) = name; - TYPE_TAG_NAME (result) = name; TYPE_NFIELDS (result) = nfields; TYPE_FIELDS (result) @@ -1090,10 +1089,10 @@ rust_evaluate_funcall (struct expression *exp, int *pos, enum noside noside) && TYPE_CODE (type) != TYPE_CODE_ENUM) || rust_tuple_type_p (type)) error (_("Method calls only supported on struct or enum types")); - if (TYPE_TAG_NAME (type) == NULL) + if (TYPE_NAME (type) == NULL) error (_("Method call on nameless type")); - std::string name = std::string (TYPE_TAG_NAME (type)) + "::" + method; + std::string name = std::string (TYPE_NAME (type)) + "::" + method; block = get_selected_block (0); sym = lookup_symbol (name.c_str (), block, VAR_DOMAIN, NULL); @@ -1606,13 +1605,13 @@ rust_evaluate_subexp (struct type *expect_type, struct expression *exp, if (outer_type != NULL) error(_("Cannot access field %d of variant %s::%s, " "there are only %d fields"), - field_number, TYPE_TAG_NAME (outer_type), - rust_last_path_segment (TYPE_TAG_NAME (type)), + field_number, TYPE_NAME (outer_type), + rust_last_path_segment (TYPE_NAME (type)), nfields); else error(_("Cannot access field %d of %s, " "there are only %d fields"), - field_number, TYPE_TAG_NAME (type), nfields); + field_number, TYPE_NAME (type), nfields); } /* Tuples are tuple structs too. */ @@ -1620,13 +1619,13 @@ rust_evaluate_subexp (struct type *expect_type, struct expression *exp, { if (outer_type != NULL) error(_("Variant %s::%s is not a tuple variant"), - TYPE_TAG_NAME (outer_type), - rust_last_path_segment (TYPE_TAG_NAME (type))); + TYPE_NAME (outer_type), + rust_last_path_segment (TYPE_NAME (type))); else error(_("Attempting to access anonymous field %d " "of %s, which is not a tuple, tuple struct, or " "tuple-like variant"), - field_number, TYPE_TAG_NAME (type)); + field_number, TYPE_NAME (type)); } result = value_primitive_field (lhs, 0, field_number, type); @@ -1668,7 +1667,7 @@ tuple structs, and tuple-like enum variants")); if (rust_tuple_type_p (type) || rust_tuple_struct_type_p (type)) error (_("Attempting to access named field foo of tuple " "variant %s::%s, which has only anonymous fields"), - TYPE_TAG_NAME (outer_type), + TYPE_NAME (outer_type), rust_last_path_segment (TYPE_NAME (type))); TRY @@ -1679,7 +1678,7 @@ tuple structs, and tuple-like enum variants")); CATCH (except, RETURN_MASK_ERROR) { error (_("Could not find field %s of struct variant %s::%s"), - field_name, TYPE_TAG_NAME (outer_type), + field_name, TYPE_NAME (outer_type), rust_last_path_segment (TYPE_NAME (type))); } END_CATCH diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 0017f18c35..420cdd2742 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1344,8 +1344,8 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF; SYMBOL_VALUE (sym) = valu; SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN; - if (TYPE_TAG_NAME (SYMBOL_TYPE (sym)) == 0) - TYPE_TAG_NAME (SYMBOL_TYPE (sym)) + if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0) + TYPE_NAME (SYMBOL_TYPE (sym)) = obconcat (&objfile->objfile_obstack, SYMBOL_LINKAGE_NAME (sym), (char *) NULL); @@ -1702,7 +1702,7 @@ again: type. */ type = dbx_alloc_type (typenums, objfile); TYPE_CODE (type) = code; - TYPE_TAG_NAME (type) = type_name; + TYPE_NAME (type) = type_name; INIT_CPLUS_SPECIFIC (type); TYPE_STUB (type) = 1; @@ -1767,7 +1767,6 @@ again: copies of a type otherwise. */ replace_type (type, xtype); TYPE_NAME (type) = NULL; - TYPE_TAG_NAME (type) = NULL; } else { @@ -3428,9 +3427,9 @@ complain_about_struct_wipeout (struct type *type) const char *name = ""; const char *kind = ""; - if (TYPE_TAG_NAME (type)) + if (TYPE_NAME (type)) { - name = TYPE_TAG_NAME (type); + name = TYPE_NAME (type); switch (TYPE_CODE (type)) { case TYPE_CODE_STRUCT: kind = "struct "; break; @@ -3439,11 +3438,6 @@ complain_about_struct_wipeout (struct type *type) default: kind = ""; } } - else if (TYPE_NAME (type)) - { - name = TYPE_NAME (type); - kind = ""; - } else { name = ""; @@ -4476,7 +4470,7 @@ add_undefined_type_1 (struct type *type) static void add_undefined_type (struct type *type, int typenums[2]) { - if (TYPE_TAG_NAME (type) == NULL) + if (TYPE_NAME (type) == NULL) add_undefined_type_noname (type, typenums); else add_undefined_type_1 (type); @@ -4561,7 +4555,7 @@ cleanup_undefined_types_1 (void) struct pending *ppt; int i; /* Name of the type, without "struct" or "union". */ - const char *type_name = TYPE_TAG_NAME (*type); + const char *type_name = TYPE_NAME (*type); if (type_name == NULL) { diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 9adde044cd..4d56a3e952 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -540,7 +540,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol, if (SYMBOL_DOMAIN (symbol) == STRUCT_DOMAIN) { - if (TYPE_TAG_NAME (SYMBOL_TYPE (symbol))) + if (TYPE_NAME (SYMBOL_TYPE (symbol))) { LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth, &type_print_raw_options); diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 5d34e29a86..ddec6ee5d6 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -428,7 +428,6 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) { m_type = arch_composite_type (m_gdbarch, NULL, TYPE_CODE_STRUCT); TYPE_NAME (m_type) = xstrdup (e->name.c_str ()); - TYPE_TAG_NAME (m_type) = TYPE_NAME (m_type); for (const tdesc_type_field &f : e->fields) { diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp index 9322108565..4ec80812a9 100644 --- a/gdb/testsuite/gdb.base/maint.exp +++ b/gdb/testsuite/gdb.base/maint.exp @@ -345,7 +345,7 @@ foreach { test_name command } $test_list { set msg "maint print type" gdb_test_multiple "maint print type argc" $msg { - -re "type node $hex\r\nname .int. \\($hex\\)\r\ntagname .. \\($hex\\)\r\ncode $hex \\(TYPE_CODE_INT\\)\r\nlength \[24\]\r\nobjfile $hex\r\ntarget_type $hex\r\npointer_type $hex\r\nreference_type $hex\r\ntype_chain $hex\r\ninstance_flags $hex\r\nflags\r\nnfields 0 $hex\r\n$gdb_prompt $" { + -re "type node $hex\r\nname .int. \\($hex\\)\r\ncode $hex \\(TYPE_CODE_INT\\)\r\nlength \[24\]\r\nobjfile $hex\r\ntarget_type $hex\r\npointer_type $hex\r\nreference_type $hex\r\ntype_chain $hex\r\ninstance_flags $hex\r\nflags\r\nnfields 0 $hex\r\n$gdb_prompt $" { pass $msg } } diff --git a/gdb/testsuite/gdb.cp/typeid.exp b/gdb/testsuite/gdb.cp/typeid.exp index 4378dcbb59..1731b78b9d 100644 --- a/gdb/testsuite/gdb.cp/typeid.exp +++ b/gdb/testsuite/gdb.cp/typeid.exp @@ -27,7 +27,7 @@ proc do_typeid_tests {started} { global hex # We might see the standard type or gdb's internal type. - set type_re "(std::type_info|struct gdb_gnu_v3_type_info)" + set type_re "(std::type_info|gdb_gnu_v3_type_info)" foreach simple_var {i cp ccp ca b} { diff --git a/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp b/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp index 41eff9237c..31707bbd0c 100644 --- a/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp +++ b/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp @@ -38,4 +38,5 @@ gdb_test "show cp-abi" {The currently selected C\+\+ ABI is "gnu-v3".*} gdb_load ${binfile} +gdb_test_no_output "set language c++" gdb_test "ptype c" "type = struct C {\[\r\n \t\]*private:\[\r\n \t\]*int \\(C::\\*fp\\)\\(C \\*( const)?\\);\[\r\n \t\]*}" diff --git a/gdb/testsuite/gdb.dwarf2/method-ptr.exp b/gdb/testsuite/gdb.dwarf2/method-ptr.exp index 5a4f05350e..7fe755cb7d 100644 --- a/gdb/testsuite/gdb.dwarf2/method-ptr.exp +++ b/gdb/testsuite/gdb.dwarf2/method-ptr.exp @@ -82,5 +82,6 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \ return -1 } +gdb_test_no_output "set language c++" gdb_test "ptype the_typedef" \ "type = int \\(S::\\*\\)\\(S \\* const, float\\)" diff --git a/gdb/testsuite/gdb.xml/tdesc-regs.exp b/gdb/testsuite/gdb.xml/tdesc-regs.exp index bb7b9be16c..94d4007a89 100644 --- a/gdb/testsuite/gdb.xml/tdesc-regs.exp +++ b/gdb/testsuite/gdb.xml/tdesc-regs.exp @@ -179,7 +179,7 @@ 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\\)\\)\\)" gdb_test "ptype \$unionreg" \ - "type = union {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}" + "type = union vecint {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}" gdb_test "ptype \$unionreg.v4" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)" gdb_test "ptype \$structreg" \ "type = struct struct1 {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}" @@ -189,7 +189,7 @@ gdb_test "ptype \$bitfields" \ gdb_test "ptype \$flags" \ "type = flag flags {\r\n *bool 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-3;\r\n *bool C @4;\r\n *uint32_t D @5;\r\n *uint32_t @6-7;\r\n *enum {yes = 1, no = 0, maybe = 2, so} Z @8-9;\r\n}" + "type = flag mixed_flags {\r\n *bool A @0;\r\n *uint32_t B @1-3;\r\n *bool C @4;\r\n *uint32_t D @5;\r\n *uint32_t @6-7;\r\n *enum Z_values {yes = 1, no = 0, maybe = 2, so} Z @8-9;\r\n}" # Reggroups should have at least general and the extra foo group gdb_test "maintenance print reggroups" \ " Group\[ \t\]+Type\[ \t\]+\r\n.* general\[ \t\]+user\[ \t\]+\r\n.* foo\[ \t\]+user\[ \t\]+" diff --git a/gdb/valarith.c b/gdb/valarith.c index 58e3a09c37..d2dd590064 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -61,8 +61,6 @@ find_size_for_pointer_math (struct type *ptr_type) name = TYPE_NAME (ptr_target); if (name == NULL) - name = TYPE_TAG_NAME (ptr_target); - if (name == NULL) error (_("Cannot perform pointer math on incomplete types, " "try casting to a known type, or void *.")); else diff --git a/gdb/valops.c b/gdb/valops.c index 1f655b5187..cb51a2688e 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -3243,7 +3243,7 @@ enum_constant_from_type (struct type *type, const char *name) } error (_("no constant named \"%s\" in enum \"%s\""), - name, TYPE_TAG_NAME (type)); + name, TYPE_NAME (type)); } /* C++: Given an aggregate type CURTYPE, and a member name NAME, @@ -3581,7 +3581,7 @@ value_namespace_elt (const struct type *curtype, if (retval == NULL) error (_("No symbol \"%s\" in namespace \"%s\"."), - name, TYPE_TAG_NAME (curtype)); + name, TYPE_NAME (curtype)); return retval; } @@ -3597,7 +3597,7 @@ value_maybe_namespace_elt (const struct type *curtype, const char *name, int want_address, enum noside noside) { - const char *namespace_name = TYPE_TAG_NAME (curtype); + const char *namespace_name = TYPE_NAME (curtype); struct block_symbol sym; struct value *result;