Rename a private data member in tui_source_window
[deliverable/binutils-gdb.git] / gdb / dwarf2read.c
index cccc493b29126da1cdb93eeabfd0eb945d6dc355..1052501c351de0923ee79df201151337517841f0 100644 (file)
@@ -102,11 +102,11 @@ static unsigned int dwarf_die_debug = 0;
 /* When non-zero, dump line number entries as they are read in.  */
 static unsigned int dwarf_line_debug = 0;
 
-/* When non-zero, cross-check physname against demangler.  */
-static int check_physname = 0;
+/* When true, cross-check physname against demangler.  */
+static bool check_physname = false;
 
-/* When non-zero, do not reject deprecated .gdb_index sections.  */
-static int use_deprecated_index_sections = 0;
+/* When true, do not reject deprecated .gdb_index sections.  */
+static bool use_deprecated_index_sections = false;
 
 static const struct objfile_key<dwarf2_per_objfile> dwarf2_objfile_data_key;
 
@@ -179,7 +179,8 @@ struct mapped_index_base
      vector.  */
   std::pair<std::vector<name_component>::const_iterator,
            std::vector<name_component>::const_iterator>
-    find_name_components_bounds (const lookup_name_info &ln_no_params) const;
+    find_name_components_bounds (const lookup_name_info &ln_no_params,
+                                enum language lang) const;
 
   /* Prevent deleting/destroying via a base class pointer.  */
 protected:
@@ -2279,7 +2280,7 @@ get_section_name (const struct dwarf2_section_info *section)
   asection *sectp = get_section_bfd_section (section);
 
   gdb_assert (sectp != NULL);
-  return bfd_section_name (get_section_bfd_owner (section), sectp);
+  return bfd_section_name (sectp);
 }
 
 /* Return the name of the file SECTION is in.  */
@@ -2314,7 +2315,7 @@ get_section_flags (const struct dwarf2_section_info *section)
   asection *sectp = get_section_bfd_section (section);
 
   gdb_assert (sectp != NULL);
