gdb: Convert language la_get_symbol_name_matcher field to a method
[deliverable/binutils-gdb.git] / gdb / dwarf2 / read.c
index 97d1771a6295eaf36b4f4e93c13c25e9be287127..34915be8da7abb9f74998a4c6ad03a9a3c6ab52f 100644 (file)
@@ -3436,31 +3436,64 @@ struct dw2_symtab_iterator
   int global_seen;
 };
 
-/* Initialize the index symtab iterator ITER.  */
+/* Initialize the index symtab iterator ITER, common part.  */
 
 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,
-                     const char *name)
+dw2_symtab_iter_init_common (struct dw2_symtab_iterator *iter,
+                            dwarf2_per_objfile *per_objfile,
+                            gdb::optional<block_enum> block_index,
+                            domain_enum domain)
 {
   iter->per_objfile = per_objfile;
   iter->block_index = block_index;
   iter->domain = domain;
   iter->next = 0;
   iter->global_seen = 0;
+  iter->vec = NULL;
+  iter->length = 0;
+}
 
-  mapped_index *index = per_objfile->per_bfd->index_table.get ();
+/* Initialize the index symtab iterator ITER, const char *NAME variant.  */
+
+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,
+                     const char *name)
+{
+  dw2_symtab_iter_init_common (iter, per_objfile, block_index, domain);
 
+  mapped_index *index = per_objfile->per_bfd->index_table.get ();
   /* index is NULL if OBJF_READNOW.  */
-  if (index != NULL && find_slot_in_mapped_hash (index, name, &iter->vec))
+  if (index == NULL)
+    return;
+
+  if (find_slot_in_mapped_hash (index, name, &iter->vec))
     iter->length = MAYBE_SWAP (*iter->vec);
-  else
-    {
-      iter->vec = NULL;
-      iter->length = 0;
-    }
+}
+
+/* Initialize the index symtab iterator ITER, offset_type NAMEI variant.  */
+
+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)
+{
+  dw2_symtab_iter_init_common (iter, per_objfile, block_index, domain);
+
+  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));
+  const auto &bucket = index->symbol_table[namei];
+
+  iter->vec = (offset_type *) (index->constant_pool
+                              + MAYBE_SWAP (bucket.vec));
+  iter->length = MAYBE_SWAP (*iter->vec);
 }
 
 /* Return the next matching CU or NULL if there are no more.  */
@@ -3745,9 +3778,6 @@ dw2_map_matching_symbols
 
   if (per_objfile->per_bfd->index_table != nullptr)
     {
-      /* Ada currently doesn't support .gdb_index (see PR24713).  We can get
-        here though if the current language is Ada for a non-Ada objfile
-        using GNU index.  */
       mapped_index &index = *per_objfile->per_bfd->index_table;
 
       const char *match_name = name.ada ().lookup_name ().c_str ();
@@ -3765,7 +3795,7 @@ dw2_map_matching_symbols
        struct dwarf2_per_cu_data *per_cu;
 
        dw2_symtab_iter_init (&iter, per_objfile, block_kind, domain,
-                             match_name);
+                             namei);
        while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
          dw2_expand_symtabs_matching_one (per_cu, per_objfile, nullptr,
                                           nullptr);
@@ -4067,7 +4097,7 @@ dw2_expand_symtabs_matching_symbol
 
       const language_defn *lang = language_def (lang_e);
       symbol_name_matcher_ftype *name_matcher
-       = get_symbol_name_matcher (lang, lookup_name_without_params);
+       = lang->get_symbol_name_matcher (lookup_name_without_params);
 
       name_and_matcher key {
          name_matcher,
@@ -18844,8 +18874,8 @@ guess_partial_die_structure_name (struct partial_die_info *struct_pdi,
          && child_pdi->linkage_name != NULL)
        {
          gdb::unique_xmalloc_ptr<char> actual_class_name
-           (language_class_name_from_physname (cu->language_defn,
-                                               child_pdi->linkage_name));
+           (cu->language_defn->class_name_from_physname
+            (child_pdi->linkage_name));
          if (actual_class_name != NULL)
            {
              struct objfile *objfile = cu->per_objfile->objfile;
@@ -21685,8 +21715,7 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu)
          if (linkage_name != NULL)
            {
              gdb::unique_xmalloc_ptr<char> actual_name
-               (language_class_name_from_physname (cu->language_defn,
-                                                   linkage_name));
+               (cu->language_defn->class_name_from_physname (linkage_name));
              const char *name = NULL;
 
              if (actual_name != NULL)
This page took 0.031025 seconds and 4 git commands to generate.