]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/dwarf2/read.c
gdbsupport: add path_join function
[thirdparty/binutils-gdb.git] / gdb / dwarf2 / read.c
index c0bb18a26f3acc88fdb1639baf5a5f637512c6bb..8586463f5505a563831bca7c251d360f5b9bf1af 100644 (file)
@@ -245,6 +245,11 @@ struct mapped_index final : public mapped_index_base
   { return this->symbol_table.size () / 2; }
 
   quick_symbol_functions_up make_quick_functions () const override;
+
+  bool version_check () const override
+  {
+    return version >= 8;
+  }
 };
 
 /* A description of the mapped .debug_names.
@@ -1275,7 +1280,7 @@ static const char *compute_include_file_name
      (const struct line_header *lh,
       const file_entry &fe,
       const file_and_directory &cu_info,
-      gdb::unique_xmalloc_ptr<char> *name_holder);
+      std::string &name_holder);
 
 static htab_up allocate_signatured_type_table ();
 
@@ -1841,6 +1846,40 @@ struct dwarf2_base_index_functions : public quick_symbol_functions
                             bool need_fullname) override;
 };
 
+/* With OBJF_READNOW, the DWARF reader expands all CUs immediately.
+   It's handy in this case to have an empty implementation of the
+   quick symbol functions, to avoid special cases in the rest of the
+   code.  */
+
+struct readnow_functions : public dwarf2_base_index_functions
+{
+  void dump (struct objfile *objfile) override
+  {
+  }
+
+  void expand_matching_symbols
+    (struct objfile *,
+     const lookup_name_info &lookup_name,
+     domain_enum domain,
+     int global,
+     symbol_compare_ftype *ordered_compare) override
+  {
+  }
+
+  bool expand_symtabs_matching
+    (struct objfile *objfile,
+     gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
+     const lookup_name_info *lookup_name,
+     gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
+     gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+     block_search_flags search_flags,
+     domain_enum domain,
+     enum search_domain kind) override
+  {
+    return true;
+  }
+};
+
 struct dwarf2_gdb_index : public dwarf2_base_index_functions
 {
   void dump (struct objfile *objfile) override;
@@ -1885,12 +1924,6 @@ struct dwarf2_debug_names_index : public dwarf2_base_index_functions
      enum search_domain kind) override;
 };
 
