X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fdwarf2read.c;h=51fb06e3b6617fbda5c4203cdae56c4253ba74c1;hb=452f10a186cdb18091f590315c55488b871812e3;hp=40626a1562f0ca96106dfa78b727b0cb712e704f;hpb=8d9a2568651d55eb518d3ac6c0dd0b4719da7f77;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 40626a1562..51fb06e3b6 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1,6 +1,7 @@ /* DWARF 2 debugging format support for GDB. - Copyright (C) 1994-2019 Free Software Foundation, Inc. + Copyright (C) 1994-2020 Free Software Foundation, Inc. + Copyright (C) 2019-2020 Advanced Micro Devices, Inc. All rights reserved. Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology, Inc. with support from Florida State University (under contract @@ -1339,15 +1340,6 @@ struct dwarf_block const gdb_byte *data; }; -#ifndef ATTR_ALLOC_CHUNK -#define ATTR_ALLOC_CHUNK 4 -#endif - -/* Allocate fields for structs, unions and enums in this size. */ -#ifndef DW_FIELD_ALLOC_CHUNK -#define DW_FIELD_ALLOC_CHUNK 4 -#endif - /* FIXME: We might want to set this from BFD via bfd_arch_bits_per_byte, but this would require a corresponding change in unpack_field_as_long and friends. */ @@ -1910,6 +1902,9 @@ static void process_queue (struct dwarf2_per_objfile *dwarf2_per_objfile); static struct type *dwarf2_per_cu_addr_type (struct dwarf2_per_cu_data *per_cu); static struct type *dwarf2_per_cu_addr_sized_int_type (struct dwarf2_per_cu_data *per_cu, bool unsigned_p); +static struct type *dwarf2_per_cu_int_type + (struct dwarf2_per_cu_data *per_cu, int size_in_bytes, + bool unsigned_p); /* Class, the destructor of which frees all allocated queue entries. This will only have work to do if an error was thrown while processing the @@ -3176,7 +3171,7 @@ create_addrmap_from_index (struct dwarf2_per_objfile *dwarf2_per_objfile, iter = index->address_table.data (); end = iter + index->address_table.size (); - baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; while (iter < end) { @@ -3222,8 +3217,7 @@ create_addrmap_from_aranges (struct dwarf2_per_objfile *dwarf2_per_objfile, struct objfile *objfile = dwarf2_per_objfile->objfile; bfd *abfd = objfile->obfd; struct gdbarch *gdbarch = get_objfile_arch (objfile); - const CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)); + const CORE_ADDR baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; auto_obstack temp_obstack; addrmap *mutable_map = addrmap_create_mutable (&temp_obstack); @@ -5243,8 +5237,7 @@ dw2_find_pc_sect_compunit_symtab (struct objfile *objfile, if (!objfile->partial_symtabs->psymtabs_addrmap) return NULL; - CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)); + CORE_ADDR baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; data = (struct dwarf2_per_cu_data *) addrmap_find (objfile->partial_symtabs->psymtabs_addrmap, pc - baseaddr); if (!data) @@ -8074,7 +8067,7 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader, /* This must be done before calling dwarf2_build_include_psymtabs. */ pst->dirname = dwarf2_string_attr (comp_unit_die, DW_AT_comp_dir, cu); - baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; dwarf2_find_base_address (comp_unit_die, cu); @@ -8904,7 +8897,7 @@ partial_die_parent_scope (struct partial_die_info *pdi, /* Return the fully scoped name associated with PDI, from compilation unit CU. The result will be allocated with malloc. */ -static char * +static gdb::unique_xmalloc_ptr partial_die_full_name (struct partial_die_info *pdi, struct dwarf2_cu *cu) { @@ -8930,7 +8923,7 @@ partial_die_full_name (struct partial_die_info *pdi, attr.u.unsnd = to_underlying (pdi->sect_off); die = follow_die_ref (NULL, &attr, &ref_cu); - return xstrdup (dwarf2_full_name (NULL, die, ref_cu)); + return make_unique_xstrdup (dwarf2_full_name (NULL, die, ref_cu)); } } @@ -8938,7 +8931,8 @@ partial_die_full_name (struct partial_die_info *pdi, if (parent_scope == NULL) return NULL; else - return typename_concat (NULL, parent_scope, pdi->name, 0, cu); + return gdb::unique_xmalloc_ptr (typename_concat (NULL, parent_scope, + pdi->name, 0, cu)); } static void @@ -8951,13 +8945,13 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) CORE_ADDR addr = 0; const char *actual_name = NULL; CORE_ADDR baseaddr; - char *built_actual_name; - baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; - built_actual_name = partial_die_full_name (pdi, cu); + gdb::unique_xmalloc_ptr built_actual_name + = partial_die_full_name (pdi, cu); if (built_actual_name != NULL) - actual_name = built_actual_name; + actual_name = built_actual_name.get (); if (actual_name == NULL) actual_name = pdi->name; @@ -9050,10 +9044,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) /* Static Variable. Skip symbols whose value we cannot know (those without location descriptors or constant values). */ if (!has_loc && !pdi->has_const_value) - { - xfree (built_actual_name); - return; - } + return; add_psymbol_to_list (actual_name, built_actual_name != NULL, @@ -9103,10 +9094,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) union or class entry that does not have a byte size attribute and that has a DW_AT_declaration attribute." */ if (!pdi->has_byte_size && pdi->is_declaration) - { - xfree (built_actual_name); - return; - } + return; /* NOTE: carlton/2003-10-07: See comment in new_symbol about static vs. global. */ @@ -9131,8 +9119,6 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) default: break; } - - xfree (built_actual_name); } /* Read a partial die corresponding to a namespace; also, add a symbol @@ -9203,8 +9189,7 @@ add_partial_subprogram (struct partial_die_info *pdi, CORE_ADDR this_highpc; CORE_ADDR this_lowpc; - baseaddr = ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)); + baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; this_lowpc = (gdbarch_adjust_dwarf2_addr (gdbarch, pdi->lowpc + baseaddr) @@ -9901,7 +9886,7 @@ compute_delayed_physnames (struct dwarf2_cu *cu) static void fixup_go_packaging (struct dwarf2_cu *cu) { - char *package_name = NULL; + gdb::unique_xmalloc_ptr package_name; struct pending *list; int i; @@ -9913,27 +9898,27 @@ fixup_go_packaging (struct dwarf2_cu *cu) { struct symbol *sym = list->symbol[i]; - if (SYMBOL_LANGUAGE (sym) == language_go + if (sym->language () == language_go && SYMBOL_CLASS (sym) == LOC_BLOCK) { - char *this_package_name = go_symbol_package_name (sym); + gdb::unique_xmalloc_ptr this_package_name + (go_symbol_package_name (sym)); if (this_package_name == NULL) continue; if (package_name == NULL) - package_name = this_package_name; + package_name = std::move (this_package_name); else { struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile; - if (strcmp (package_name, this_package_name) != 0) + if (strcmp (package_name.get (), this_package_name.get ()) != 0) complaint (_("Symtab %s has objects from two different Go packages: %s and %s"), (symbol_symtab (sym) != NULL ? symtab_to_filename_for_display (symbol_symtab (sym)) : objfile_name (objfile)), - this_package_name, package_name); - xfree (this_package_name); + this_package_name.get (), package_name.get ()); } } } @@ -9943,14 +9928,14 @@ fixup_go_packaging (struct dwarf2_cu *cu) { struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile; const char *saved_package_name - = obstack_strdup (&objfile->per_bfd->storage_obstack, package_name); + = obstack_strdup (&objfile->per_bfd->storage_obstack, package_name.get ()); struct type *type = init_type (objfile, TYPE_CODE_MODULE, 0, saved_package_name); struct symbol *sym; sym = allocate_symbol (objfile); - SYMBOL_SET_LANGUAGE (sym, language_go, &objfile->objfile_obstack); - SYMBOL_SET_NAMES (sym, saved_package_name, false, objfile); + sym->set_language (language_go, &objfile->objfile_obstack); + sym->compute_and_set_names (saved_package_name, false, objfile->per_bfd); /* This is not VAR_DOMAIN because we want a way to ensure a lookup of, e.g., "main" finds the "main" module and not C's main(). */ SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN; @@ -9958,8 +9943,6 @@ fixup_go_packaging (struct dwarf2_cu *cu) SYMBOL_TYPE (sym) = type; add_symbol_to_list (sym, cu->get_builder ()->get_global_symbols ()); - - xfree (package_name); } } @@ -10415,7 +10398,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu, struct block *static_block; CORE_ADDR addr; - baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; /* Clear the list here in case something was left over. */ cu->method_list.clear (); @@ -10875,7 +10858,7 @@ dwarf2_compute_name (const char *name, /* For Fortran GDB prefers DW_AT_*linkage_name for the physname if present but otherwise compute it by typename_concat inside GDB. FIXME: Actually this is not really true, or at least not always true. - It's all very confusing. SYMBOL_SET_NAMES doesn't try to demangle + It's all very confusing. compute_and_set_names doesn't try to demangle Fortran names because there is no mangling standard. So new_symbol will set the demangled name to the result of dwarf2_full_name, and it is the demangled name that GDB uses if it exists. */ @@ -10909,11 +10892,10 @@ dwarf2_compute_name (const char *name, prefix = determine_prefix (die, cu); if (*prefix != '\0') { - char *prefixed_name = typename_concat (NULL, prefix, name, - physname, cu); + gdb::unique_xmalloc_ptr prefixed_name + (typename_concat (NULL, prefix, name, physname, cu)); - buf.puts (prefixed_name); - xfree (prefixed_name); + buf.puts (prefixed_name.get ()); } else buf.puts (name); @@ -11618,7 +11600,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu) CORE_ADDR baseaddr; prepare_one_comp_unit (cu, die, cu->language); - baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; get_scope_pc_bounds (die, &lowpc, &highpc, cu); @@ -12955,16 +12937,15 @@ open_dwo_file (struct dwarf2_per_objfile *dwarf2_per_objfile, if (comp_dir != NULL) { - char *path_to_try = concat (comp_dir, SLASH_STRING, - file_name, (char *) NULL); + gdb::unique_xmalloc_ptr path_to_try + (concat (comp_dir, SLASH_STRING, file_name, (char *) NULL)); /* NOTE: If comp_dir is a relative path, this will also try the search path, which seems useful. */ gdb_bfd_ref_ptr abfd (try_open_dwop_file (dwarf2_per_objfile, - path_to_try, + path_to_try.get (), 0 /*is_dwp*/, 1 /*search_cwd*/)); - xfree (path_to_try); if (abfd != NULL) return abfd; } @@ -13733,7 +13714,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) } } - baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; name = dwarf2_name (die, cu); @@ -13912,7 +13893,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu) struct die_info *child_die; CORE_ADDR baseaddr; - baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; /* Ignore blocks with missing or invalid low and high pc attributes. */ /* ??? Perhaps consider discontiguous blocks defined by DW_AT_ranges @@ -13986,7 +13967,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) int nparams; struct die_info *child_die; - baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; attr = dwarf2_attr (die, DW_AT_call_return_pc, cu); if (attr == NULL) @@ -14383,7 +14364,7 @@ dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu, } buffer = dwarf2_per_objfile->rnglists.buffer + offset; - baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; while (1) { @@ -14551,7 +14532,7 @@ dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu, } buffer = dwarf2_per_objfile->ranges.buffer + offset; - baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; while (1) { @@ -14629,8 +14610,7 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return, { struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile; struct gdbarch *gdbarch = get_objfile_arch (objfile); - const CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)); + const CORE_ADDR baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; int low_set = 0; CORE_ADDR low = 0; CORE_ADDR high = 0; @@ -15124,7 +15104,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, attr = dwarf2_attr (die, DW_AT_bit_offset, cu); if (attr != nullptr) { - if (gdbarch_bits_big_endian (gdbarch)) + if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) { /* For big endian bits, the DW_AT_bit_offset gives the additional bit offset from the MSB of the containing @@ -15252,13 +15232,18 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, /* Normally a DW_TAG_variant_part won't have a size, but our representation requires one, so set it to the maximum of the - child sizes. */ + child sizes, being sure to account for the offset at which + each child is seen. */ if (TYPE_LENGTH (fp->type) == 0) { unsigned max = 0; for (int i = 0; i < TYPE_NFIELDS (fp->type); ++i) - if (TYPE_LENGTH (TYPE_FIELD_TYPE (fp->type, i)) > max) - max = TYPE_LENGTH (TYPE_FIELD_TYPE (fp->type, i)); + { + unsigned len = ((TYPE_FIELD_BITPOS (fp->type, i) + 7) / 8 + + TYPE_LENGTH (TYPE_FIELD_TYPE (fp->type, i))); + if (len > max) + max = len; + } TYPE_LENGTH (fp->type) = max; } } @@ -15464,6 +15449,25 @@ dwarf2_is_constructor (struct die_info *die, struct dwarf2_cu *cu) && (type_name[len] == '\0' || type_name[len] == '<')); } +/* Check if the given VALUE is a recognized enum + dwarf_defaulted_attribute constant according to DWARF5 spec, + Table 7.24. */ + +static bool +is_valid_DW_AT_defaulted (ULONGEST value) +{ + switch (value) + { + case DW_DEFAULTED_no: + case DW_DEFAULTED_in_class: + case DW_DEFAULTED_out_of_class: + return true; + } + + complaint (_("unrecognized DW_AT_defaulted value (%s)"), pulongest (value)); + return false; +} + /* Add a member function to the proper fieldlist. */ static void @@ -15576,6 +15580,16 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, if (attr && DW_UNSND (attr) != 0) fnp->is_artificial = 1; + /* Check for defaulted methods. */ + attr = dwarf2_attr (die, DW_AT_defaulted, cu); + if (attr != nullptr && is_valid_DW_AT_defaulted (DW_UNSND (attr))) + fnp->defaulted = (enum dwarf_defaulted_attribute) DW_UNSND (attr); + + /* Check for deleted methods. */ + attr = dwarf2_attr (die, DW_AT_deleted, cu); + if (attr != nullptr && DW_UNSND (attr) != 0) + fnp->is_deleted = 1; + fnp->is_constructor = dwarf2_is_constructor (die, cu); /* Get index in virtual function table if it is a virtual member @@ -15815,6 +15829,52 @@ maybe_set_alignment (struct dwarf2_cu *cu, struct die_info *die, objfile_name (cu->per_cu->dwarf2_per_objfile->objfile)); } +/* Check if the given VALUE is a valid enum dwarf_calling_convention + constant for a type, according to DWARF5 spec, Table 5.5. */ + +static bool +is_valid_DW_AT_calling_convention_for_type (ULONGEST value) +{ + switch (value) + { + case DW_CC_normal: + case DW_CC_pass_by_reference: + case DW_CC_pass_by_value: + return true; + + default: + complaint (_("unrecognized DW_AT_calling_convention value " + "(%s) for a type"), pulongest (value)); + return false; + } +} + +/* Check if the given VALUE is a valid enum dwarf_calling_convention + constant for a subroutine, according to DWARF5 spec, Table 3.3, and + also according to GNU-specific values (see include/dwarf2.h). */ + +static bool +is_valid_DW_AT_calling_convention_for_subroutine (ULONGEST value) +{ + switch (value) + { + case DW_CC_normal: + case DW_CC_program: + case DW_CC_nocall: + return true; + + case DW_CC_GNU_renesas_sh: + case DW_CC_GNU_borland_fastcall_i386: + case DW_CC_GDB_IBM_OpenCL: + return true; + + default: + complaint (_("unrecognized DW_AT_calling_convention value " + "(%s) for a subroutine"), pulongest (value)); + return false; + } +} + /* Called when we find the DIE that starts a structure or union scope (definition) to create a type for the structure or union. Fill in the type's name and general properties; the members will not be @@ -15896,6 +15956,18 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu) if (cu->language == language_cplus && die->tag == DW_TAG_class_type) TYPE_DECLARED_CLASS (type) = 1; + /* Store the calling convention in the type if it's available in + the die. Otherwise the calling convention remains set to + the default value DW_CC_normal. */ + attr = dwarf2_attr (die, DW_AT_calling_convention, cu); + if (attr != nullptr + && is_valid_DW_AT_calling_convention_for_type (DW_UNSND (attr))) + { + ALLOCATE_CPLUS_STRUCT_TYPE (type); + TYPE_CPLUS_CALLING_CONVENTION (type) + = (enum dwarf_calling_convention) (DW_UNSND (attr)); + } + attr = dwarf2_attr (die, DW_AT_byte_size, cu); if (attr != nullptr) { @@ -16052,7 +16124,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) read the discriminant member, so we can record it later in the discriminant_info. */ bool is_variant_part = TYPE_FLAG_DISCRIMINATED_UNION (type); - sect_offset discr_offset; + sect_offset discr_offset {}; bool has_template_parameters = false; if (is_variant_part) @@ -16453,8 +16525,7 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) { struct die_info *child_die; struct symbol *sym; - struct field *fields = NULL; - int num_fields = 0; + std::vector fields; const char *name; child_die = die->child; @@ -16471,34 +16542,26 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu) { sym = new_symbol (child_die, this_type, cu); - if ((num_fields % DW_FIELD_ALLOC_CHUNK) == 0) - { - fields = (struct field *) - xrealloc (fields, - (num_fields + DW_FIELD_ALLOC_CHUNK) - * sizeof (struct field)); - } - - FIELD_NAME (fields[num_fields]) = sym->linkage_name (); - FIELD_TYPE (fields[num_fields]) = NULL; - SET_FIELD_ENUMVAL (fields[num_fields], SYMBOL_VALUE (sym)); - FIELD_BITSIZE (fields[num_fields]) = 0; + fields.emplace_back (); + struct field &field = fields.back (); - num_fields++; + FIELD_NAME (field) = sym->linkage_name (); + FIELD_TYPE (field) = NULL; + SET_FIELD_ENUMVAL (field, SYMBOL_VALUE (sym)); + FIELD_BITSIZE (field) = 0; } } child_die = sibling_die (child_die); } - if (num_fields) + if (!fields.empty ()) { - TYPE_NFIELDS (this_type) = num_fields; + TYPE_NFIELDS (this_type) = fields.size (); TYPE_FIELDS (this_type) = (struct field *) - TYPE_ALLOC (this_type, sizeof (struct field) * num_fields); - memcpy (TYPE_FIELDS (this_type), fields, - sizeof (struct field) * num_fields); - xfree (fields); + TYPE_ALLOC (this_type, sizeof (struct field) * fields.size ()); + memcpy (TYPE_FIELDS (this_type), fields.data (), + sizeof (struct field) * fields.size ()); } } @@ -17315,29 +17378,90 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu) struct gdbarch *gdbarch = get_objfile_arch (objfile); struct type *type, *range_type, *index_type, *char_type; struct attribute *attr; - unsigned int length; + struct dynamic_prop prop; + bool length_is_constant = true; + LONGEST length; + + /* There are a couple of places where bit sizes might be made use of + when parsing a DW_TAG_string_type, however, no producer that we know + of make use of these. Handling bit sizes that are a multiple of the + byte size is easy enough, but what about other bit sizes? Lets deal + with that problem when we have to. Warn about these attributes being + unsupported, then parse the type and ignore them like we always + have. */ + if (dwarf2_attr (die, DW_AT_bit_size, cu) != nullptr + || dwarf2_attr (die, DW_AT_string_length_bit_size, cu) != nullptr) + { + static bool warning_printed = false; + if (!warning_printed) + { + warning (_("DW_AT_bit_size and DW_AT_string_length_bit_size not " + "currently supported on DW_TAG_string_type.")); + warning_printed = true; + } + } attr = dwarf2_attr (die, DW_AT_string_length, cu); - if (attr != nullptr) + if (attr != nullptr && !attr_form_is_constant (attr)) + { + /* The string length describes the location at which the length of + the string can be found. The size of the length field can be + specified with one of the attributes below. */ + struct type *prop_type; + struct attribute *len + = dwarf2_attr (die, DW_AT_string_length_byte_size, cu); + if (len == nullptr) + len = dwarf2_attr (die, DW_AT_byte_size, cu); + if (len != nullptr && attr_form_is_constant (len)) + { + /* Pass 0 as the default as we know this attribute is constant + and the default value will not be returned. */ + LONGEST sz = dwarf2_get_attr_constant_value (len, 0); + prop_type = dwarf2_per_cu_int_type (cu->per_cu, sz, true); + } + else + { + /* If the size is not specified then we assume it is the size of + an address on this target. */ + prop_type = dwarf2_per_cu_addr_sized_int_type (cu->per_cu, true); + } + + /* Convert the attribute into a dynamic property. */ + if (!attr_to_dynamic_prop (attr, die, cu, &prop, prop_type)) + length = 1; + else + length_is_constant = false; + } + else if (attr != nullptr) { - length = DW_UNSND (attr); + /* This DW_AT_string_length just contains the length with no + indirection. There's no need to create a dynamic property in this + case. Pass 0 for the default value as we know it will not be + returned in this case. */ + length = dwarf2_get_attr_constant_value (attr, 0); + } + else if ((attr = dwarf2_attr (die, DW_AT_byte_size, cu)) != nullptr) + { + /* We don't currently support non-constant byte sizes for strings. */ + length = dwarf2_get_attr_constant_value (attr, 1); } else { - /* Check for the DW_AT_byte_size attribute. */ - attr = dwarf2_attr (die, DW_AT_byte_size, cu); - if (attr != nullptr) - { - length = DW_UNSND (attr); - } - else - { - length = 1; - } + /* Use 1 as a fallback length if we have nothing else. */ + length = 1; } index_type = objfile_type (objfile)->builtin_int; - range_type = create_static_range_type (NULL, index_type, 1, length); + if (length_is_constant) + range_type = create_static_range_type (NULL, index_type, 1, length); + else + { + struct dynamic_prop low_bound; + + low_bound.kind = PROP_CONST; + low_bound.data.const_val = 1; + range_type = create_range_type (NULL, index_type, &low_bound, &prop, 0); + } char_type = language_string_char_type (cu->language_defn, gdbarch); type = create_string_type (NULL, char_type, range_type); @@ -17410,8 +17534,10 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) the subroutine die. Otherwise set the calling convention to the default value DW_CC_normal. */ attr = dwarf2_attr (die, DW_AT_calling_convention, cu); - if (attr != nullptr) - TYPE_CALLING_CONVENTION (ftype) = DW_UNSND (attr); + if (attr != nullptr + && is_valid_DW_AT_calling_convention_for_subroutine (DW_UNSND (attr))) + TYPE_CALLING_CONVENTION (ftype) + = (enum dwarf_calling_convention) (DW_UNSND (attr)); else if (cu->producer && strstr (cu->producer, "IBM XL C for OpenCL")) TYPE_CALLING_CONVENTION (ftype) = DW_CC_GDB_IBM_OpenCL; else @@ -17555,7 +17681,7 @@ read_typedef (struct die_info *die, struct dwarf2_cu *cu) static struct type * dwarf2_init_float_type (struct objfile *objfile, int bits, const char *name, - const char *name_hint) + const char *name_hint, enum bfd_endian byte_order) { struct gdbarch *gdbarch = get_objfile_arch (objfile); const struct floatformat **format; @@ -17563,7 +17689,7 @@ dwarf2_init_float_type (struct objfile *objfile, int bits, const char *name, format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits); if (format) - type = init_float_type (objfile, bits, name, format); + type = init_float_type (objfile, bits, name, format, byte_order); else type = init_type (objfile, TYPE_CODE_ERROR, bits, name); @@ -17602,7 +17728,8 @@ dwarf2_init_integer_type (struct dwarf2_cu *cu, struct objfile *objfile, static struct type * dwarf2_init_complex_target_type (struct dwarf2_cu *cu, struct objfile *objfile, - int bits, const char *name_hint) + int bits, const char *name_hint, + enum bfd_endian byte_order) { gdbarch *gdbarch = get_objfile_arch (objfile); struct type *tt = nullptr; @@ -17651,7 +17778,7 @@ dwarf2_init_complex_target_type (struct dwarf2_cu *cu, tt = nullptr; const char *name = (tt == nullptr) ? nullptr : TYPE_NAME (tt); - return dwarf2_init_float_type (objfile, bits, name, name_hint); + return dwarf2_init_float_type (objfile, bits, name, name_hint, byte_order); } /* Find a representation of a given base type and install @@ -17664,7 +17791,6 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) struct type *type; struct attribute *attr; int encoding = 0, bits = 0; - int endianity = 0; const char *name; gdbarch *arch; @@ -17677,11 +17803,29 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) name = dwarf2_name (die, cu); if (!name) complaint (_("DW_AT_name missing from DW_TAG_base_type")); + + arch = get_objfile_arch (objfile); + enum bfd_endian byte_order = gdbarch_byte_order (arch); + attr = dwarf2_attr (die, DW_AT_endianity, cu); if (attr) - endianity = DW_UNSND (attr); + { + int endianity = DW_UNSND (attr); + + switch (endianity) + { + case DW_END_big: + byte_order = BFD_ENDIAN_BIG; + break; + case DW_END_little: + byte_order = BFD_ENDIAN_LITTLE; + break; + default: + complaint (_("DW_AT_endianity has unrecognized value %d"), endianity); + break; + } + } - arch = get_objfile_arch (objfile); switch (encoding) { case DW_ATE_address: @@ -17693,14 +17837,15 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) type = init_boolean_type (objfile, bits, 1, name); break; case DW_ATE_complex_float: - type = dwarf2_init_complex_target_type (cu, objfile, bits / 2, name); + type = dwarf2_init_complex_target_type (cu, objfile, bits / 2, name, + byte_order); type = init_complex_type (objfile, name, type); break; case DW_ATE_decimal_float: type = init_decfloat_type (objfile, bits, name); break; case DW_ATE_float: - type = dwarf2_init_float_type (objfile, bits, name, name); + type = dwarf2_init_float_type (objfile, bits, name, name, byte_order); break; case DW_ATE_signed: type = dwarf2_init_integer_type (cu, objfile, bits, 0, name); @@ -17758,17 +17903,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu) maybe_set_alignment (cu, die, type); - switch (endianity) - { - case DW_END_big: - if (gdbarch_byte_order (arch) == BFD_ENDIAN_LITTLE) - TYPE_ENDIANITY_NOT_DEFAULT (type) = 1; - break; - case DW_END_little: - if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG) - TYPE_ENDIANITY_NOT_DEFAULT (type) = 1; - break; - } + TYPE_ENDIANITY_NOT_DEFAULT (type) = gdbarch_byte_order (arch) != byte_order; return set_die_type (die, type, cu); } @@ -17798,7 +17933,15 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, baton->locexpr.per_cu = cu->per_cu; baton->locexpr.size = DW_BLOCK (attr)->size; baton->locexpr.data = DW_BLOCK (attr)->data; - baton->locexpr.is_reference = false; + switch (attr->name) + { + case DW_AT_string_length: + baton->locexpr.is_reference = true; + break; + default: + baton->locexpr.is_reference = false; + break; + } prop->data.baton = baton; prop->kind = PROP_LOCEXPR; gdb_assert (prop->data.baton != NULL); @@ -17882,24 +18025,22 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, return 1; } -/* Find an integer type the same size as the address size given in the - compilation unit header for PER_CU. UNSIGNED_P controls if the integer - is unsigned or not. */ +/* Find an integer type SIZE_IN_BYTES bytes in size and return it. + UNSIGNED_P controls if the integer is unsigned or not. */ static struct type * -dwarf2_per_cu_addr_sized_int_type (struct dwarf2_per_cu_data *per_cu, - bool unsigned_p) +dwarf2_per_cu_int_type (struct dwarf2_per_cu_data *per_cu, + int size_in_bytes, bool unsigned_p) { struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile; - int addr_size = dwarf2_per_cu_addr_size (per_cu); struct type *int_type; /* Helper macro to examine the various builtin types. */ -#define TRY_TYPE(F) \ - int_type = (unsigned_p \ - ? objfile_type (objfile)->builtin_unsigned_ ## F \ - : objfile_type (objfile)->builtin_ ## F); \ - if (int_type != NULL && TYPE_LENGTH (int_type) == addr_size) \ +#define TRY_TYPE(F) \ + int_type = (unsigned_p \ + ? objfile_type (objfile)->builtin_unsigned_ ## F \ + : objfile_type (objfile)->builtin_ ## F); \ + if (int_type != NULL && TYPE_LENGTH (int_type) == size_in_bytes) \ return int_type TRY_TYPE (char); @@ -17913,6 +18054,18 @@ dwarf2_per_cu_addr_sized_int_type (struct dwarf2_per_cu_data *per_cu, gdb_assert_not_reached ("unable to find suitable integer type"); } +/* Find an integer type the same size as the address size given in the + compilation unit header for PER_CU. UNSIGNED_P controls if the integer + is unsigned or not. */ + +static struct type * +dwarf2_per_cu_addr_sized_int_type (struct dwarf2_per_cu_data *per_cu, + bool unsigned_p) +{ + int addr_size = dwarf2_per_cu_addr_size (per_cu); + return dwarf2_per_cu_int_type (per_cu, addr_size, unsigned_p); +} + /* Read the DW_AT_type attribute for a sub-range. If this attribute is not present (which is valid) then compute the default type based on the compilation units address size. */ @@ -18060,7 +18213,52 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) && !TYPE_UNSIGNED (base_type) && (high.data.const_val & negative_mask)) high.data.const_val |= negative_mask; - range_type = create_range_type (NULL, orig_base_type, &low, &high, bias); + /* Check for bit and byte strides. */ + struct dynamic_prop byte_stride_prop; + attribute *attr_byte_stride = dwarf2_attr (die, DW_AT_byte_stride, cu); + if (attr_byte_stride != nullptr) + { + struct type *prop_type + = dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false); + attr_to_dynamic_prop (attr_byte_stride, die, cu, &byte_stride_prop, + prop_type); + } + + struct dynamic_prop bit_stride_prop; + attribute *attr_bit_stride = dwarf2_attr (die, DW_AT_bit_stride, cu); + if (attr_bit_stride != nullptr) + { + /* It only makes sense to have either a bit or byte stride. */ + if (attr_byte_stride != nullptr) + { + complaint (_("Found DW_AT_bit_stride and DW_AT_byte_stride " + "- DIE at %s [in module %s]"), + sect_offset_str (die->sect_off), + objfile_name (cu->per_cu->dwarf2_per_objfile->objfile)); + attr_bit_stride = nullptr; + } + else + { + struct type *prop_type + = dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false); + attr_to_dynamic_prop (attr_bit_stride, die, cu, &bit_stride_prop, + prop_type); + } + } + + if (attr_byte_stride != nullptr + || attr_bit_stride != nullptr) + { + bool byte_stride_p = (attr_byte_stride != nullptr); + struct dynamic_prop *stride + = byte_stride_p ? &byte_stride_prop : &bit_stride_prop; + + range_type + = create_range_type_with_stride (NULL, orig_base_type, &low, + &high, bias, stride, byte_stride_p); + } + else + range_type = create_range_type (NULL, orig_base_type, &low, &high, bias); if (high_bound_is_count) TYPE_RANGE_DATA (range_type)->flag_upper_bound_is_count = 1; @@ -18354,8 +18552,7 @@ abbrev_table_read_table (struct dwarf2_per_objfile *dwarf2_per_objfile, struct abbrev_info *cur_abbrev; unsigned int abbrev_number, bytes_read, abbrev_name; unsigned int abbrev_form; - struct attr_abbrev *cur_attrs; - unsigned int allocated_attrs; + std::vector cur_attrs; abbrev_table_up abbrev_table (new struct abbrev_table (sect_off)); @@ -18364,12 +18561,10 @@ abbrev_table_read_table (struct dwarf2_per_objfile *dwarf2_per_objfile, abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); abbrev_ptr += bytes_read; - allocated_attrs = ATTR_ALLOC_CHUNK; - cur_attrs = XNEWVEC (struct attr_abbrev, allocated_attrs); - /* Loop until we reach an abbrev number of 0. */ while (abbrev_number) { + cur_attrs.clear (); cur_abbrev = abbrev_table->alloc_abbrev (); /* read in abbrev header */ @@ -18404,25 +18599,18 @@ abbrev_table_read_table (struct dwarf2_per_objfile *dwarf2_per_objfile, if (abbrev_name == 0) break; - if (cur_abbrev->num_attrs == allocated_attrs) - { - allocated_attrs += ATTR_ALLOC_CHUNK; - cur_attrs - = XRESIZEVEC (struct attr_abbrev, cur_attrs, allocated_attrs); - } - - cur_attrs[cur_abbrev->num_attrs].name - = (enum dwarf_attribute) abbrev_name; - cur_attrs[cur_abbrev->num_attrs].form - = (enum dwarf_form) abbrev_form; - cur_attrs[cur_abbrev->num_attrs].implicit_const = implicit_const; + cur_attrs.emplace_back (); + struct attr_abbrev &cur_attr = cur_attrs.back (); + cur_attr.name = (enum dwarf_attribute) abbrev_name; + cur_attr.form = (enum dwarf_form) abbrev_form; + cur_attr.implicit_const = implicit_const; ++cur_abbrev->num_attrs; } cur_abbrev->attrs = XOBNEWVEC (&abbrev_table->abbrev_obstack, struct attr_abbrev, cur_abbrev->num_attrs); - memcpy (cur_abbrev->attrs, cur_attrs, + memcpy (cur_abbrev->attrs, cur_attrs.data (), cur_abbrev->num_attrs * sizeof (struct attr_abbrev)); abbrev_table->add_abbrev (abbrev_number, cur_abbrev); @@ -18442,7 +18630,6 @@ abbrev_table_read_table (struct dwarf2_per_objfile *dwarf2_per_objfile, break; } - xfree (cur_attrs); return abbrev_table; } @@ -19115,16 +19302,15 @@ guess_partial_die_structure_name (struct partial_die_info *struct_pdi, if (child_pdi->tag == DW_TAG_subprogram && child_pdi->linkage_name != NULL) { - char *actual_class_name - = language_class_name_from_physname (cu->language_defn, - child_pdi->linkage_name); + gdb::unique_xmalloc_ptr actual_class_name + (language_class_name_from_physname (cu->language_defn, + child_pdi->linkage_name)); if (actual_class_name != NULL) { struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile; struct_pdi->name = obstack_strdup (&objfile->per_bfd->storage_obstack, - actual_class_name); - xfree (actual_class_name); + actual_class_name.get ()); } break; } @@ -19189,24 +19375,22 @@ partial_die_info::fixup (struct dwarf2_cu *cu) || tag == DW_TAG_union_type) && linkage_name != NULL) { - char *demangled; - - demangled = gdb_demangle (linkage_name, DMGL_TYPES); - if (demangled) + gdb::unique_xmalloc_ptr demangled + (gdb_demangle (linkage_name, DMGL_TYPES)); + if (demangled != nullptr) { const char *base; /* Strip any leading namespaces/classes, keep only the base name. DW_AT_name for named DIEs does not contain the prefixes. */ - base = strrchr (demangled, ':'); - if (base && base > demangled && base[-1] == ':') + base = strrchr (demangled.get (), ':'); + if (base && base > demangled.get () && base[-1] == ':') base++; else - base = demangled; + base = demangled.get (); struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile; name = obstack_strdup (&objfile->per_bfd->storage_obstack, base); - xfree (demangled); } } @@ -21195,7 +21379,7 @@ dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu, the line number program). */ bool record_lines_p = !decode_for_pst_p; - baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; line_ptr = lh->statement_program_start; line_end = lh->statement_program_end; @@ -21486,7 +21670,7 @@ static void dwarf2_start_subfile (struct dwarf2_cu *cu, const char *filename, const char *dirname) { - char *copy = NULL; + gdb::unique_xmalloc_ptr copy; /* In order not to lose the line information directory, we concatenate it to the filename when it makes sense. @@ -21497,14 +21681,11 @@ dwarf2_start_subfile (struct dwarf2_cu *cu, const char *filename, if (!IS_ABSOLUTE_PATH (filename) && dirname != NULL) { - copy = concat (dirname, SLASH_STRING, filename, (char *)NULL); - filename = copy; + copy.reset (concat (dirname, SLASH_STRING, filename, (char *) NULL)); + filename = copy.get (); } cu->get_builder ()->start_subfile (filename); - - if (copy != NULL) - xfree (copy); } /* Start a symtab for DWARF. NAME, COMP_DIR, LOW_PC are passed to the @@ -21522,7 +21703,7 @@ dwarf2_cu::start_symtab (const char *name, const char *comp_dir, list_in_scope = get_builder ()->get_file_symbols (); - get_builder ()->record_debugformat ("DWARF 2"); + get_builder ()->record_debugformat (xstrprintf ("DWARF %d", this->header.version)); get_builder ()->record_producer (producer); processing_has_namespace_info = false; @@ -21581,10 +21762,10 @@ var_decode_location (struct attribute *attr, struct symbol *sym, &dummy)); SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC; fixup_symbol_section (sym, objfile); - SET_SYMBOL_VALUE_ADDRESS (sym, - SYMBOL_VALUE_ADDRESS (sym) - + ANOFFSET (objfile->section_offsets, - SYMBOL_SECTION (sym))); + SET_SYMBOL_VALUE_ADDRESS + (sym, + SYMBOL_VALUE_ADDRESS (sym) + + objfile->section_offsets[SYMBOL_SECTION (sym)]); return; } @@ -21626,7 +21807,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, int inlined_func = (die->tag == DW_TAG_inlined_subroutine); - baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; name = dwarf2_name (die, cu); if (name) @@ -21641,9 +21822,9 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, OBJSTAT (objfile, n_syms++); /* Cache this symbol's name and the name's demangled form (if any). */ - SYMBOL_SET_LANGUAGE (sym, cu->language, &objfile->objfile_obstack); + sym->set_language (cu->language, &objfile->objfile_obstack); linkagename = dwarf2_physname (name, die, cu); - SYMBOL_SET_NAMES (sym, linkagename, false, objfile); + sym->compute_and_set_names (linkagename, false, objfile->per_bfd); /* Fortran does not have mangling standard and the mangling does differ between gfortran, iFort etc. */ @@ -22472,7 +22653,7 @@ read_type_die_1 (struct die_info *die, struct dwarf2_cu *cu) This is the full-die version of guess_partial_die_structure_name. In this case we know DIE has no useful parent. */ -static char * +static const char * guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu) { struct die_info *spec_die; @@ -22498,33 +22679,32 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu) if (linkage_name != NULL) { - char *actual_name - = language_class_name_from_physname (cu->language_defn, - linkage_name); - char *name = NULL; + gdb::unique_xmalloc_ptr actual_name + (language_class_name_from_physname (cu->language_defn, + linkage_name)); + const char *name = NULL; if (actual_name != NULL) { const char *die_name = dwarf2_name (die, cu); if (die_name != NULL - && strcmp (die_name, actual_name) != 0) + && strcmp (die_name, actual_name.get ()) != 0) { /* Strip off the class name from the full name. We want the prefix. */ int die_name_len = strlen (die_name); - int actual_name_len = strlen (actual_name); + int actual_name_len = strlen (actual_name.get ()); + const char *ptr = actual_name.get (); /* Test for '::' as a sanity check. */ if (actual_name_len > die_name_len + 2 - && actual_name[actual_name_len - - die_name_len - 1] == ':') + && ptr[actual_name_len - die_name_len - 1] == ':') name = obstack_strndup ( &objfile->per_bfd->storage_obstack, - actual_name, actual_name_len - die_name_len - 2); + ptr, actual_name_len - die_name_len - 2); } } - xfree (actual_name); return name; } } @@ -22711,7 +22891,7 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu) || die->tag == DW_TAG_structure_type || die->tag == DW_TAG_union_type)) { - char *name = guess_full_die_structure_name (die, cu); + const char *name = guess_full_die_structure_name (die, cu); if (name != NULL) return name; } @@ -22885,8 +23065,6 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47510. */ if (!attr || DW_STRING (attr) == NULL) { - char *demangled = NULL; - attr = dw2_linkage_name_attr (die, cu); if (attr == NULL || DW_STRING (attr) == NULL) return NULL; @@ -22894,18 +23072,17 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) /* Avoid demangling DW_STRING (attr) the second time on a second call for the same DIE. */ if (!DW_STRING_IS_CANONICAL (attr)) - demangled = gdb_demangle (DW_STRING (attr), DMGL_TYPES); - - if (demangled) { + gdb::unique_xmalloc_ptr demangled + (gdb_demangle (DW_STRING (attr), DMGL_TYPES)); + const char *base; /* FIXME: we already did this for the partial symbol... */ DW_STRING (attr) = obstack_strdup (&objfile->per_bfd->storage_obstack, - demangled); + demangled.get ()); DW_STRING_IS_CANONICAL (attr) = 1; - xfree (demangled); /* Strip any leading namespaces/classes, keep only the base name. DW_AT_name for named DIEs does not contain the prefixes. */ @@ -23428,8 +23605,7 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, != dwarf2_per_objfile->abstract_to_concrete.end ())) { CORE_ADDR pc = (*get_frame_pc) (baton); - CORE_ADDR baseaddr - = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + CORE_ADDR baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)]; struct gdbarch *gdbarch = get_objfile_arch (objfile); for (const auto &cand_off @@ -24390,7 +24566,7 @@ parse_macro_definition (struct macro_source_file *file, int line, { /* It's an object-like macro. */ int name_len = p - body; - char *name = savestring (body, name_len); + std::string name (body, name_len); const char *replacement; if (*p == ' ') @@ -24401,14 +24577,12 @@ parse_macro_definition (struct macro_source_file *file, int line, replacement = body + name_len; } - macro_define_object (file, line, name, replacement); - - xfree (name); + macro_define_object (file, line, name.c_str (), replacement); } else if (*p == '(') { /* It's a function-like macro. */ - char *name = savestring (body, p - body); + std::string name (body, p - body); int argc = 0; int argv_size = 1; char **argv = XNEWVEC (char *, argv_size); @@ -24457,14 +24631,14 @@ parse_macro_definition (struct macro_source_file *file, int line, if (*p == ' ') /* Perfectly formed definition, no complaints. */ - macro_define_function (file, line, name, + macro_define_function (file, line, name.c_str (), argc, (const char **) argv, p + 1); else if (*p == '\0') { /* Complain, but do define it. */ dwarf2_macro_malformed_definition_complaint (body); - macro_define_function (file, line, name, + macro_define_function (file, line, name.c_str (), argc, (const char **) argv, p); } @@ -24476,7 +24650,6 @@ parse_macro_definition (struct macro_source_file *file, int line, /* Just complain. */ dwarf2_macro_malformed_definition_complaint (body); - xfree (name); { int i; @@ -25449,7 +25622,7 @@ dwarf2_per_cu_text_offset (struct dwarf2_per_cu_data *per_cu) { struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile; - return ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + return objfile->section_offsets[SECT_OFF_TEXT (objfile)]; } /* Return a type that is a generic pointer type, the size of which matches