-  return bfd_get_section_flags (sectp->owner, sectp);
+  return bfd_section_flags (sectp);
 }
 
 /* When loading sections, we look either for uncompressed section or for
@@ -2339,7 +2340,7 @@ void
 dwarf2_per_objfile::locate_sections (bfd *abfd, asection *sectp,
                                     const dwarf2_debug_sections &names)
 {
-  flagword aflag = bfd_get_section_flags (abfd, sectp);
+  flagword aflag = bfd_section_flags (sectp);
 
   if ((aflag & SEC_HAS_CONTENTS) == 0)
     {
@@ -2347,72 +2348,72 @@ dwarf2_per_objfile::locate_sections (bfd *abfd, asection *sectp,
   else if (section_is_p (sectp->name, &names.info))
     {
       this->info.s.section = sectp;
-      this->info.size = bfd_get_section_size (sectp);
+      this->info.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names.abbrev))
     {
       this->abbrev.s.section = sectp;
-      this->abbrev.size = bfd_get_section_size (sectp);
+      this->abbrev.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names.line))
     {
       this->line.s.section = sectp;
-      this->line.size = bfd_get_section_size (sectp);
+      this->line.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names.loc))
     {
       this->loc.s.section = sectp;
-      this->loc.size = bfd_get_section_size (sectp);
+      this->loc.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names.loclists))
     {
       this->loclists.s.section = sectp;
-      this->loclists.size = bfd_get_section_size (sectp);
+      this->loclists.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names.macinfo))
     {
       this->macinfo.s.section = sectp;
-      this->macinfo.size = bfd_get_section_size (sectp);
+      this->macinfo.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names.macro))
     {
       this->macro.s.section = sectp;
-      this->macro.size = bfd_get_section_size (sectp);
+      this->macro.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names.str))
     {
       this->str.s.section = sectp;
-      this->str.size = bfd_get_section_size (sectp);
+      this->str.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names.line_str))
     {
       this->line_str.s.section = sectp;
-      this->line_str.size = bfd_get_section_size (sectp);
+      this->line_str.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names.addr))
     {
       this->addr.s.section = sectp;
-      this->addr.size = bfd_get_section_size (sectp);
+      this->addr.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names.frame))
     {
       this->frame.s.section = sectp;
-      this->frame.size = bfd_get_section_size (sectp);
+      this->frame.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names.eh_frame))
     {
       this->eh_frame.s.section = sectp;
-      this->eh_frame.size = bfd_get_section_size (sectp);
+      this->eh_frame.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names.ranges))
     {
       this->ranges.s.section = sectp;
-      this->ranges.size = bfd_get_section_size (sectp);
+      this->ranges.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names.rnglists))
     {
       this->rnglists.s.section = sectp;
-      this->rnglists.size = bfd_get_section_size (sectp);
+      this->rnglists.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names.types))
     {
@@ -2420,28 +2421,28 @@ dwarf2_per_objfile::locate_sections (bfd *abfd, asection *sectp,
 
       memset (&type_section, 0, sizeof (type_section));
       type_section.s.section = sectp;
-      type_section.size = bfd_get_section_size (sectp);
+      type_section.size = bfd_section_size (sectp);
 
       this->types.push_back (type_section);
     }
   else if (section_is_p (sectp->name, &names.gdb_index))
     {
       this->gdb_index.s.section = sectp;
-      this->gdb_index.size = bfd_get_section_size (sectp);
+      this->gdb_index.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names.debug_names))
     {
       this->debug_names.s.section = sectp;
-      this->debug_names.size = bfd_get_section_size (sectp);
+      this->debug_names.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names.debug_aranges))
     {
       this->debug_aranges.s.section = sectp;
-      this->debug_aranges.size = bfd_get_section_size (sectp);
+      this->debug_aranges.size = bfd_section_size (sectp);
     }
 
-  if ((bfd_get_section_flags (abfd, sectp) & (SEC_LOAD | SEC_ALLOC))
-      && bfd_section_vma (abfd, sectp) == 0)
+  if ((bfd_section_flags (sectp) & (SEC_LOAD | SEC_ALLOC))
+      && bfd_section_vma (sectp) == 0)
     this->has_section_at_zero = true;
 }
 
@@ -2530,7 +2531,7 @@ dwarf2_read_section (struct objfile *objfile, dwarf2_section_info *info)
     {
       error (_("Dwarf Error: Can't read DWARF data"
               " in section %s [in module %s]"),
-            bfd_section_name (abfd, sectp), bfd_get_filename (abfd));
+            bfd_section_name (sectp), bfd_get_filename (abfd));
     }
 }
 
@@ -2602,37 +2603,37 @@ locate_dwz_sections (bfd *abfd, asection *sectp, void *arg)
   if (section_is_p (sectp->name, &dwarf2_elf_names.abbrev))
     {
       dwz_file->abbrev.s.section = sectp;
-      dwz_file->abbrev.size = bfd_get_section_size (sectp);
+      dwz_file->abbrev.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &dwarf2_elf_names.info))
     {
       dwz_file->info.s.section = sectp;
-      dwz_file->info.size = bfd_get_section_size (sectp);
+      dwz_file->info.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &dwarf2_elf_names.str))
     {
       dwz_file->str.s.section = sectp;
-      dwz_file->str.size = bfd_get_section_size (sectp);
+      dwz_file->str.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &dwarf2_elf_names.line))
     {
       dwz_file->line.s.section = sectp;
-      dwz_file->line.size = bfd_get_section_size (sectp);
+      dwz_file->line.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &dwarf2_elf_names.macro))
     {
       dwz_file->macro.s.section = sectp;
-      dwz_file->macro.size = bfd_get_section_size (sectp);
+      dwz_file->macro.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &dwarf2_elf_names.gdb_index))
     {
       dwz_file->gdb_index.s.section = sectp;
-      dwz_file->gdb_index.size = bfd_get_section_size (sectp);
+      dwz_file->gdb_index.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &dwarf2_elf_names.debug_names))
     {
       dwz_file->debug_names.s.section = sectp;
-      dwz_file->debug_names.size = bfd_get_section_size (sectp);
+      dwz_file->debug_names.size = bfd_section_size (sectp);
     }
 }
 
@@ -3583,14 +3584,14 @@ dwarf2_read_gdb_index
        return 0;
 
       if (!read_gdb_index_from_buffer (objfile,
-                                      bfd_get_filename (dwz->dwz_bfd), 1,
-                                      dwz_index_content, &dwz_map,
+                                      bfd_get_filename (dwz->dwz_bfd.get ()),
+                                      1, dwz_index_content, &dwz_map,
                                       &dwz_list, &dwz_list_elements,
                                       &dwz_types_ignore,
                                       &dwz_types_elements_ignore))
        {
          warning (_("could not read '.gdb_index' section from %s; skipping"),
-                  bfd_get_filename (dwz->dwz_bfd));
+                  bfd_get_filename (dwz->dwz_bfd.get ()));
          return 0;
        }
     }
@@ -3692,11 +3693,17 @@ dw2_get_file_names_reader (const struct die_reader_specs *reader,
 
   file_and_directory fnd = find_file_and_directory (comp_unit_die, cu);
 
-  qfn->num_file_names = lh->file_names.size ();
+  int offset = 0;
+  if (strcmp (fnd.name, "<unknown>") != 0)
+    ++offset;
+
+  qfn->num_file_names = offset + lh->file_names.size ();
   qfn->file_names =
-    XOBNEWVEC (&objfile->objfile_obstack, const char *, lh->file_names.size ());
+    XOBNEWVEC (&objfile->objfile_obstack, const char *, qfn->num_file_names);
+  if (offset != 0)
+    qfn->file_names[0] = xstrdup (fnd.name);
   for (i = 0; i < lh->file_names.size (); ++i)
-    qfn->file_names[i] = file_full_name (i + 1, lh.get (), fnd.comp_dir);
+    qfn->file_names[i + offset] = file_full_name (i + 1, lh.get (), fnd.comp_dir);
   qfn->real_names = NULL;
 
   lh_cu->v.quick->file_names = qfn;
@@ -4186,10 +4193,9 @@ dw2_expand_symtabs_with_fullname (struct objfile *objfile,
 static void
 dw2_map_matching_symbols
   (struct objfile *objfile,
-   const char * name, domain_enum domain,
+   const lookup_name_info &name, domain_enum domain,
    int global,
    gdb::function_view<symbol_found_callback_ftype> callback,
-   symbol_name_match_type match,
    symbol_compare_ftype *ordered_compare)
 {
   /* Currently unimplemented; used for Ada.  The function can be called if the
@@ -4197,93 +4203,6 @@ dw2_map_matching_symbols
      does not look for non-Ada symbols this function should just return.  */
 }
 