-static quick_symbol_functions_up
-make_dwarf_gdb_index ()
-{
-  return quick_symbol_functions_up (new dwarf2_gdb_index);
-}
-
 quick_symbol_functions_up
 mapped_index::make_quick_functions () const
 {
@@ -2010,7 +2043,7 @@ dw2_do_instantiate_symtab (dwarf2_per_cu_data *per_cu,
            && cu != NULL
            && cu->dwo_unit != NULL
            && per_objfile->per_bfd->index_table != NULL
-           && per_objfile->per_bfd->index_table->version <= 7
+           && !per_objfile->per_bfd->index_table->version_check ()
            /* DWP files aren't supported yet.  */
            && get_dwp_file (per_objfile) == NULL)
          queue_and_load_all_dwo_tus (cu);
@@ -2747,9 +2780,9 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader,
     {
       for (const auto &entry : lh->file_names ())
        {
-         gdb::unique_xmalloc_ptr<char> name_holder;
+         std::string name_holder;
          const char *include_name =
-           compute_include_file_name (lh.get (), entry, fnd, &name_holder);
+           compute_include_file_name (lh.get (), entry, fnd, name_holder);
          if (include_name != nullptr)
            {
              include_name = per_objfile->objfile->intern (include_name);
@@ -2899,7 +2932,8 @@ static void
 dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
                      dwarf2_per_objfile *per_objfile,
                      gdb::optional<block_enum> block_index,
-                     domain_enum domain, offset_type namei)
+                     domain_enum domain, offset_type namei,
+                     mapped_index &index)
 {
   iter->per_objfile = per_objfile;
   iter->block_index = block_index;
@@ -2909,22 +2943,18 @@ dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
   iter->vec = {};
   iter->length = 0;
 
-  mapped_index *index = per_objfile->per_bfd->index_table.get ();
-  /* index is NULL if OBJF_READNOW.  */
-  if (index == NULL)
-    return;
-
-  gdb_assert (!index->symbol_name_slot_invalid (namei));
-  offset_type vec_idx = index->symbol_vec_index (namei);
+  gdb_assert (!index.symbol_name_slot_invalid (namei));
+  offset_type vec_idx = index.symbol_vec_index (namei);
 
-  iter->vec = offset_view (index->constant_pool.slice (vec_idx));
+  iter->vec = offset_view (index.constant_pool.slice (vec_idx));
   iter->length = iter->vec[0];
 }
 
 /* Return the next matching CU or NULL if there are no more.  */
 
 static struct dwarf2_per_cu_data *
-dw2_symtab_iter_next (struct dw2_symtab_iterator *iter)
+dw2_symtab_iter_next (struct dw2_symtab_iterator *iter,
+                     mapped_index &index)
 {
   dwarf2_per_objfile *per_objfile = iter->per_objfile;
 
@@ -2938,9 +2968,8 @@ dw2_symtab_iter_next (struct dw2_symtab_iterator *iter)
         Indices prior to version 7 don't record them,
         and indices >= 7 may elide them for certain symbols
         (gold does this).  */
-      int attrs_valid =
-       (per_objfile->per_bfd->index_table->version >= 7
-        && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE);
+      int attrs_valid = (index.version >= 7
+                        && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE);
 
       /* Don't crash on bad data.  */
       if (cu_index >= per_objfile->per_bfd->all_comp_units.size ())
@@ -3048,14 +3077,9 @@ dwarf2_gdb_index::dump (struct objfile *objfile)
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
 
-  gdb_printf (".gdb_index:");
-  if (per_objfile->per_bfd->index_table != NULL)
-    {
-      gdb_printf (" version %d\n",
-                 per_objfile->per_bfd->index_table->version);
-    }
-  else
-    gdb_printf (" faked for \"readnow\"\n");
+  mapped_index *index = (static_cast<mapped_index *>
+                        (per_objfile->per_bfd->index_table.get ()));
+  gdb_printf (".gdb_index: version %d\n", index->version);
   gdb_printf ("\n");
 }
 
@@ -3105,37 +3129,31 @@ dwarf2_gdb_index::expand_matching_symbols
 
   const block_enum block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
 
-  if (per_objfile->per_bfd->index_table != nullptr)
-    {
-      mapped_index &index = *per_objfile->per_bfd->index_table;
+  mapped_index &index
+    = (static_cast<mapped_index &>
+       (*per_objfile->per_bfd->index_table.get ()));
 
-      const char *match_name = name.ada ().lookup_name ().c_str ();
-      auto matcher = [&] (const char *symname)
-       {
-         if (ordered_compare == nullptr)
-           return true;
-         return ordered_compare (symname, match_name) == 0;
-       };
+  const char *match_name = name.ada ().lookup_name ().c_str ();
+  auto matcher = [&] (const char *symname)
+  {
+    if (ordered_compare == nullptr)
+      return true;
+    return ordered_compare (symname, match_name) == 0;
+  };
 
-      dw2_expand_symtabs_matching_symbol (index, name, matcher,
-                                         [&] (offset_type namei)
-      {
-       struct dw2_symtab_iterator iter;
-       struct dwarf2_per_cu_data *per_cu;
-
-       dw2_symtab_iter_init (&iter, per_objfile, block_kind, domain,
-                             namei);
-       while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
-         dw2_expand_symtabs_matching_one (per_cu, per_objfile, nullptr,
-                                          nullptr);
-       return true;
-      }, per_objfile);
-    }
-  else
+  dw2_expand_symtabs_matching_symbol (index, name, matcher,
+                                     [&] (offset_type namei)
     {
-      /* We have -readnow: no .gdb_index, but no partial symtabs either.  So,
-        proceed assuming all symtabs have been read in.  */
-    }
+      struct dw2_symtab_iterator iter;
+      struct dwarf2_per_cu_data *per_cu;
+
+      dw2_symtab_iter_init (&iter, per_objfile, block_kind, domain, namei,
+                           index);
+      while ((per_cu = dw2_symtab_iter_next (&iter, index)) != NULL)
+       dw2_expand_symtabs_matching_one (per_cu, per_objfile, nullptr,
+                                        nullptr);
+      return true;
+    }, per_objfile);
 }
 
 /* Starting from a search name, return the string that finds the upper
@@ -3952,7 +3970,9 @@ dw2_expand_marked_cus
 {
   offset_type vec_len, vec_idx;
   bool global_seen = false;
-  mapped_index &index = *per_objfile->per_bfd->index_table;
+  mapped_index &index
+    = (static_cast<mapped_index &>
+       (*per_objfile->per_bfd->index_table.get ()));
 
   offset_view vec (index.constant_pool.slice (index.symbol_vec_index (idx)));
   vec_len = vec[0];
@@ -4151,10 +4171,6 @@ dwarf2_gdb_index::expand_symtabs_matching
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
 
-  /* index_table is NULL if OBJF_READNOW.  */
-  if (!per_objfile->per_bfd->index_table)
-    return true;
-
   dw_expand_symtabs_matching_file_matcher (per_objfile, file_matcher);
 
   /* This invariant is documented in quick-functions.h.  */
