Add 'domain' parameter to expand_symtabs_matching
[deliverable/binutils-gdb.git] / gdb / symtab.c
index 7ffb52a94358f9f17d618cff1d1e1eceb214f943..274ddfd1dae26763050d048c9ecbebb6d8046b09 100644 (file)
@@ -555,11 +555,8 @@ iterate_over_symtabs (const char *name,
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      if (objfile->sf
-         && objfile->sf->qf->map_symtabs_matching_filename (objfile,
-                                                            name,
-                                                            real_path.get (),
-                                                            callback))
+      if (objfile->map_symtabs_matching_filename (name, real_path.get (),
+                                                 callback))
        return;
     }
 }
@@ -1012,6 +1009,16 @@ general_symbol_info::search_name () const
 
 /* See symtab.h.  */
 
+struct obj_section *
+general_symbol_info::obj_section (const struct objfile *objfile) const
+{
+  if (section_index () >= 0)
+    return &objfile->sections[section_index ()];
+  return nullptr;
+}
+
+/* See symtab.h.  */
+
 bool
 symbol_matches_search_name (const struct general_symbol_info *gsymbol,
                            const lookup_name_info &name)
@@ -1104,11 +1111,8 @@ expand_symtab_containing_pc (CORE_ADDR pc, struct obj_section *section)
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      struct compunit_symtab *cust = NULL;
-
-      if (objfile->sf)
-       cust = objfile->sf->qf->find_pc_sect_compunit_symtab (objfile, msymbol,
-                                                             pc, section, 0);
+      struct compunit_symtab *cust
+       = objfile->find_pc_sect_compunit_symtab (msymbol, pc, section, 0);
       if (cust)
        return;
     }
@@ -1645,7 +1649,7 @@ fixup_section (struct general_symbol_info *ginfo,
   msym = lookup_minimal_symbol_by_pc_name (addr, ginfo->linkage_name (),
                                           objfile);
   if (msym)
-    ginfo->section = MSYMBOL_SECTION (msym);
+    ginfo->set_section_index (msym->section_index ());
   else
     {
       /* Static, function-local variables do appear in the linker
@@ -1697,7 +1701,7 @@ fixup_section (struct general_symbol_info *ginfo,
          if (obj_section_addr (s) - offset <= addr
              && addr < obj_section_endaddr (s) - offset)
            {
-             ginfo->section = idx;
+             ginfo->set_section_index (idx);
              return;
            }
        }
@@ -1706,9 +1710,9 @@ fixup_section (struct general_symbol_info *ginfo,
         section.  If there is no allocated section, then it hardly
         matters what we pick, so just pick zero.  */
       if (fallback == -1)
-       ginfo->section = 0;
+       ginfo->set_section_index (0);
       else
-       ginfo->section = fallback;
+       ginfo->set_section_index (fallback);
     }
 }
 
@@ -1730,7 +1734,7 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
   if (objfile == NULL)
     objfile = symbol_objfile (sym);
 
-  if (SYMBOL_OBJ_SECTION (objfile, sym))
+  if (sym->obj_section (objfile) != nullptr)
     return sym;
 
   /* We should have an objfile by now.  */