-/* Symbol name matcher for .gdb_index names.
-
-   Symbol names in .gdb_index have a few particularities:
-
-   - There's no indication of which is the language of each symbol.
-
-     Since each language has its own symbol name matching algorithm,
-     and we don't know which language is the right one, we must match
-     each symbol against all languages.  This would be a potential
-     performance problem if it were not mitigated by the
-     mapped_index::name_components lookup table, which significantly
-     reduces the number of times we need to call into this matcher,
-     making it a non-issue.
-
-   - Symbol names in the index have no overload (parameter)
-     information.  I.e., in C++, "foo(int)" and "foo(long)" both
-     appear as "foo" in the index, for example.
-
-     This means that the lookup names passed to the symbol name
-     matcher functions must have no parameter information either
-     because (e.g.) symbol search name "foo" does not match
-     lookup-name "foo(int)" [while swapping search name for lookup
-     name would match].
-*/
-class gdb_index_symbol_name_matcher
-{
-public:
-  /* Prepares the vector of comparison functions for LOOKUP_NAME.  */
-  gdb_index_symbol_name_matcher (const lookup_name_info &lookup_name);
-
-  /* Walk all the matcher routines and match SYMBOL_NAME against them.
-     Returns true if any matcher matches.  */
-  bool matches (const char *symbol_name);
-
-private:
-  /* A reference to the lookup name we're matching against.  */
-  const lookup_name_info &m_lookup_name;
-
-  /* A vector holding all the different symbol name matchers, for all
-     languages.  */
-  std::vector<symbol_name_matcher_ftype *> m_symbol_name_matcher_funcs;
-};
-
-gdb_index_symbol_name_matcher::gdb_index_symbol_name_matcher
-  (const lookup_name_info &lookup_name)
-    : m_lookup_name (lookup_name)
-{
-  /* Prepare the vector of comparison functions upfront, to avoid
-     doing the same work for each symbol.  Care is taken to avoid
-     matching with the same matcher more than once if/when multiple
-     languages use the same matcher function.  */
-  auto &matchers = m_symbol_name_matcher_funcs;
-  matchers.reserve (nr_languages);
-
-  matchers.push_back (default_symbol_name_matcher);
-
-  for (int i = 0; i < nr_languages; i++)
-    {
-      const language_defn *lang = language_def ((enum language) i);
-      symbol_name_matcher_ftype *name_matcher
-       = get_symbol_name_matcher (lang, m_lookup_name);
-
-      /* Don't insert the same comparison routine more than once.
-        Note that we do this linear walk instead of a seemingly
-        cheaper sorted insert, or use a std::set or something like
-        that, because relative order of function addresses is not
-        stable.  This is not a problem in practice because the number
-        of supported languages is low, and the cost here is tiny
-        compared to the number of searches we'll do afterwards using
-        this object.  */
-      if (name_matcher != default_symbol_name_matcher
-         && (std::find (matchers.begin (), matchers.end (), name_matcher)
-             == matchers.end ()))
-       matchers.push_back (name_matcher);
-    }
-}
-
-bool
-gdb_index_symbol_name_matcher::matches (const char *symbol_name)
-{
-  for (auto matches_name : m_symbol_name_matcher_funcs)
-    if (matches_name (symbol_name, m_lookup_name, NULL))
-      return true;
-
-  return false;
-}
-
 /* Starting from a search name, return the string that finds the upper
    bound of all strings that start with SEARCH_NAME in a sorted name
    list.  Returns the empty string to indicate that the upper bound is
@@ -4362,13 +4281,13 @@ make_sort_after_prefix_name (const char *search_name)
 std::pair<std::vector<name_component>::const_iterator,
          std::vector<name_component>::const_iterator>
 mapped_index_base::find_name_components_bounds
-  (const lookup_name_info &lookup_name_without_params) const
+  (const lookup_name_info &lookup_name_without_params, language lang) const
 {
   auto *name_cmp
     = this->name_components_casing == case_sensitive_on ? strcmp : strcasecmp;
 
-  const char *cplus
-    = lookup_name_without_params.cplus ().lookup_name ().c_str ();
+  const char *lang_name
+    = lookup_name_without_params.language_lookup_name (lang).c_str ();
 
   /* Comparison function object for lower_bound that matches against a
      given symbol name.  */