@@ -4174,7 +4190,9 @@ dwarf2_gdb_index::expand_symtabs_matching
       return true;
     }
 
-  mapped_index &index = *per_objfile->per_bfd->index_table;
+  mapped_index &index
+    = (static_cast<mapped_index &>
+       (*per_objfile->per_bfd->index_table.get ()));
 
   bool result
     = dw2_expand_symtabs_matching_symbol (index, *lookup_name,
@@ -4672,7 +4690,7 @@ dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile)
 
   create_addrmap_from_aranges (per_objfile, &per_bfd->debug_aranges);
 
-  per_bfd->debug_names_table = std::move (map);
+  per_bfd->index_table = std::move (map);
   per_bfd->quick_file_names_table =
     create_quick_file_names_table (per_bfd->all_comp_units.size ());
 
@@ -5096,14 +5114,7 @@ dw2_debug_names_iterator::next ()
 void
 dwarf2_debug_names_index::dump (struct objfile *objfile)
 {
-  dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
-
-  gdb_printf (".debug_names:");
-  if (per_objfile->per_bfd->debug_names_table)
-    gdb_printf (" exists\n");
-  else
-    gdb_printf (" faked for \"readnow\"\n");
-  gdb_printf ("\n");
+  gdb_printf (".debug_names: exists\n");
 }
 
 void
@@ -5115,11 +5126,9 @@ dwarf2_debug_names_index::expand_matching_symbols
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
 
-  /* debug_names_table is NULL if OBJF_READNOW.  */
-  if (!per_objfile->per_bfd->debug_names_table)
-    return;
-
-  mapped_debug_names &map = *per_objfile->per_bfd->debug_names_table;
+  mapped_debug_names &map
+    = (static_cast<mapped_debug_names &>
+       (*per_objfile->per_bfd->index_table.get ()));
   const block_search_flags block_flags
     = global ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK;
 
@@ -5160,10 +5169,6 @@ dwarf2_debug_names_index::expand_symtabs_matching
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
 
-  /* debug_names_table is NULL if OBJF_READNOW.  */
-  if (!per_objfile->per_bfd->debug_names_table)
-    return true;
-
   dw_expand_symtabs_matching_file_matcher (per_objfile, file_matcher);
 
   /* This invariant is documented in quick-functions.h.  */
@@ -5183,7 +5188,9 @@ dwarf2_debug_names_index::expand_symtabs_matching
       return true;
     }
 
-  mapped_debug_names &map = *per_objfile->per_bfd->debug_names_table;
+  mapped_debug_names &map
+    = (static_cast<mapped_debug_names &>
+       (*per_objfile->per_bfd->index_table.get ()));
 
   bool result
     = dw2_expand_symtabs_matching_symbol (map, *lookup_name,
@@ -5284,20 +5291,7 @@ dwarf2_initialize_objfile (struct objfile *objfile)
       per_bfd->quick_file_names_table
        = create_quick_file_names_table (per_bfd->all_comp_units.size ());
 
-      /* Arrange for gdb to see the "quick" functions.  However, these
-        functions will be no-ops because we will have expanded all
-        symtabs.  */
-      objfile->qf.push_front (make_dwarf_gdb_index ());
-      return;
-    }
-
-  /* Was a debug names index already read when we processed an objfile sharing
-     PER_BFD?  */
-  if (per_bfd->debug_names_table != nullptr)
-    {
-      dwarf_read_debug_printf ("re-using shared debug names table");
-      objfile->qf.push_front
-       (per_bfd->debug_names_table->make_quick_functions ());
+      objfile->qf.emplace_front (new readnow_functions);
       return;
     }
 