@@ -2359,9 +2363,6 @@ lookup_symbol_via_quick_fns (struct objfile *objfile,
   const struct block *block;
   struct block_symbol result;
 
-  if (!objfile->sf)
-    return {};
-
   if (symbol_lookup_debug > 1)
     {
       fprintf_unfiltered (gdb_stdlog,
@@ -2372,7 +2373,7 @@ lookup_symbol_via_quick_fns (struct objfile *objfile,
                          name, domain_name (domain));
     }
 
-  cust = objfile->sf->qf->lookup_symbol (objfile, block_index, name, domain);
+  cust = objfile->lookup_symbol (block_index, name, domain);
   if (cust == NULL)
     {
       if (symbol_lookup_debug > 1)
@@ -2539,23 +2540,13 @@ lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index,
 static enum language
 find_quick_global_symbol_language (const char *name, const domain_enum domain)
 {
-  for (objfile *objfile : current_program_space->objfiles ())
-    {
-      if (objfile->sf && objfile->sf->qf
-         && objfile->sf->qf->lookup_global_symbol_language)
-       continue;
-      return language_unknown;
-    }
-
   for (objfile *objfile : current_program_space->objfiles ())
     {
       bool symbol_found_p;
       enum language lang
-       = objfile->sf->qf->lookup_global_symbol_language (objfile, name, domain,
-                                                         &symbol_found_p);
-      if (!symbol_found_p)
-       continue;
-      return lang;
+       = objfile->lookup_global_symbol_language (name, domain, &symbol_found_p);
+      if (symbol_found_p)
+       return lang;
     }
 
   return language_unknown;
@@ -2739,10 +2730,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile,
   const struct block *block;
   struct symbol *sym;
 
-  if (!objfile->sf)
-    return NULL;
-  cust = objfile->sf->qf->lookup_symbol (objfile, block_index, name,
-                                        STRUCT_DOMAIN);
+  cust = objfile->lookup_symbol (block_index, name, STRUCT_DOMAIN);
   if (cust == NULL)
     return NULL;
 
@@ -2945,16 +2933,15 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
          /* In order to better support objfiles that contain both
             stabs and coff debugging info, we continue on if a psymtab
             can't be found.  */
-         if ((obj_file->flags & OBJF_REORDERED) && obj_file->sf)
+         if ((obj_file->flags & OBJF_REORDERED) != 0)
            {
              struct compunit_symtab *result;
 
              result
-               = obj_file->sf->qf->find_pc_sect_compunit_symtab (obj_file,
-                                                                 msymbol,
-                                                                 pc,
-                                                                 section,
-                                                                 0);
+               = obj_file->find_pc_sect_compunit_symtab (msymbol,
+                                                         pc,
+                                                         section,
+                                                         0);
              if (result != NULL)
                return result;
            }
@@ -2972,8 +2959,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
                  ALL_BLOCK_SYMBOLS (b, iter, sym)
                    {
                      fixup_symbol_section (sym, obj_file);
-                     if (matching_obj_sections (SYMBOL_OBJ_SECTION (obj_file,
-                                                                    sym),
+                     if (matching_obj_sections (sym->obj_section (obj_file),
                                                 section))
                        break;
                    }
@@ -2996,14 +2982,8 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
 
   for (objfile *objf : current_program_space->objfiles ())
     {
-      struct compunit_symtab *result;
-
-      if (!objf->sf)
-       continue;
-      result = objf->sf->qf->find_pc_sect_compunit_symtab (objf,
-                                                          msymbol,
-                                                          pc, section,
-                                                          1);
+      struct compunit_symtab *result
+       = objf->find_pc_sect_compunit_symtab (msymbol, pc, section, 1);
       if (result != NULL)
        return result;
     }
@@ -3050,11 +3030,9 @@ find_symbol_at_address (CORE_ADDR address)
 
   for (objfile *objfile : current_program_space->objfiles ())
     {
-      /* If this objfile doesn't have "quick" functions, then it may
-        have been read with -readnow, in which case we need to search
-        the symtabs directly.  */
-      if (objfile->sf == NULL
-         || objfile->sf->qf->find_compunit_symtab_by_address == NULL)
+      /* If this objfile was read with -readnow, then we need to
+        search the symtabs directly.  */
+      if ((objfile->flags & OBJF_READNOW) != 0)
        {
          for (compunit_symtab *symtab : objfile->compunits ())
            {
@@ -3066,8 +3044,7 @@ find_symbol_at_address (CORE_ADDR address)
       else
        {
          struct compunit_symtab *symtab
-           = objfile->sf->qf->find_compunit_symtab_by_address (objfile,
-                                                               address);
+           = objfile->find_compunit_symtab_by_address (address);
          if (symtab != NULL)
            {
              struct symbol *sym = search_symtab (symtab, address);
@@ -3442,11 +3419,7 @@ find_line_symtab (struct symtab *sym_tab, int line,
        best = 0;
 
       for (objfile *objfile : current_program_space->objfiles ())
-       {
-         if (objfile->sf)
-           objfile->sf->qf->expand_symtabs_with_fullname
-             (objfile, symtab_to_fullname (sym_tab));
-       }
+       objfile->expand_symtabs_with_fullname (symtab_to_fullname (sym_tab));
 
       for (objfile *objfile : current_program_space->objfiles ())
        {
@@ -3732,7 +3705,7 @@ find_function_start_sal (symbol *sym, bool funfirstline)
   fixup_symbol_section (sym, NULL);
   symtab_and_line sal
     = find_function_start_sal_1 (BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym)),
-                                SYMBOL_OBJ_SECTION (symbol_objfile (sym), sym),
+                                sym->obj_section (symbol_objfile (sym)),
                                 funfirstline);
   sal.symbol = sym;
   return sal;
@@ -3823,7 +3796,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
 
       objfile = symbol_objfile (sym);
       pc = BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (sym));
-      section = SYMBOL_OBJ_SECTION (objfile, sym);
+      section = sym->obj_section (objfile);
       name = sym->linkage_name ();
     }
   else
@@ -3836,7 +3809,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
 
       objfile = msymbol.objfile;
       pc = BMSYMBOL_VALUE_ADDRESS (msymbol);
-      section = MSYMBOL_OBJ_SECTION (objfile, msymbol.minsym);
+      section = msymbol.minsym->obj_section (objfile);
       name = msymbol.minsym->linkage_name ();
     }
 
@@ -4254,15 +4227,21 @@ struct output_source_filename_data
 
   /* Flag of whether we're printing the first one.  */
   int first;
-};
 
-/* Slave routine for sources_info.  Force line breaks at ,'s.
-   NAME is the name to print.
-   DATA contains the state for printing and watching for duplicates.  */
+  /* Worker for sources_info.  Force line breaks at ,'s.
+     NAME is the name to print.  */
+  void output (const char *name);
 
-static void
-output_source_filename (const char *name,
-                       struct output_source_filename_data *data)
+  /* An overload suitable for use as a callback to
+     quick_symbol_functions::map_symbol_filenames.  */
+  void operator() (const char *filename, const char *fullname)
+  {
+    output (fullname != nullptr ? fullname : filename);
+  }
+};
+
+void
+output_source_filename_data::output (const char *name)
 {
   /* Since a single source file can result in several partial symbol
      tables, we need to avoid printing it more than once.  Note: if
@@ -4274,51 +4253,41 @@ output_source_filename (const char *name,
      symtabs; it doesn't hurt to check.  */
 
   /* Was NAME already seen?  */
-  if (data->filename_seen_cache->seen (name))
+  if (filename_seen_cache->seen (name))
     {
       /* Yes; don't print it again.  */
       return;
     }
 
-  /* Does it match data->regexp?  */
-  if (data->c_regexp.has_value ())
+  /* Does it match regexp?  */
+  if (c_regexp.has_value ())
     {
       const char *to_match;
       std::string dirname;
 
-      if (data->partial_match.dirname)
+      if (partial_match.dirname)
        {
          dirname = ldirname (name);
          to_match = dirname.c_str ();
        }
-      else if (data->partial_match.basename)
+      else if (partial_match.basename)
        to_match = lbasename (name);
       else
        to_match = name;
 
-      if (data->c_regexp->exec (to_match, 0, NULL, 0) != 0)
+      if (c_regexp->exec (to_match, 0, NULL, 0) != 0)
        return;
     }
 
   /* Print it and reset *FIRST.  */
-  if (! data->first)
+  if (! first)
     printf_filtered (", ");
-  data->first = 0;
+  first = 0;
 
   wrap_here ("");
   fputs_styled (name, file_name_style.style (), gdb_stdout);
 }
 
-/* A callback for map_partial_symbol_filenames.  */
-
-static void
-output_partial_symbol_filename (const char *filename, const char *fullname,
-                               void *data)
-{
-  output_source_filename (fullname ? fullname : filename,
-                         (struct output_source_filename_data *) data);
-}
-
 using isrc_flag_option_def
   = gdb::option::flag_option_def<filename_partial_match_opts>;
 
@@ -4437,7 +4406,7 @@ info_sources_command (const char *args, int from_tty)
            {
              const char *fullname = symtab_to_fullname (s);
 
-             output_source_filename (fullname, &data);
+             data.output (fullname);
            }
        }
     }
@@ -4448,8 +4417,7 @@ info_sources_command (const char *args, int from_tty)
 
   filenames_seen.clear ();
   data.first = 1;
-  map_symbol_filenames (output_partial_symbol_filename, &data,
-                       1 /*need_fullname*/);
+  map_symbol_filenames (data, true /*need_fullname*/);
   printf_filtered ("\n");
 }
 
@@ -4567,21 +4535,21 @@ global_symbol_searcher::expand_symtabs
   enum search_domain kind = m_kind;
   bool found_msymbol = false;
 
-  if (objfile->sf)
-    objfile->sf->qf->expand_symtabs_matching
-      (objfile,
-       [&] (const char *filename, bool basenames)
-       {
-        return file_matches (filename, filenames, basenames);
-       },
-       &lookup_name_info::match_any (),
-       [&] (const char *symname)
-       {
-        return (!preg.has_value ()
-                || preg->exec (symname, 0, NULL, 0) == 0);
-       },
-       NULL,
-       kind);
+  objfile->expand_symtabs_matching
+    ([&] (const char *filename, bool basenames)
+     {
+       return file_matches (filename, filenames, basenames);
+     },
+     &lookup_name_info::match_any (),
+     [&] (const char *symname)
+     {
+       return (!preg.has_value ()
+              || preg->exec (symname, 0, NULL, 0) == 0);
+     },
+     NULL,
+     SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
+     UNDEF_DOMAIN,
+     kind);
 
   /* Here, we search through the minimal symbol tables for functions and
      variables that match, and force their symbols to be read.  This is in
@@ -5593,10 +5561,8 @@ find_gnu_ifunc (const symbol *sym)
          if (MSYMBOL_TYPE (minsym) == mst_data_gnu_ifunc)
            {
              struct gdbarch *gdbarch = objfile->arch ();
-             msym_addr
-               = gdbarch_convert_from_func_ptr_addr (gdbarch,
-                                                     msym_addr,
-                                                     current_top_target ());
+             msym_addr = gdbarch_convert_from_func_ptr_addr
+               (gdbarch, msym_addr, current_inferior ()->top_target ());
            }
          if (msym_addr == address)
            {
@@ -5766,7 +5732,9 @@ default_collect_symbol_completion_matches_break_on
                               add_symtab_completions (symtab,
                                                       tracker, mode, lookup_name,
                                                       sym_text, word, code);
+                              return true;
                             },
+                          SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
                           ALL_DOMAIN);
 
   /* Search upwards from currently selected frame (so that we can
@@ -5988,7 +5956,7 @@ not_interesting_fname (const char *fname)
   return 0;
 }
 
-/* An object of this type is passed as the user_data argument to
+/* An object of this type is passed as the callback argument to
    map_partial_symbol_filenames.  */
 struct add_partial_filename_data
 {
@@ -5997,34 +5965,33 @@ struct add_partial_filename_data
   const char *word;
   int text_len;
   completion_list *list;
+
+  void operator() (const char *filename, const char *fullname);
 };
 
 /* A callback for map_partial_symbol_filenames.  */
 
-static void
-maybe_add_partial_symtab_filename (const char *filename, const char *fullname,
-                                  void *user_data)
+void
+add_partial_filename_data::operator() (const char *filename,
+                                      const char *fullname)
 {
-  struct add_partial_filename_data *data
-    = (struct add_partial_filename_data *) user_data;
-
   if (not_interesting_fname (filename))
     return;
-  if (!data->filename_seen_cache->seen (filename)
-      && filename_ncmp (filename, data->text, data->text_len) == 0)
+  if (!filename_seen_cache->seen (filename)
+      && filename_ncmp (filename, text, text_len) == 0)
     {
       /* This file matches for a completion; add it to the
         current list of matches.  */
-      add_filename_to_list (filename, data->text, data->word, data->list);
+      add_filename_to_list (filename, text, word, list);
     }
   else
     {
       const char *base_name = lbasename (filename);
 
       if (base_name != filename
-         && !data->filename_seen_cache->seen (base_name)
-         && filename_ncmp (base_name, data->text, data->text_len) == 0)
-       add_filename_to_list (base_name, data->text, data->word, data->list);
+         && !filename_seen_cache->seen (base_name)
+         && filename_ncmp (base_name, text, text_len) == 0)
+       add_filename_to_list (base_name, text, word, list);
     }
 }
 
@@ -6081,8 +6048,7 @@ make_source_files_completion_list (const char *text, const char *word)
   datum.word = word;
   datum.text_len = text_len;
   datum.list = &list;
-  map_symbol_filenames (maybe_add_partial_symtab_filename, &datum,
-                       0 /*need_fullname*/);
+  map_symbol_filenames (datum, false /*need_fullname*/);
 
   return list;
 }
@@ -6463,7 +6429,8 @@ get_msymbol_address (struct objfile *objf, const struct minimal_symbol *minsym)
            return BMSYMBOL_VALUE_ADDRESS (found);
        }
     }
-  return minsym->value.address + objf->section_offsets[minsym->section];
+  return (minsym->value.address
+         + objf->section_offsets[minsym->section_index ()]);
 }
 
 \f
This page took 0.037559 seconds and 4 git commands to generate.