@@ -4396,10 +4315,10 @@ mapped_index_base::find_name_components_bounds
   /* Find the lower bound.  */
   auto lower = [&] ()
     {
-      if (lookup_name_without_params.completion_mode () && cplus[0] == '\0')
+      if (lookup_name_without_params.completion_mode () && lang_name[0] == '\0')
        return begin;
       else
-       return std::lower_bound (begin, end, cplus, lookup_compare_lower);
+       return std::lower_bound (begin, end, lang_name, lookup_compare_lower);
     } ();
 
   /* Find the upper bound.  */
@@ -4418,14 +4337,14 @@ mapped_index_base::find_name_components_bounds
             We find the upper bound by looking for the insertion
             point of "func"-with-last-character-incremented,
             i.e. "fund".  */
-         std::string after = make_sort_after_prefix_name (cplus);
+         std::string after = make_sort_after_prefix_name (lang_name);
          if (after.empty ())
            return end;
          return std::lower_bound (lower, end, after.c_str (),
                                   lookup_compare_lower);
        }
       else
-       return std::upper_bound (lower, end, cplus, lookup_compare_upper);
+       return std::upper_bound (lower, end, lang_name, lookup_compare_upper);
     } ();
 
   return {lower, upper};
@@ -4445,11 +4364,7 @@ mapped_index_base::build_name_components ()
 
   /* The code below only knows how to break apart components of C++
      symbol names (and other languages that use '::' as
-     namespace/module separator).  If we add support for wild matching
-     to some language that uses some other operator (E.g., Ada, Go and
-     D use '.'), then we'll need to try splitting the symbol name
-     according to that language too.  Note that Ada does support wild
-     matching, but doesn't currently support .gdb_index.  */
+     namespace/module separator) and Ada symbol names.  */
   auto count = this->symbol_name_count ();
   for (offset_type idx = 0; idx < count; idx++)
     {
@@ -4460,16 +4375,33 @@ mapped_index_base::build_name_components ()
 
       /* Add each name component to the name component table.  */
       unsigned int previous_len = 0;
-      for (unsigned int current_len = cp_find_first_component (name);
-          name[current_len] != '\0';
-          current_len += cp_find_first_component (name + current_len))
+
+      if (strstr (name, "::") != nullptr)
        {
-         gdb_assert (name[current_len] == ':');
-         this->name_components.push_back ({previous_len, idx});
-         /* Skip the '::'.  */
-         current_len += 2;
-         previous_len = current_len;
+         for (unsigned int current_len = cp_find_first_component (name);
+              name[current_len] != '\0';
+              current_len += cp_find_first_component (name + current_len))
+           {
+             gdb_assert (name[current_len] == ':');
+             this->name_components.push_back ({previous_len, idx});
+             /* Skip the '::'.  */
+             current_len += 2;
+             previous_len = current_len;
+           }
+       }
+      else
+       {
+         /* Handle the Ada encoded (aka mangled) form here.  */
+         for (const char *iter = strstr (name, "__");
+              iter != nullptr;
+              iter = strstr (iter, "__"))
+           {
+             this->name_components.push_back ({previous_len, idx});
+             iter += 2;
+             previous_len = iter - name;
+           }
        }
+
       this->name_components.push_back ({previous_len, idx});
     }
 
@@ -4504,22 +4436,15 @@ dw2_expand_symtabs_matching_symbol
    const lookup_name_info &lookup_name_in,
    gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
    enum search_domain kind,