@@ -5305,23 +5299,16 @@ dwarf2_initialize_objfile (struct objfile *objfile)
      PER_BFD?  */
   if (per_bfd->index_table != nullptr)
     {
-      dwarf_read_debug_printf ("re-using shared index table");
+      dwarf_read_debug_printf ("re-using symbols");
       objfile->qf.push_front (per_bfd->index_table->make_quick_functions ());
       return;
     }
 
-  if (per_bfd->cooked_index_table != nullptr)
-    {
-      dwarf_read_debug_printf ("re-using cooked index table");
-      objfile->qf.push_front (make_cooked_index_funcs ());
-      return;
-    }
-
   if (dwarf2_read_debug_names (per_objfile))
     {
       dwarf_read_debug_printf ("found debug names");
       objfile->qf.push_front
-       (per_bfd->debug_names_table->make_quick_functions ());
+       (per_bfd->index_table->make_quick_functions ());
       return;
     }
 
@@ -5360,7 +5347,7 @@ dwarf2_build_psymtabs (struct objfile *objfile, bool already_attached)
 
   if (already_attached)
     {
-      if (per_objfile->per_bfd->cooked_index_table != nullptr)
+      if (per_objfile->per_bfd->index_table != nullptr)
        return;
     }
   else
@@ -7140,11 +7127,11 @@ dwarf2_build_psymtabs_hard (dwarf2_per_objfile *per_objfile)
                     }),
      indexes.end ());
   indexes.shrink_to_fit ();
-  per_bfd->cooked_index_table.reset
-    (new cooked_index_vector (std::move (indexes)));
 
-  const cooked_index_entry *main_entry
-    = per_bfd->cooked_index_table->get_main ();
+  cooked_index_vector *vec = new cooked_index_vector (std::move (indexes));
+  per_bfd->index_table.reset (vec);
+
+  const cooked_index_entry *main_entry = vec->get_main ();
   if (main_entry != nullptr)
     set_objfile_main_name (objfile, main_entry->name,
                           main_entry->per_cu->lang);
@@ -7823,9 +7810,9 @@ fixup_go_packaging (struct dwarf2_cu *cu)
                  struct objfile *objfile = cu->per_objfile->objfile;
                  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
+                              (sym->symtab () != NULL
                                ? symtab_to_filename_for_display
-                                   (symbol_symtab (sym))
+                               (sym->symtab ())
                                : objfile_name (objfile)),
                               this_package_name.get (), package_name.get ());
                }
@@ -11111,14 +11098,13 @@ open_dwo_file (dwarf2_per_objfile *per_objfile,
 
   if (comp_dir != NULL)
     {
-      gdb::unique_xmalloc_ptr<char> path_to_try
-       (concat (comp_dir, SLASH_STRING, file_name, (char *) NULL));
+      std::string path_to_try = path_join (comp_dir, file_name);
 
       /* 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 (per_objfile, path_to_try.get (),
-                                               0 /*is_dwp*/,
-                                               1 /*search_cwd*/));
+      gdb_bfd_ref_ptr abfd (try_open_dwop_file
+       (per_objfile, path_to_try.c_str (), 0 /*is_dwp*/, 1 /*search_cwd*/));
+
       if (abfd != NULL)
        return abfd;
     }
@@ -12094,7 +12080,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
         of gdb assume that symbols do, and this is reasonably
         true.  */
       for (symbol *sym : template_args)
-       symbol_set_symtab (sym, symbol_symtab (templ_func));
+       sym->set_symtab (templ_func->symtab ());
     }
 
   /* In C++, we can have functions nested inside functions (e.g., when
@@ -14990,7 +14976,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
        {
          struct symtab *symtab;
          if (sym != nullptr)
-           symtab = symbol_symtab (sym);
+           symtab = sym->symtab ();
          else if (cu->line_header != nullptr)
            {
              /* Any related symtab will do.  */
@@ -15014,7 +15000,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
                 other parts of gdb assume that symbols do, and this is
                 reasonably true.  */
              for (int i = 0; i < TYPE_N_TEMPLATE_ARGUMENTS (type); ++i)
-               symbol_set_symtab (TYPE_TEMPLATE_ARGUMENT (type, i), symtab);
+               TYPE_TEMPLATE_ARGUMENT (type, i)->set_symtab (symtab);
            }
        }
     }
