Merge branch 'master' into merge-job
authorJenkins as Icarus Sparry <icarus.sparry@amd.com>
Thu, 9 Jan 2020 03:58:14 +0000 (03:58 +0000)
committerJenkins as Icarus Sparry <icarus.sparry@amd.com>
Thu, 9 Jan 2020 03:58:14 +0000 (03:58 +0000)
1  2 
gdb/dwarf2read.c

diff --combined gdb/dwarf2read.c
index d6471e5bc316b6185a427c585e8c3cd23b68aaf9,04979f3d12fa6f8e365abe83290694f30b671125..51fb06e3b6617fbda5c4203cdae56c4253ba74c1
@@@ -1,7 -1,6 +1,7 @@@
  /* DWARF 2 debugging format support for GDB.
  
     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
@@@ -1340,15 -1339,6 +1340,6 @@@ struct dwarf_bloc
      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.  */
@@@ -3180,7 -3170,7 +3171,7 @@@ create_addrmap_from_index (struct dwarf
    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)
      {
@@@ -3226,8 -3216,7 +3217,7 @@@ create_addrmap_from_aranges (struct dwa
    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);
@@@ -5247,8 -5236,7 +5237,7 @@@ dw2_find_pc_sect_compunit_symtab (struc
    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)
@@@ -8078,7 -8066,7 +8067,7 @@@ process_psymtab_comp_unit_reader (cons
    /* 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);
  
@@@ -8908,7 -8896,7 +8897,7 @@@ partial_die_parent_scope (struct partia
  /* 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<char>
  partial_die_full_name (struct partial_die_info *pdi,
                       struct dwarf2_cu *cu)
  {
          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));
        }
      }
  
    if (parent_scope == NULL)
      return NULL;
    else
-     return typename_concat (NULL, parent_scope, pdi->name, 0, cu);
+     return gdb::unique_xmalloc_ptr<char> (typename_concat (NULL, parent_scope,
+                                                          pdi->name, 0, cu));
  }
  
  static void
@@@ -8955,13 -8944,13 +8945,13 @@@ add_partial_symbol (struct partial_die_
    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<char> 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;
          /* 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,
           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.  */
      default:
        break;
      }
-   xfree (built_actual_name);
  }
  
  /* Read a partial die corresponding to a namespace; also, add a symbol
@@@ -9207,8 -9188,7 +9189,7 @@@ add_partial_subprogram (struct partial_
              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)
@@@ -9905,7 -9885,7 +9886,7 @@@ compute_delayed_physnames (struct dwarf
  static void
  fixup_go_packaging (struct dwarf2_cu *cu)
  {
-   char *package_name = NULL;
+   gdb::unique_xmalloc_ptr<char> package_name;
    struct pending *list;
    int i;
  
          if (sym->language () == language_go
              && SYMBOL_CLASS (sym) == LOC_BLOCK)
            {
-             char *this_package_name = go_symbol_package_name (sym);
+             gdb::unique_xmalloc_ptr<char> 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 ());
                }
            }
        }
      {
        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;
        SYMBOL_TYPE (sym) = type;
  
        add_symbol_to_list (sym, cu->get_builder ()->get_global_symbols ());
-       xfree (package_name);
      }
  }
  
@@@ -10419,7 -10397,7 +10398,7 @@@ process_full_comp_unit (struct dwarf2_p
    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 ();
@@@ -10913,11 -10891,10 +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<char> 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);
@@@ -11622,7 -11599,7 +11600,7 @@@ read_file_scope (struct die_info *die, 
    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);
  
@@@ -12959,16 -12936,15 +12937,15 @@@ open_dwo_file (struct dwarf2_per_objfil
  
    if (comp_dir != NULL)
      {
-       char *path_to_try = concat (comp_dir, SLASH_STRING,
-                                 file_name, (char *) NULL);
+       gdb::unique_xmalloc_ptr<char> 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;
      }
@@@ -13737,7 -13713,7 +13714,7 @@@ read_func_scope (struct die_info *die, 
        }
      }
  
-   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+   baseaddr = objfile->section_offsets[SECT_OFF_TEXT (objfile)];
  
    name = dwarf2_name (die, cu);
  
@@@ -13916,7 -13892,7 +13893,7 @@@ read_lexical_block_scope (struct die_in
    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
@@@ -13990,7 -13966,7 +13967,7 @@@ read_call_site_scope (struct die_info *
    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)
@@@ -14387,7 -14363,7 +14364,7 @@@ dwarf2_rnglists_process (unsigned offse
      }
    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)
      {
@@@ -14555,7 -14531,7 +14532,7 @@@ dwarf2_ranges_process (unsigned offset
      }
    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)
      {
@@@ -14633,8 -14609,7 +14610,7 @@@ dwarf2_ranges_read (unsigned offset, CO
  {
    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;
@@@ -16549,8 -16524,7 +16525,7 @@@ process_enumeration_scope (struct die_i
      {
        struct die_info *child_die;
        struct symbol *sym;
-       struct field *fields = NULL;
-       int num_fields = 0;
+       std::vector<struct field> fields;
        const char *name;
  
        child_die = die->child;
                {
                  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 ());
        }
      }
  
@@@ -18585,8 -18551,7 +18552,7 @@@ abbrev_table_read_table (struct dwarf2_
    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<struct attr_abbrev> cur_attrs;
  
    abbrev_table_up abbrev_table (new struct abbrev_table (sect_off));
  
    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 */
          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);
        break;
      }
  