-   gdb::function_view<void (offset_type)> match_callback)
+   gdb::function_view<bool (offset_type)> match_callback)
 {
   lookup_name_info lookup_name_without_params
     = lookup_name_in.make_ignore_params ();
-  gdb_index_symbol_name_matcher lookup_name_matcher
-    (lookup_name_without_params);
 
   /* Build the symbol name component sorted vector, if we haven't
      yet.  */
   index.build_name_components ();
 
-  auto bounds = index.find_name_components_bounds (lookup_name_without_params);
-
-  /* Now for each symbol name in range, check to see if we have a name
-     match, and if so, call the MATCH_CALLBACK callback.  */
-
   /* The same symbol may appear more than once in the range though.
      E.g., if we're looking for symbols that complete "w", and we have
      a symbol named "w1::w2", we'll find the two name components for
@@ -4528,17 +4453,61 @@ dw2_expand_symtabs_matching_symbol
      indexes that matched in a temporary vector and ignore
      duplicates.  */
   std::vector<offset_type> matches;
-  matches.reserve (std::distance (bounds.first, bounds.second));
 
-  for (; bounds.first != bounds.second; ++bounds.first)
+  struct name_and_matcher
+  {
+    symbol_name_matcher_ftype *matcher;
+    const std::string &name;
+
+    bool operator== (const name_and_matcher &other) const
+    {
+      return matcher == other.matcher && name == other.name;
+    }
+  };
+
+  /* A vector holding all the different symbol name matchers, for all
+     languages.  */
+  std::vector<name_and_matcher> matchers;
+
+  for (int i = 0; i < nr_languages; i++)
     {
-      const char *qualified = index.symbol_name_at (bounds.first->idx);
+      enum language lang_e = (enum language) i;
 
-      if (!lookup_name_matcher.matches (qualified)
-         || (symbol_matcher != NULL && !symbol_matcher (qualified)))
+      const language_defn *lang = language_def (lang_e);
+      symbol_name_matcher_ftype *name_matcher
+       = get_symbol_name_matcher (lang, lookup_name_without_params);
+
+      name_and_matcher key {
+         name_matcher,
+        lookup_name_without_params.language_lookup_name (lang_e)
+      };
+
+      /* Don't insert the same comparison routine more than once.
+        Note that we do this linear walk.  This is not a problem in
+        practice because the number of supported languages is
+        low.  */
+      if (std::find (matchers.begin (), matchers.end (), key)
+         != matchers.end ())
        continue;
+      matchers.push_back (std::move (key));
+
+      auto bounds
+       = index.find_name_components_bounds (lookup_name_without_params,
+                                            lang_e);
+
+      /* Now for each symbol name in range, check to see if we have a name
+        match, and if so, call the MATCH_CALLBACK callback.  */
+
+      for (; bounds.first != bounds.second; ++bounds.first)
+       {
+         const char *qualified = index.symbol_name_at (bounds.first->idx);
+
+         if (!name_matcher (qualified, lookup_name_without_params, NULL)
+             || (symbol_matcher != NULL && !symbol_matcher (qualified)))
+           continue;
 
-      matches.push_back (bounds.first->idx);
+         matches.push_back (bounds.first->idx);
+       }
     }
 
   std::sort (matches.begin (), matches.end ());
@@ -4549,7 +4518,8 @@ dw2_expand_symtabs_matching_symbol
     {
       if (prev != idx)
        {
-         match_callback (idx);
+         if (!match_callback (idx))
+           break;
          prev = idx;
        }
     }
@@ -4644,6 +4614,7 @@ check_match (const char *file, int line,
 
     if (expected_str == NULL || strcmp (expected_str, matched_name) != 0)
       mismatch (expected_str, matched_name);
+    return true;
   });
 
   const char *expected_str
@@ -4710,7 +4681,8 @@ check_find_bounds_finds (mapped_index_base &index,
   lookup_name_info lookup_name (search_name,
                                symbol_name_match_type::FULL, true);
 
-  auto bounds = index.find_name_components_bounds (lookup_name);
+  auto bounds = index.find_name_components_bounds (lookup_name,
+                                                  language_cplus);
 
   size_t distance = std::distance (bounds.first, bounds.second);
   if (distance != expected_syms.size ())
@@ -5195,6 +5167,7 @@ dw2_expand_symtabs_matching
     {
       dw2_expand_marked_cus (dwarf2_per_objfile, idx, file_matcher,
                             expansion_notify, kind);
+      return true;
     });
 }
 
@@ -5623,11 +5596,11 @@ dwarf2_read_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile)
   if (dwz != NULL)
     {
       if (!read_debug_names_from_section (objfile,
-                                         bfd_get_filename (dwz->dwz_bfd),
+                                         bfd_get_filename (dwz->dwz_bfd.get ()),
                                          &dwz->debug_names, dwz_map))
        {
          warning (_("could not read '.debug_names' section from %s; skipping"),
-                  bfd_get_filename (dwz->dwz_bfd));
+                  bfd_get_filename (dwz->dwz_bfd.get ()));
          return false;
        }
     }
