[NIOS2] Fix disassembly of br.n instruction.
[deliverable/binutils-gdb.git] / gdb / symtab.c
index dccc3d1e2379af30dfb286658bb45a69735bb020..122fdf0b1d3ea908c47069fc60b20dcbf2508a8c 100644 (file)
@@ -1,6 +1,6 @@
 /* Symbol table lookup for the GNU debugger, GDB.
 
-   Copyright (C) 1986-2020 Free Software Foundation, Inc.
+   Copyright (C) 1986-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -42,6 +42,7 @@
 #include "addrmap.h"
 #include "cli/cli-utils.h"
 #include "cli/cli-style.h"
+#include "cli/cli-cmds.h"
 #include "fnmatch.h"
 #include "hashtab.h"
 #include "typeprint.h"
@@ -554,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;
     }
 }
@@ -1011,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)
@@ -1103,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;
     }
@@ -1644,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
@@ -1696,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;
            }
        }
@@ -1705,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);
     }
 }
 
@@ -1729,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.  */
@@ -1842,7 +1847,8 @@ demangle_for_lookup (const char *name, enum language lang,
     }
   else if (lang == language_go)
     {
-      char *demangled_name = go_demangle (name, 0);
+      char *demangled_name
+       = language_def (language_go)->demangle_symbol (name, 0);
       if (demangled_name != NULL)
        return storage.set_malloc_ptr (demangled_name);
     }
@@ -2357,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,
@@ -2370,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)
@@ -2537,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;
@@ -2737,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;
 
@@ -2943,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;
            }
@@ -2970,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;
                    }
@@ -2994,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;
     }
@@ -3048,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 ())
            {
@@ -3064,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);
@@ -3440,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 ())
        {
@@ -3730,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;
@@ -3821,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
@@ -3834,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 ();
     }
 
@@ -4565,21 +4540,19 @@ 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,
+     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
@@ -5591,10 +5564,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)
            {
@@ -6461,7 +6432,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
@@ -6929,10 +6901,13 @@ If zero then the symbol cache is disabled."),
           _("Print symbol cache statistics for each program space."),
           &maintenanceprintlist);
 
-  add_cmd ("flush-symbol-cache", class_maintenance,
+  add_cmd ("symbol-cache", class_maintenance,
           maintenance_flush_symbol_cache,
           _("Flush the symbol cache for each program space."),
-          &maintenancelist);
+          &maintenanceflushlist);
+  c = add_alias_cmd ("flush-symbol-cache", "flush symbol-cache",
+                    class_maintenance, 0, &maintenancelist);
+  deprecate_cmd (c, "maintenancelist flush symbol-cache");
 
   gdb::observers::executable_changed.attach (symtab_observer_executable_changed);
   gdb::observers::new_objfile.attach (symtab_new_objfile_observer);
This page took 0.034632 seconds and 4 git commands to generate.