diff --git a/gdb/ChangeLog b/gdb/ChangeLog index def9db59b8..3f92a6d6c5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2020-05-16 Simon Marchi + + * gdbtypes.h (struct type) : New methods. + (TYPE_CODE): Use type::name. Change all call sites used to set + the name to use type::set_name instead. + 2020-05-16 Tom Tromey * top.c (quit_force): Update. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index e5288e2370..98488242c8 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2144,7 +2144,7 @@ constrained_packed_array_type (struct type *type, long *elt_bits) elt_bits); create_array_type (new_type, new_elt_type, index_type); TYPE_FIELD_BITSIZE (new_type, 0) = *elt_bits; - TYPE_NAME (new_type) = ada_type_name (type); + new_type->set_name (ada_type_name (type)); if ((check_typedef (index_type)->code () == TYPE_CODE_RANGE && is_dynamic_type (check_typedef (index_type))) @@ -8029,7 +8029,7 @@ empty_record (struct type *templ) TYPE_NFIELDS (type) = 0; TYPE_FIELDS (type) = NULL; INIT_NONE_SPECIFIC (type); - TYPE_NAME (type) = ""; + type->set_name (""); TYPE_LENGTH (type) = 0; return type; } @@ -8087,7 +8087,7 @@ ada_template_to_fixed_record_type_1 (struct type *type, TYPE_FIELDS (rtype) = (struct field *) TYPE_ALLOC (rtype, nfields * sizeof (struct field)); memset (TYPE_FIELDS (rtype), 0, sizeof (struct field) * nfields); - TYPE_NAME (rtype) = ada_type_name (type); + rtype->set_name (ada_type_name (type)); TYPE_FIXED_INSTANCE (rtype) = 1; off = 0; @@ -8363,7 +8363,7 @@ template_to_static_fixed_type (struct type *type0) TYPE_ALLOC (type, nfields * sizeof (struct field)); memcpy (TYPE_FIELDS (type), TYPE_FIELDS (type0), sizeof (struct field) * nfields); - TYPE_NAME (type) = ada_type_name (type0); + type->set_name (ada_type_name (type0)); TYPE_FIXED_INSTANCE (type) = 1; TYPE_LENGTH (type) = 0; } @@ -8412,7 +8412,7 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr, (struct field *) TYPE_ALLOC (rtype, nfields * sizeof (struct field)); memcpy (TYPE_FIELDS (rtype), TYPE_FIELDS (type), sizeof (struct field) * nfields); - TYPE_NAME (rtype) = ada_type_name (type); + rtype->set_name (ada_type_name (type)); TYPE_FIXED_INSTANCE (rtype) = 1; TYPE_LENGTH (rtype) = TYPE_LENGTH (type); @@ -8734,7 +8734,7 @@ to_fixed_array_type (struct type *type0, struct value *dval, /* We want to preserve the type name. This can be useful when trying to get the type name of a value that has already been printed (for instance, if the user did "print VAR; whatis $". */ - TYPE_NAME (result) = TYPE_NAME (type0); + result->set_name (TYPE_NAME (type0)); if (constrained_packed_array_p) { @@ -8978,7 +8978,7 @@ static_unwrap_type (struct type *type) { struct type *type1 = TYPE_FIELD_TYPE (ada_check_typedef (type), 0); if (ada_type_name (type1) == NULL) - TYPE_NAME (type1) = ada_type_name (type); + type1->set_name (ada_type_name (type)); return static_unwrap_type (type1); } @@ -9420,7 +9420,7 @@ unwrap_value (struct value *val) struct type *val_type = ada_check_typedef (value_type (v)); if (ada_type_name (val_type) == NULL) - TYPE_NAME (val_type) = ada_type_name (type); + val_type->set_name (ada_type_name (type)); return unwrap_value (v); } @@ -11674,7 +11674,7 @@ to_fixed_range_type (struct type *raw_type, struct value *dval) to match the size of the base_type, which is not what we want. Set it back to the original range type's length. */ TYPE_LENGTH (type) = TYPE_LENGTH (raw_type); - TYPE_NAME (type) = name; + type->set_name (name); return type; } } @@ -13836,8 +13836,8 @@ ada_language_arch_info (struct gdbarch *gdbarch, lai->primitive_type_vector [ada_primitive_type_system_address] = lookup_pointer_type (arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void")); - TYPE_NAME (lai->primitive_type_vector [ada_primitive_type_system_address]) - = "system__address"; + lai->primitive_type_vector [ada_primitive_type_system_address] + ->set_name ("system__address"); /* Create the equivalent of the System.Storage_Elements.Storage_Offset type. This is a signed integral type whose size is the same as diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 40bffbb2dd..45df1bd39d 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -3920,7 +3920,7 @@ arm_neon_double_type (struct gdbarch *gdbarch) append_composite_type_field (t, "f64", elem); TYPE_VECTOR (t) = 1; - TYPE_NAME (t) = "neon_d"; + t->set_name ("neon_d"); tdep->neon_double_type = t; } @@ -3959,7 +3959,7 @@ arm_neon_quad_type (struct gdbarch *gdbarch) append_composite_type_field (t, "f64", init_vector_type (elem, 2)); TYPE_VECTOR (t) = 1; - TYPE_NAME (t) = "neon_q"; + t->set_name ("neon_q"); tdep->neon_quad_type = t; } diff --git a/gdb/coffread.c b/gdb/coffread.c index 7e3cb4a6fd..c08c9de2ff 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1469,7 +1469,7 @@ patch_type (struct type *type, struct type *real_type) process_coff_symbol. */ if (TYPE_NAME (target)) xfree ((char*) TYPE_NAME (target)); - TYPE_NAME (target) = xstrdup (TYPE_NAME (real_target)); + target->set_name (xstrdup (TYPE_NAME (real_target))); } } @@ -1684,8 +1684,7 @@ process_coff_symbol (struct coff_symbol *cs, ; } else - TYPE_NAME (SYMBOL_TYPE (sym)) = - xstrdup (sym->linkage_name ()); + SYMBOL_TYPE (sym)->set_name (xstrdup (sym->linkage_name ())); } /* Keep track of any type which points to empty structured @@ -1720,7 +1719,7 @@ process_coff_symbol (struct coff_symbol *cs, if (sym->linkage_name () != NULL && *sym->linkage_name () != '~' && *sym->linkage_name () != '.') - TYPE_NAME (SYMBOL_TYPE (sym)) = xstrdup (sym->linkage_name ()); + SYMBOL_TYPE (sym)->set_name (xstrdup (sym->linkage_name ())); add_symbol_to_list (sym, get_file_symbols ()); break; @@ -1881,7 +1880,7 @@ decode_base_type (struct coff_symbol *cs, /* Anonymous structure type. */ type = coff_alloc_type (cs->c_symnum); type->set_code (TYPE_CODE_STRUCT); - TYPE_NAME (type) = NULL; + type->set_name (NULL); INIT_CPLUS_SPECIFIC (type); TYPE_LENGTH (type) = 0; TYPE_FIELDS (type) = 0; @@ -1901,7 +1900,7 @@ decode_base_type (struct coff_symbol *cs, { /* Anonymous union type. */ type = coff_alloc_type (cs->c_symnum); - TYPE_NAME (type) = NULL; + type->set_name (NULL); INIT_CPLUS_SPECIFIC (type); TYPE_LENGTH (type) = 0; TYPE_FIELDS (type) = 0; @@ -1923,7 +1922,7 @@ decode_base_type (struct coff_symbol *cs, /* Anonymous enum type. */ type = coff_alloc_type (cs->c_symnum); type->set_code (TYPE_CODE_ENUM); - TYPE_NAME (type) = NULL; + type->set_name (NULL); TYPE_LENGTH (type) = 0; TYPE_FIELDS (type) = 0; TYPE_NFIELDS (type) = 0; diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c index 955238bb01..7e5b71eece 100644 --- a/gdb/csky-tdep.c +++ b/gdb/csky-tdep.c @@ -267,7 +267,7 @@ csky_vector_type (struct gdbarch *gdbarch) init_vector_type (bt->builtin_int8, 16)); TYPE_VECTOR (t) = 1; - TYPE_NAME (t) = "builtin_type_vec128i"; + t->set_name ("builtin_type_vec128i"); return t; } diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 74355a019b..b5bdb5f9cf 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -596,7 +596,7 @@ read_structure_type (struct ctf_context *ccp, ctf_id_t tid) gdb::unique_xmalloc_ptr name (ctf_type_aname_raw (fp, tid)); if (name != NULL && strlen (name.get() ) != 0) - TYPE_NAME (type) = obstack_strdup (&of->objfile_obstack, name.get ()); + type->set_name (obstack_strdup (&of->objfile_obstack, name.get ())); kind = ctf_type_kind (fp, tid); if (kind == CTF_K_UNION) @@ -654,7 +654,7 @@ read_func_kind_type (struct ctf_context *ccp, ctf_id_t tid) gdb::unique_xmalloc_ptr name (ctf_type_aname_raw (fp, tid)); if (name != NULL && strlen (name.get ()) != 0) - TYPE_NAME (type) = obstack_strdup (&of->objfile_obstack, name.get ()); + type->set_name (obstack_strdup (&of->objfile_obstack, name.get ())); type->set_code (TYPE_CODE_FUNC); ctf_func_type_info (fp, tid, &cfi); @@ -680,7 +680,7 @@ read_enum_type (struct ctf_context *ccp, ctf_id_t tid) gdb::unique_xmalloc_ptr name (ctf_type_aname_raw (fp, tid)); if (name != NULL && strlen (name.get ()) != 0) - TYPE_NAME (type) = obstack_strdup (&of->objfile_obstack, name.get ()); + type->set_name (obstack_strdup (&of->objfile_obstack, name.get ())); type->set_code (TYPE_CODE_ENUM); TYPE_LENGTH (type) = ctf_type_size (fp, tid); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 245ce07de7..2c81a4eed6 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9343,9 +9343,9 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) TYPE_FIELD (type, 1) = saved_field; TYPE_FIELD_NAME (type, 1) = rust_last_path_segment (TYPE_NAME (TYPE_FIELD_TYPE (type, 1))); - TYPE_NAME (TYPE_FIELD_TYPE (type, 1)) - = rust_fully_qualify (&objfile->objfile_obstack, TYPE_NAME (type), - TYPE_FIELD_NAME (type, 1)); + TYPE_FIELD_TYPE (type, 1)->set_name + (rust_fully_qualify (&objfile->objfile_obstack, TYPE_NAME (type), + TYPE_FIELD_NAME (type, 1))); const char *dataless_name = rust_fully_qualify (&objfile->objfile_obstack, TYPE_NAME (type), @@ -9374,9 +9374,9 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) const char *variant_name = rust_last_path_segment (TYPE_NAME (field_type)); TYPE_FIELD_NAME (type, 0) = variant_name; - TYPE_NAME (field_type) - = rust_fully_qualify (&objfile->objfile_obstack, - TYPE_NAME (type), variant_name); + field_type->set_name + (rust_fully_qualify (&objfile->objfile_obstack, + TYPE_NAME (type), variant_name)); } else { @@ -9477,9 +9477,9 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) ++TYPE_FIELDS (sub_type); } TYPE_FIELD_NAME (type, i) = variant_name; - TYPE_NAME (sub_type) - = rust_fully_qualify (&objfile->objfile_obstack, - TYPE_NAME (type), variant_name); + sub_type->set_name + (rust_fully_qualify (&objfile->objfile_obstack, + TYPE_NAME (type), variant_name)); } /* Indicate that this is a variant type. */ @@ -15356,13 +15356,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_NAME (type) = full_name; + type->set_name (full_name); } else { /* The name is already allocated along with this objfile, so we don't need to duplicate it for the type. */ - TYPE_NAME (type) = name; + type->set_name (name); } } @@ -15939,7 +15939,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu) type->set_code (TYPE_CODE_ENUM); name = dwarf2_full_name (NULL, die, cu); if (name != NULL) - TYPE_NAME (type) = name; + type->set_name (name); attr = dwarf2_attr (die, DW_AT_type, cu); if (attr != NULL) @@ -16186,7 +16186,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu) name = dwarf2_name (die, cu); if (name) - TYPE_NAME (type) = name; + type->set_name (name); maybe_set_alignment (cu, die, type); @@ -17757,7 +17757,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) name = dwarf2_name (die, cu); if (name) - TYPE_NAME (range_type) = name; + range_type->set_name (name); attr = dwarf2_attr (die, DW_AT_byte_size, cu); if (attr != nullptr) @@ -17780,7 +17780,7 @@ read_unspecified_type (struct die_info *die, struct dwarf2_cu *cu) type = init_type (cu->per_cu->dwarf2_per_objfile->objfile, TYPE_CODE_VOID,0, NULL); - TYPE_NAME (type) = dwarf2_name (die, cu); + type->set_name (dwarf2_name (die, cu)); /* In Ada, an unspecified type is typically used when the description of the type is deferred to a different unit. When encountering @@ -20905,7 +20905,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, with this objfile, so we don't need to duplicate it for the type. */ if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0) - TYPE_NAME (SYMBOL_TYPE (sym)) = sym->search_name (); + SYMBOL_TYPE (sym)->set_name (sym->search_name ()); } } } diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index 5deb251a3a..acf787c706 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -1629,7 +1629,7 @@ fbsd_get_siginfo_type (struct gdbarch *gdbarch) /* union sigval */ sigval_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION); - TYPE_NAME (sigval_type) = xstrdup ("sigval"); + sigval_type->set_name (xstrdup ("sigval")); append_composite_type_field (sigval_type, "sival_int", int_type); append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type); @@ -1679,7 +1679,7 @@ fbsd_get_siginfo_type (struct gdbarch *gdbarch) /* struct siginfo */ siginfo_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - TYPE_NAME (siginfo_type) = xstrdup ("siginfo"); + siginfo_type->set_name (xstrdup ("siginfo")); append_composite_type_field (siginfo_type, "si_signo", int_type); append_composite_type_field (siginfo_type, "si_errno", int_type); append_composite_type_field (siginfo_type, "si_code", int_type); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 8f45af6ae7..10c44ddbca 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3174,7 +3174,7 @@ init_type (struct objfile *objfile, enum type_code code, int bit, set_type_code (type, code); gdb_assert ((bit % TARGET_CHAR_BIT) == 0); TYPE_LENGTH (type) = bit / TARGET_CHAR_BIT; - TYPE_NAME (type) = name; + type->set_name (name); return type; } @@ -3307,7 +3307,7 @@ init_complex_type (const char *name, struct type *target_type) t = alloc_type_copy (target_type); set_type_code (t, TYPE_CODE_COMPLEX); TYPE_LENGTH (t) = 2 * TYPE_LENGTH (target_type); - TYPE_NAME (t) = name; + t->set_name (name); TYPE_TARGET_TYPE (t) = target_type; TYPE_MAIN_TYPE (target_type)->flds_bnds.complex_type = t; @@ -5290,7 +5290,7 @@ copy_type_recursive (struct objfile *objfile, TYPE_OWNER (new_type).gdbarch = get_type_arch (type); if (TYPE_NAME (type)) - TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type)); + new_type->set_name (xstrdup (TYPE_NAME (type))); TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type); TYPE_LENGTH (new_type) = TYPE_LENGTH (type); @@ -5443,7 +5443,7 @@ arch_type (struct gdbarch *gdbarch, TYPE_LENGTH (type) = bit / TARGET_CHAR_BIT; if (name) - TYPE_NAME (type) = gdbarch_obstack_strdup (gdbarch, name); + type->set_name (gdbarch_obstack_strdup (gdbarch, name)); return type; } @@ -5615,7 +5615,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_NAME (t) = name; + t->set_name (name); INIT_CPLUS_SPECIFIC (t); return t; } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index a8cd44a75b..aeed06ba5d 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -889,6 +889,18 @@ struct type this->main_type->code = code; } + /* Get the name of this type. */ + const char *name () const + { + return this->main_type->name; + } + + /* Set the name of this type. */ + void set_name (const char *name) + { + this->main_type->name = name; + } + /* * Return the dynamic property of the requested KIND from this type's list of dynamic properties. */ dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const; @@ -1404,7 +1416,7 @@ 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_NAME(thistype) ((thistype)->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 1fe3a9670c..df5818b300 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -167,7 +167,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_NAME (t) = "gdb_gnu_v3_abi_vtable"; + t->set_name ("gdb_gnu_v3_abi_vtable"); INIT_CPLUS_SPECIFIC (t); return make_type_with_address_space (t, TYPE_INSTANCE_FLAG_CODE_SPACE); @@ -1056,7 +1056,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_NAME (t) = "gdb_gnu_v3_type_info"; + t->set_name ("gdb_gnu_v3_type_info"); INIT_CPLUS_SPECIFIC (t); return t; diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 0f8d9aa740..f4fe3a20c7 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -3080,7 +3080,7 @@ i386_bnd_type (struct gdbarch *gdbarch) append_composite_type_field (t, "lbound", bt->builtin_data_ptr); append_composite_type_field (t, "ubound", bt->builtin_data_ptr); - TYPE_NAME (t) = "builtin_type_bound128"; + t->set_name ("builtin_type_bound128"); tdep->i386_bnd_type = t; } @@ -3133,7 +3133,7 @@ i386_zmm_type (struct gdbarch *gdbarch) init_vector_type (bt->builtin_int128, 4)); TYPE_VECTOR (t) = 1; - TYPE_NAME (t) = "builtin_type_vec512i"; + t->set_name ("builtin_type_vec512i"); tdep->i386_zmm_type = t; } @@ -3186,7 +3186,7 @@ i386_ymm_type (struct gdbarch *gdbarch) init_vector_type (bt->builtin_int128, 2)); TYPE_VECTOR (t) = 1; - TYPE_NAME (t) = "builtin_type_vec256i"; + t->set_name ("builtin_type_vec256i"); tdep->i386_ymm_type = t; } @@ -3228,7 +3228,7 @@ i386_mmx_type (struct gdbarch *gdbarch) init_vector_type (bt->builtin_int8, 8)); TYPE_VECTOR (t) = 1; - TYPE_NAME (t) = "builtin_type_vec64i"; + t->set_name ("builtin_type_vec64i"); tdep->i386_mmx_type = t; } diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index ed84d6ace6..0f9559355f 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -258,7 +258,7 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch, /* sival_t */ sigval_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION); - TYPE_NAME (sigval_type) = xstrdup ("sigval_t"); + sigval_type->set_name (xstrdup ("sigval_t")); append_composite_type_field (sigval_type, "sival_int", int_type); append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type); @@ -352,7 +352,7 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch, /* struct siginfo */ siginfo_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - TYPE_NAME (siginfo_type) = xstrdup ("siginfo"); + siginfo_type->set_name (xstrdup ("siginfo")); append_composite_type_field (siginfo_type, "si_signo", int_type); append_composite_type_field (siginfo_type, "si_errno", int_type); append_composite_type_field (siginfo_type, "si_code", int_type); diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index ba53512636..cd08d26baf 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1010,10 +1010,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_NAME (t) = NULL; + t->set_name (NULL); else - TYPE_NAME (t) = obconcat (&mdebugread_objfile->objfile_obstack, - name, (char *) NULL); + t->set_name (obconcat (&mdebugread_objfile->objfile_obstack, + name, (char *) NULL)); t->set_code (type_code); TYPE_LENGTH (t) = sh->value; @@ -1324,7 +1324,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, for anything except pointers or functions. */ } else - TYPE_NAME (SYMBOL_TYPE (s)) = s->linkage_name (); + SYMBOL_TYPE (s)->set_name (s->linkage_name ()); } break; @@ -1674,11 +1674,11 @@ 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_NAME (tp) = NULL; + tp->set_name (NULL); else if (TYPE_NAME (tp) == NULL || strcmp (TYPE_NAME (tp), name) != 0) - TYPE_NAME (tp) - = obstack_strdup (&mdebugread_objfile->objfile_obstack, name); + tp->set_name (obstack_strdup (&mdebugread_objfile->objfile_obstack, + name)); } } @@ -1713,8 +1713,8 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs, } if (TYPE_NAME (tp) == NULL || strcmp (TYPE_NAME (tp), name) != 0) - TYPE_NAME (tp) - = obstack_strdup (&mdebugread_objfile->objfile_obstack, name); + tp->set_name (obstack_strdup (&mdebugread_objfile->objfile_obstack, + name)); } } if (t->bt == btTypedef) @@ -4736,7 +4736,7 @@ new_type (char *name) struct type *t; t = alloc_type (mdebugread_objfile); - TYPE_NAME (t) = name; + t->set_name (name); INIT_CPLUS_SPECIFIC (t); return t; } diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 0cd3501c4d..d686c6ea92 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -1105,21 +1105,21 @@ build_opencl_types (struct gdbarch *gdbarch) #define BUILD_OCL_VTYPES(TYPE)\ types[opencl_primitive_type_##TYPE##2] \ = init_vector_type (types[opencl_primitive_type_##TYPE], 2); \ - TYPE_NAME (types[opencl_primitive_type_##TYPE##2]) = OCL_STRING(TYPE ## 2); \ + types[opencl_primitive_type_##TYPE##2]->set_name (OCL_STRING(TYPE ## 2)); \ types[opencl_primitive_type_##TYPE##3] \ = init_vector_type (types[opencl_primitive_type_##TYPE], 3); \ - TYPE_NAME (types[opencl_primitive_type_##TYPE##3]) = OCL_STRING(TYPE ## 3); \ + types[opencl_primitive_type_##TYPE##3]->set_name (OCL_STRING(TYPE ## 3)); \ TYPE_LENGTH (types[opencl_primitive_type_##TYPE##3]) \ = 4 * TYPE_LENGTH (types[opencl_primitive_type_##TYPE]); \ types[opencl_primitive_type_##TYPE##4] \ = init_vector_type (types[opencl_primitive_type_##TYPE], 4); \ - TYPE_NAME (types[opencl_primitive_type_##TYPE##4]) = OCL_STRING(TYPE ## 4); \ + types[opencl_primitive_type_##TYPE##4]->set_name (OCL_STRING(TYPE ## 4)); \ types[opencl_primitive_type_##TYPE##8] \ = init_vector_type (types[opencl_primitive_type_##TYPE], 8); \ - TYPE_NAME (types[opencl_primitive_type_##TYPE##8]) = OCL_STRING(TYPE ## 8); \ + types[opencl_primitive_type_##TYPE##8]->set_name (OCL_STRING(TYPE ## 8)); \ types[opencl_primitive_type_##TYPE##16] \ = init_vector_type (types[opencl_primitive_type_##TYPE], 16); \ - TYPE_NAME (types[opencl_primitive_type_##TYPE##16]) = OCL_STRING(TYPE ## 16) + types[opencl_primitive_type_##TYPE##16]->set_name (OCL_STRING(TYPE ## 16)) types[opencl_primitive_type_char] = arch_integer_type (gdbarch, 8, 0, "char"); diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index c1c466f1a1..e4edd7ca3e 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -544,7 +544,7 @@ riscv_fpreg_d_type (struct gdbarch *gdbarch) append_composite_type_field (t, "float", bt->builtin_float); append_composite_type_field (t, "double", bt->builtin_double); TYPE_VECTOR (t) = 1; - TYPE_NAME (t) = "builtin_type_fpreg_d"; + t->set_name ("builtin_type_fpreg_d"); tdep->riscv_fpreg_d_type = t; } diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 3ccb307ec2..84278e708e 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -2274,7 +2274,7 @@ rs6000_builtin_type_vec64 (struct gdbarch *gdbarch) init_vector_type (bt->builtin_int8, 8)); TYPE_VECTOR (t) = 1; - TYPE_NAME (t) = "ppc_builtin_type_vec64"; + t->set_name ("ppc_builtin_type_vec64"); tdep->ppc_builtin_type_vec64 = t; } @@ -2321,7 +2321,7 @@ rs6000_builtin_type_vec128 (struct gdbarch *gdbarch) init_vector_type (bt->builtin_int8, 16)); TYPE_VECTOR (t) = 1; - TYPE_NAME (t) = "ppc_builtin_type_vec128"; + t->set_name ("ppc_builtin_type_vec128"); tdep->ppc_builtin_type_vec128 = t; } diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index b8cc4daab5..3fa550d769 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -982,7 +982,7 @@ rust_composite_type (struct type *original, ++nfields; result->set_code (TYPE_CODE_STRUCT); - TYPE_NAME (result) = name; + result->set_name (name); TYPE_NFIELDS (result) = nfields; TYPE_FIELDS (result) diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 716b5f3f53..12e164c2d2 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1294,12 +1294,10 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, /* Pascal accepts names for pointer types. */ if (get_current_subfile ()->language == language_pascal) - { - TYPE_NAME (SYMBOL_TYPE (sym)) = sym->linkage_name (); - } + SYMBOL_TYPE (sym)->set_name (sym->linkage_name ()); } else - TYPE_NAME (SYMBOL_TYPE (sym)) = sym->linkage_name (); + SYMBOL_TYPE (sym)->set_name (sym->linkage_name ()); } add_symbol_to_list (sym, get_file_symbols ()); @@ -1314,12 +1312,12 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, SYMBOL_VALUE (struct_sym) = valu; SYMBOL_DOMAIN (struct_sym) = STRUCT_DOMAIN; if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0) - TYPE_NAME (SYMBOL_TYPE (sym)) - = obconcat (&objfile->objfile_obstack, sym->linkage_name (), - (char *) NULL); + SYMBOL_TYPE (sym)->set_name + (obconcat (&objfile->objfile_obstack, sym->linkage_name (), + (char *) NULL)); add_symbol_to_list (struct_sym, get_file_symbols ()); } - + break; case 'T': @@ -1341,9 +1339,9 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, SYMBOL_VALUE (sym) = valu; SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN; if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0) - TYPE_NAME (SYMBOL_TYPE (sym)) - = obconcat (&objfile->objfile_obstack, sym->linkage_name (), - (char *) NULL); + SYMBOL_TYPE (sym)->set_name + (obconcat (&objfile->objfile_obstack, sym->linkage_name (), + (char *) NULL)); add_symbol_to_list (sym, get_file_symbols ()); if (synonym) @@ -1356,9 +1354,9 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, SYMBOL_VALUE (typedef_sym) = valu; SYMBOL_DOMAIN (typedef_sym) = VAR_DOMAIN; if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0) - TYPE_NAME (SYMBOL_TYPE (sym)) - = obconcat (&objfile->objfile_obstack, sym->linkage_name (), - (char *) NULL); + SYMBOL_TYPE (sym)->set_name + (obconcat (&objfile->objfile_obstack, sym->linkage_name (), + (char *) NULL)); add_symbol_to_list (typedef_sym, get_file_symbols ()); } break; @@ -1688,7 +1686,7 @@ again: type. */ type = dbx_alloc_type (typenums, objfile); type->set_code (code); - TYPE_NAME (type) = type_name; + type->set_name (type_name); INIT_CPLUS_SPECIFIC (type); TYPE_STUB (type) = 1; @@ -1752,7 +1750,7 @@ again: "complete_this_type" function, but never create unnecessary copies of a type otherwise. */ replace_type (type, xtype); - TYPE_NAME (type) = NULL; + type->set_name (NULL); } else { diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 2ec07a3e3b..20a3a640f4 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -156,7 +156,7 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) type *element_gdb_type = make_gdb_type (m_gdbarch, e->element_type); m_type = init_vector_type (element_gdb_type, e->count); - TYPE_NAME (m_type) = xstrdup (e->name.c_str ()); + m_type->set_name (xstrdup (e->name.c_str ())); return; } @@ -192,7 +192,7 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) void make_gdb_type_struct (const tdesc_type_with_fields *e) { m_type = arch_composite_type (m_gdbarch, NULL, TYPE_CODE_STRUCT); - TYPE_NAME (m_type) = xstrdup (e->name.c_str ()); + m_type->set_name (xstrdup (e->name.c_str ())); for (const tdesc_type_field &f : e->fields) { @@ -247,7 +247,7 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype) void make_gdb_type_union (const tdesc_type_with_fields *e) { m_type = arch_composite_type (m_gdbarch, NULL, TYPE_CODE_UNION); - TYPE_NAME (m_type) = xstrdup (e->name.c_str ()); + m_type->set_name (xstrdup (e->name.c_str ())); for (const tdesc_type_field &f : e->fields) { diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index 7772df4c28..086038af0d 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -230,7 +230,7 @@ windows_get_tlb_type (struct gdbarch *gdbarch) /* list entry */ list_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - TYPE_NAME (list_type) = xstrdup ("list"); + list_type->set_name (xstrdup ("list")); module_list_ptr_type = void_ptr_type; @@ -242,7 +242,7 @@ windows_get_tlb_type (struct gdbarch *gdbarch) /* Structured Exception Handler */ seh_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - TYPE_NAME (seh_type) = xstrdup ("seh"); + seh_type->set_name (xstrdup ("seh")); seh_ptr_type = arch_type (gdbarch, TYPE_CODE_PTR, TYPE_LENGTH (void_ptr_type) * TARGET_CHAR_BIT, @@ -255,7 +255,7 @@ windows_get_tlb_type (struct gdbarch *gdbarch) /* struct _PEB_LDR_DATA */ peb_ldr_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - TYPE_NAME (peb_ldr_type) = xstrdup ("peb_ldr_data"); + peb_ldr_type->set_name (xstrdup ("peb_ldr_data")); append_composite_type_field (peb_ldr_type, "length", dword32_type); append_composite_type_field (peb_ldr_type, "initialized", dword32_type); @@ -324,7 +324,7 @@ windows_get_tlb_type (struct gdbarch *gdbarch) /* struct process environment block */ peb_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - TYPE_NAME (peb_type) = xstrdup ("peb"); + peb_type->set_name (xstrdup ("peb")); /* First bytes contain several flags. */ append_composite_type_field (peb_type, "flags", dword_ptr_type); @@ -343,7 +343,7 @@ windows_get_tlb_type (struct gdbarch *gdbarch) /* struct thread information block */ tib_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - TYPE_NAME (tib_type) = xstrdup ("tib"); + tib_type->set_name (xstrdup ("tib")); /* uint32_t current_seh; %fs:0x0000 */ append_composite_type_field (tib_type, "current_seh", seh_ptr_type);