@@ -5679,6 +5652,13 @@ public:
       m_addr (find_vec_in_debug_names (map, namei))
   {}
 
+  dw2_debug_names_iterator (const mapped_debug_names &map,
+                           block_enum block_index, domain_enum domain,
+                           uint32_t namei)
+    : m_map (map), m_block_index (block_index), m_domain (domain),
+      m_addr (find_vec_in_debug_names (map, namei))
+  {}
+
   /* Return the next matching CU or NULL if there are no more.  */
   dwarf2_per_cu_data *next ();
 
@@ -6096,6 +6076,63 @@ dw2_debug_names_expand_symtabs_for_function (struct objfile *objfile,
     }
 }
 
+static void
+dw2_debug_names_map_matching_symbols
+  (struct objfile *objfile,
+   const lookup_name_info &name, domain_enum domain,
+   int global,
+   gdb::function_view<symbol_found_callback_ftype> callback,
+   symbol_compare_ftype *ordered_compare)
+{
+  struct dwarf2_per_objfile *dwarf2_per_objfile
+    = get_dwarf2_per_objfile (objfile);
+
+  /* debug_names_table is NULL if OBJF_READNOW.  */
+  if (!dwarf2_per_objfile->debug_names_table)
+    return;
+
+  mapped_debug_names &map = *dwarf2_per_objfile->debug_names_table;
+  const block_enum block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
+
+  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 (map, name, matcher, ALL_DOMAIN,
+                                     [&] (offset_type namei)
+    {
+      /* The name was matched, now expand corresponding CUs that were
+        marked.  */
+      dw2_debug_names_iterator iter (map, block_kind, domain, namei);
+
+      struct dwarf2_per_cu_data *per_cu;
+      while ((per_cu = iter.next ()) != NULL)
+       dw2_expand_symtabs_matching_one (per_cu, nullptr, nullptr);
+      return true;
+    });
+
+  /* It's a shame we couldn't do this inside the
+     dw2_expand_symtabs_matching_symbol callback, but that skips CUs
+     that have already been expanded.  Instead, this loop matches what
+     the psymtab code does.  */
+  for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->all_comp_units)
+    {
+      struct compunit_symtab *cust = per_cu->v.quick->compunit_symtab;
+      if (cust != nullptr)
+       {
+         const struct block *block
+           = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), block_kind);
+         if (!iterate_over_symbols_terminated (block, name,
+                                               domain, callback))
+           break;
+       }
+    }
+}
+
 static void
 dw2_debug_names_expand_symtabs_matching
   (struct objfile *objfile,
@@ -6128,6 +6165,7 @@ dw2_debug_names_expand_symtabs_matching
       while ((per_cu = iter.next ()) != NULL)
        dw2_expand_symtabs_matching_one (per_cu, file_matcher,
                                         expansion_notify);
+      return true;
     });
 }
 
@@ -6143,7 +6181,7 @@ const struct quick_symbol_functions dwarf2_debug_names_functions =
   dw2_debug_names_expand_symtabs_for_function,
   dw2_expand_all_symtabs,
   dw2_expand_symtabs_with_fullname,
-  dw2_map_matching_symbols,
+  dw2_debug_names_map_matching_symbols,
   dw2_debug_names_expand_symtabs_matching,
   dw2_find_pc_sect_compunit_symtab,
   NULL,
@@ -12273,7 +12311,7 @@ locate_v1_virtual_dwo_sections (asection *sectp,
       if (sections->abbrev.s.section != NULL)
        return 0;
       sections->abbrev.s.section = sectp;
-      sections->abbrev.size = bfd_get_section_size (sectp);
+      sections->abbrev.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->info_dwo)
           || section_is_p (sectp->name, &names->types_dwo))