@@ -18484,12 +18470,14 @@ cooked_index_functions::find_pc_sect_compunit_symtab
       int warn_if_readin)
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
-  if (per_objfile->per_bfd->cooked_index_table == nullptr)
+  if (per_objfile->per_bfd->index_table == nullptr)
     return nullptr;
 
   CORE_ADDR baseaddr = objfile->text_section_offset ();
-  dwarf2_per_cu_data *per_cu
-    = per_objfile->per_bfd->cooked_index_table->lookup (pc - baseaddr);
+  cooked_index_vector *table
+    = (static_cast<cooked_index_vector *>
+       (per_objfile->per_bfd->index_table.get ()));
+  dwarf2_per_cu_data *per_cu = table->lookup (pc - baseaddr);
   if (per_cu == nullptr)
     return nullptr;
 
@@ -18513,12 +18501,14 @@ cooked_index_functions::find_compunit_symtab_by_address
     return nullptr;
 
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
-  if (per_objfile->per_bfd->cooked_index_table == nullptr)
+  if (per_objfile->per_bfd->index_table == nullptr)
     return nullptr;
 
   CORE_ADDR baseaddr = objfile->data_section_offset ();
-  dwarf2_per_cu_data *per_cu
-    = per_objfile->per_bfd->cooked_index_table->lookup (address - baseaddr);
+  cooked_index_vector *table
+    = (static_cast<cooked_index_vector *>
+       (per_objfile->per_bfd->index_table.get ()));
+  dwarf2_per_cu_data *per_cu = table->lookup (address - baseaddr);
   if (per_cu == nullptr)
     return nullptr;
 
@@ -18534,7 +18524,7 @@ cooked_index_functions::expand_matching_symbols
       symbol_compare_ftype *ordered_compare)
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
-  if (per_objfile->per_bfd->cooked_index_table == nullptr)
+  if (per_objfile->per_bfd->index_table == nullptr)
     return;
   const block_search_flags search_flags = (global
                                           ? SEARCH_GLOBAL_BLOCK
@@ -18543,8 +18533,10 @@ cooked_index_functions::expand_matching_symbols
   symbol_name_matcher_ftype *name_match
     = lang->get_symbol_name_matcher (lookup_name);
 
-  for (const cooked_index_entry *entry
-        : per_objfile->per_bfd->cooked_index_table->all_entries ())
+  cooked_index_vector *table
+    = (static_cast<cooked_index_vector *>
+       (per_objfile->per_bfd->index_table.get ()));
+  for (const cooked_index_entry *entry : table->all_entries ())
     {
       if (entry->parent_entry != nullptr)
        continue;
@@ -18570,7 +18562,7 @@ cooked_index_functions::expand_symtabs_matching
       enum search_domain kind)
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
-  if (per_objfile->per_bfd->cooked_index_table == nullptr)
+  if (per_objfile->per_bfd->index_table == nullptr)
     return true;
 
   dw_expand_symtabs_matching_file_matcher (per_objfile, file_matcher);
@@ -18608,14 +18600,16 @@ cooked_index_functions::expand_symtabs_matching
     language_ada
   };
 