-   xfree (cur_attrs);
    return abbrev_table;
  }
  
@@@ -19346,16 -19301,15 +19302,15 @@@ guess_partial_die_structure_name (struc
        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<char> 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;
        }
@@@ -19420,24 -19374,22 +19375,22 @@@ partial_die_info::fixup (struct dwarf2_
          || tag == DW_TAG_union_type)
        && linkage_name != NULL)
      {
-       char *demangled;
-       demangled = gdb_demangle (linkage_name, DMGL_TYPES);
-       if (demangled)
+       gdb::unique_xmalloc_ptr<char> 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);
        }
      }
  
@@@ -21426,7 -21378,7 +21379,7 @@@ dwarf_decode_lines_1 (struct line_heade
       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;
@@@ -21717,7 -21669,7 +21670,7 @@@ static voi
  dwarf2_start_subfile (struct dwarf2_cu *cu, const char *filename,
                      const char *dirname)
  {
-   char *copy = NULL;
+   gdb::unique_xmalloc_ptr<char> copy;
  
    /* In order not to lose the line information directory,
       we concatenate it to the filename when it makes sense.
  
    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
@@@ -21753,7 -21702,7 +21703,7 @@@ dwarf2_cu::start_symtab (const char *na
  
    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;
@@@ -21812,10 -21761,10 +21762,10 @@@ var_decode_location (struct attribute *
                                             &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;
      }
  
@@@ -21857,7 -21806,7 +21807,7 @@@ new_symbol (struct die_info *die, struc
  
    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)
@@@ -22703,7 -22652,7 +22653,7 @@@ read_type_die_1 (struct die_info *die, 
     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;
  
          if (linkage_name != NULL)
            {
-             char *actual_name
-               language_class_name_from_physname (cu->language_defn,
-                                                    linkage_name);
-             char *name = NULL;
+             gdb::unique_xmalloc_ptr<char> 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;
            }
        }
@@@ -22942,7 -22890,7 +22891,7 @@@ determine_prefix (struct die_info *die
                || 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;
          }
@@@ -23116,8 -23064,6 +23065,6 @@@ dwarf2_name (struct die_info *die, stru
         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;
          /* 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<char> 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.  */
@@@ -23659,8 -23604,7 +23605,7 @@@ dwarf2_fetch_die_loc_sect_off (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
@@@ -24621,7 -24565,7 +24566,7 @@@ parse_macro_definition (struct macro_so
      {
        /* 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 == ' ')
            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);
  
            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);
              }
          /* Just complain.  */
        dwarf2_macro_malformed_definition_complaint (body);
  
-       xfree (name);
        {
          int i;
  
@@@ -25680,7 -25621,7 +25622,7 @@@ dwarf2_per_cu_text_offset (struct dwarf
  {
    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
This page took 0.048788 seconds and 4 git commands to generate.