@@ -12282,7 +12320,7 @@ locate_v1_virtual_dwo_sections (asection *sectp,
       if (sections->info_or_types.s.section != NULL)
        return 0;
       sections->info_or_types.s.section = sectp;
-      sections->info_or_types.size = bfd_get_section_size (sectp);
+      sections->info_or_types.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->line_dwo))
     {
@@ -12290,7 +12328,7 @@ locate_v1_virtual_dwo_sections (asection *sectp,
       if (sections->line.s.section != NULL)
        return 0;
       sections->line.s.section = sectp;
-      sections->line.size = bfd_get_section_size (sectp);
+      sections->line.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->loc_dwo))
     {
@@ -12298,7 +12336,7 @@ locate_v1_virtual_dwo_sections (asection *sectp,
       if (sections->loc.s.section != NULL)
        return 0;
       sections->loc.s.section = sectp;
-      sections->loc.size = bfd_get_section_size (sectp);
+      sections->loc.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->macinfo_dwo))
     {
@@ -12306,7 +12344,7 @@ locate_v1_virtual_dwo_sections (asection *sectp,
       if (sections->macinfo.s.section != NULL)
        return 0;
       sections->macinfo.s.section = sectp;
-      sections->macinfo.size = bfd_get_section_size (sectp);
+      sections->macinfo.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->macro_dwo))
     {
@@ -12314,7 +12352,7 @@ locate_v1_virtual_dwo_sections (asection *sectp,
       if (sections->macro.s.section != NULL)
        return 0;
       sections->macro.s.section = sectp;
-      sections->macro.size = bfd_get_section_size (sectp);
+      sections->macro.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->str_offsets_dwo))
     {
@@ -12322,7 +12360,7 @@ locate_v1_virtual_dwo_sections (asection *sectp,
       if (sections->str_offsets.s.section != NULL)
        return 0;
       sections->str_offsets.s.section = sectp;
-      sections->str_offsets.size = bfd_get_section_size (sectp);
+      sections->str_offsets.size = bfd_section_size (sectp);
     }
   else
     {
@@ -12520,11 +12558,11 @@ create_dwp_v2_section (struct dwarf2_per_objfile *dwarf2_per_objfile,
      bounds of the real section.  This is a pretty-rare event, so just
      flag an error (easier) instead of a warning and trying to cope.  */
   if (sectp == NULL
-      || offset + size > bfd_get_section_size (sectp))
+      || offset + size > bfd_section_size (sectp))
     {
       error (_("Dwarf Error: Bad DWP V2 section info, doesn't fit"
               " in section %s [in module %s]"),
-            sectp ? bfd_section_name (abfd, sectp) : "<unknown>",
+            sectp ? bfd_section_name (sectp) : "<unknown>",
             objfile_name (dwarf2_per_objfile->objfile));
     }
 
@@ -12895,42 +12933,42 @@ dwarf2_locate_dwo_sections (bfd *abfd, asection *sectp, void *dwo_sections_ptr)
   if (section_is_p (sectp->name, &names->abbrev_dwo))
     {
       dwo_sections->abbrev.s.section = sectp;
-      dwo_sections->abbrev.size = bfd_get_section_size (sectp);
+      dwo_sections->abbrev.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->info_dwo))
     {
       dwo_sections->info.s.section = sectp;
-      dwo_sections->info.size = bfd_get_section_size (sectp);
+      dwo_sections->info.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->line_dwo))
     {
       dwo_sections->line.s.section = sectp;
-      dwo_sections->line.size = bfd_get_section_size (sectp);
+      dwo_sections->line.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->loc_dwo))
     {
       dwo_sections->loc.s.section = sectp;
-      dwo_sections->loc.size = bfd_get_section_size (sectp);
+      dwo_sections->loc.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->macinfo_dwo))
     {
       dwo_sections->macinfo.s.section = sectp;
-      dwo_sections->macinfo.size = bfd_get_section_size (sectp);
+      dwo_sections->macinfo.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->macro_dwo))
     {
       dwo_sections->macro.s.section = sectp;
-      dwo_sections->macro.size = bfd_get_section_size (sectp);
+      dwo_sections->macro.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->str_dwo))
     {
       dwo_sections->str.s.section = sectp;
-      dwo_sections->str.size = bfd_get_section_size (sectp);
+      dwo_sections->str.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->str_offsets_dwo))
     {
       dwo_sections->str_offsets.s.section = sectp;
-      dwo_sections->str_offsets.size = bfd_get_section_size (sectp);
+      dwo_sections->str_offsets.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->types_dwo))
     {
@@ -12938,7 +12976,7 @@ dwarf2_locate_dwo_sections (bfd *abfd, asection *sectp, void *dwo_sections_ptr)
 
       memset (&type_section, 0, sizeof (type_section));
       type_section.s.section = sectp;
-      type_section.size = bfd_get_section_size (sectp);
+      type_section.size = bfd_section_size (sectp);
       dwo_sections->types.push_back (type_section);
     }
 }
@@ -13002,17 +13040,17 @@ dwarf2_locate_common_dwp_sections (bfd *abfd, asection *sectp,
   if (section_is_p (sectp->name, &names->str_dwo))
     {
       dwp_file->sections.str.s.section = sectp;
-      dwp_file->sections.str.size = bfd_get_section_size (sectp);
+      dwp_file->sections.str.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->cu_index))
     {
       dwp_file->sections.cu_index.s.section = sectp;
-      dwp_file->sections.cu_index.size = bfd_get_section_size (sectp);
+      dwp_file->sections.cu_index.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->tu_index))
     {
       dwp_file->sections.tu_index.s.section = sectp;
-      dwp_file->sections.tu_index.size = bfd_get_section_size (sectp);
+      dwp_file->sections.tu_index.size = bfd_section_size (sectp);
     }
 }
 