+  cooked_index_vector *table
+    = (static_cast<cooked_index_vector *>
+       (per_objfile->per_bfd->index_table.get ()));
   for (enum language lang : unique_styles)
     {
       std::vector<gdb::string_view> name_vec
        = lookup_name_without_params.split_name (lang);
 
-      for (const cooked_index_entry *entry
-          : per_objfile->per_bfd->cooked_index_table->find (name_vec.back (),
-                                                            completing))
+      for (const cooked_index_entry *entry : table->find (name_vec.back (),
+                                                         completing))
        {
          /* No need to consider symbols from expanded CUs.  */
          if (per_objfile->symtab_set_p (entry->per_cu))
@@ -18694,6 +18688,12 @@ make_cooked_index_funcs ()
   return quick_symbol_functions_up (new cooked_index_functions);
 }
 
+quick_symbol_functions_up
+cooked_index_vector::make_quick_functions () const
+{
+  return make_cooked_index_funcs ();
+}
+
 \f
 
 /* Read the .debug_loclists or .debug_rnglists header (they are the same format)
@@ -19696,14 +19696,14 @@ dwarf_decode_line_header (sect_offset sect_off, struct dwarf2_cu *cu)
 static const char *
 compute_include_file_name (const struct line_header *lh, const file_entry &fe,
                           const file_and_directory &cu_info,
-                          gdb::unique_xmalloc_ptr<char> *name_holder)
+                          std::string &name_holder)
 {
   const char *include_name = fe.name;
   const char *include_name_to_compare = include_name;
 
   const char *dir_name = fe.include_dir (lh);
 
-  gdb::unique_xmalloc_ptr<char> hold_compare;
+  std::string hold_compare;
   if (!IS_ABSOLUTE_PATH (include_name)
       && (dir_name != nullptr || cu_info.get_comp_dir () != nullptr))
     {
@@ -19730,27 +19730,24 @@ compute_include_file_name (const struct line_header *lh, const file_entry &fe,
 
       if (dir_name != NULL)
        {
-         name_holder->reset (concat (dir_name, SLASH_STRING,
-                                     include_name, (char *) NULL));
-         include_name = name_holder->get ();
+         name_holder = path_join (dir_name, include_name);
+         include_name = name_holder.c_str ();
          include_name_to_compare = include_name;
        }
       if (!IS_ABSOLUTE_PATH (include_name)
          && cu_info.get_comp_dir () != nullptr)
        {
-         hold_compare.reset (concat (cu_info.get_comp_dir (), SLASH_STRING,
-                                     include_name, (char *) NULL));
-         include_name_to_compare = hold_compare.get ();
+         hold_compare = path_join (cu_info.get_comp_dir (), include_name);
+         include_name_to_compare = hold_compare.c_str ();
        }
     }
 
-  gdb::unique_xmalloc_ptr<char> copied_name;
+  std::string copied_name;
   const char *cu_filename = cu_info.get_name ();
   if (!IS_ABSOLUTE_PATH (cu_filename) && cu_info.get_comp_dir () != nullptr)
     {
-      copied_name.reset (concat (cu_info.get_comp_dir (), SLASH_STRING,
-                                cu_filename, (char *) NULL));
-      cu_filename = copied_name.get ();
+      copied_name = path_join (cu_info.get_comp_dir (), cu_filename);
+      cu_filename = copied_name.c_str ();
     }
 
   if (FILENAME_CMP (include_name_to_compare, cu_filename) == 0)
@@ -20485,7 +20482,7 @@ static void
 dwarf2_start_subfile (struct dwarf2_cu *cu, const char *filename,
                      const char *dirname)
 {
-  gdb::unique_xmalloc_ptr<char> copy;
+  std::string copy;
 
   /* In order not to lose the line information directory,
      we concatenate it to the filename when it makes sense.
@@ -20496,8 +20493,8 @@ dwarf2_start_subfile (struct dwarf2_cu *cu, const char *filename,
 
   if (!IS_ABSOLUTE_PATH (filename) && dirname != NULL)
     {
-      copy.reset (concat (dirname, SLASH_STRING, filename, (char *) NULL));
-      filename = copy.get ();
+      copy = path_join (dirname, filename);
+      filename = copy.c_str ();
     }
 
   cu->get_builder ()->start_subfile (filename);
@@ -20633,7 +20630,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
       /* Handle DW_AT_artificial.  */
       attr = dwarf2_attr (die, DW_AT_artificial, cu);
       if (attr != nullptr)
-       sym->artificial = attr->as_boolean ();
+       sym->set_is_artificial (attr->as_boolean ());
 
       /* Default assumptions.
         Use the passed type or decode it from the die.  */
@@ -20666,7 +20663,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
          if (fe == NULL)
            complaint (_("file index out of range"));
          else
-           symbol_set_symtab (sym, fe->symtab);
+           sym->set_symtab (fe->symtab);
        }
 
       switch (die->tag)
@@ -22581,7 +22578,7 @@ follow_die_sig_1 (struct die_info *src_die, struct signatured_type *sig_type,
       /* For .gdb_index version 7 keep track of included TUs.
         http://sourceware.org/bugzilla/show_bug.cgi?id=15021.  */
       if (per_objfile->per_bfd->index_table != NULL
-         && per_objfile->per_bfd->index_table->version <= 7)
+         && !per_objfile->per_bfd->index_table->version_check ())
        {
          (*ref_cu)->per_cu->imported_symtabs_push (sig_cu->per_cu);
        }