@@ -13037,42 +13075,42 @@ dwarf2_locate_v2_dwp_sections (bfd *abfd, asection *sectp, void *dwp_file_ptr)
   if (section_is_p (sectp->name, &names->abbrev_dwo))
     {
       dwp_file->sections.abbrev.s.section = sectp;
-      dwp_file->sections.abbrev.size = bfd_get_section_size (sectp);
+      dwp_file->sections.abbrev.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->info_dwo))
     {
       dwp_file->sections.info.s.section = sectp;
-      dwp_file->sections.info.size = bfd_get_section_size (sectp);
+      dwp_file->sections.info.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->line_dwo))
     {
       dwp_file->sections.line.s.section = sectp;
-      dwp_file->sections.line.size = bfd_get_section_size (sectp);
+      dwp_file->sections.line.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->loc_dwo))
     {
       dwp_file->sections.loc.s.section = sectp;
-      dwp_file->sections.loc.size = bfd_get_section_size (sectp);
+      dwp_file->sections.loc.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->macinfo_dwo))
     {
       dwp_file->sections.macinfo.s.section = sectp;
-      dwp_file->sections.macinfo.size = bfd_get_section_size (sectp);
+      dwp_file->sections.macinfo.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->macro_dwo))
     {
       dwp_file->sections.macro.s.section = sectp;
-      dwp_file->sections.macro.size = bfd_get_section_size (sectp);
+      dwp_file->sections.macro.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->str_offsets_dwo))
     {
       dwp_file->sections.str_offsets.s.section = sectp;
-      dwp_file->sections.str_offsets.size = bfd_get_section_size (sectp);
+      dwp_file->sections.str_offsets.size = bfd_section_size (sectp);
     }
   else if (section_is_p (sectp->name, &names->types_dwo))
     {
       dwp_file->sections.types.s.section = sectp;
-      dwp_file->sections.types.size = bfd_get_section_size (sectp);
+      dwp_file->sections.types.size = bfd_section_size (sectp);
     }
 }
 
@@ -18495,7 +18533,7 @@ load_partial_dies (const struct die_reader_specs *reader,
              || pdi.tag == DW_TAG_subrange_type))
        {
          if (building_psymtab && pdi.name != NULL)
-           add_psymbol_to_list (pdi.name, strlen (pdi.name), 0,
+           add_psymbol_to_list (pdi.name, strlen (pdi.name), false,
                                 VAR_DOMAIN, LOC_TYPEDEF, -1,
                                 psymbol_placement::STATIC,
                                 0, cu->language, objfile);
@@ -18529,7 +18567,7 @@ load_partial_dies (const struct die_reader_specs *reader,
          if (pdi.name == NULL)
            complaint (_("malformed enumerator DIE ignored"));
          else if (building_psymtab)
-           add_psymbol_to_list (pdi.name, strlen (pdi.name), 0,
+           add_psymbol_to_list (pdi.name, strlen (pdi.name), false,
                                 VAR_DOMAIN, LOC_CONST, -1,
                                 cu->language == language_cplus
                                 ? psymbol_placement::GLOBAL
@@ -19721,11 +19759,11 @@ read_indirect_string_from_dwz (struct objfile *objfile, struct dwz_file *dwz,
   if (dwz->str.buffer == NULL)
     error (_("DW_FORM_GNU_strp_alt used without .debug_str "
             "section [in module %s]"),
-          bfd_get_filename (dwz->dwz_bfd));
+          bfd_get_filename (dwz->dwz_bfd.get ()));
   if (str_offset >= dwz->str.size)
     error (_("DW_FORM_GNU_strp_alt pointing outside of "
             ".debug_str section [in module %s]"),
-          bfd_get_filename (dwz->dwz_bfd));
+          bfd_get_filename (dwz->dwz_bfd.get ()));
   gdb_assert (HOST_CHAR_BIT == 8);
   if (dwz->str.buffer[str_offset] == '\0')
     return NULL;
@@ -25799,7 +25837,7 @@ show_dwarf_cmd (const char *args, int from_tty)
   cmd_show_list (show_dwarf_cmdlist, from_tty, "");
 }
 
-int dwarf_always_disassemble;
+bool dwarf_always_disassemble;
 
 static void
 show_dwarf_always_disassemble (struct ui_file *file, int from_tty,
This page took 0.044072 seconds and 4 git commands to generate.