gdb/testsuite: make test names unique in gdb.python/py-format-string.exp
[deliverable/binutils-gdb.git] / gdb / minsyms.c
index e238355dc1175f433146e983be289d80dcf22648..3cf849f48bf00a8a3d2dfd0cc4b1380497ce24a1 100644 (file)
@@ -1,5 +1,5 @@
 /* GDB routines for manipulating the minimal symbol tables.
-   Copyright (C) 1992-2020 Free Software Foundation, Inc.
+   Copyright (C) 1992-2021 Free Software Foundation, Inc.
    Contributed by Cygnus Support, using pieces from other GDB modules.
 
    This file is part of GDB.
@@ -77,7 +77,7 @@ msymbol_is_function (struct objfile *objfile, minimal_symbol *minsym,
     case mst_file_bss:
     case mst_data_gnu_ifunc:
       {
-       struct gdbarch *gdbarch = get_objfile_arch (objfile);
+       struct gdbarch *gdbarch = objfile->arch ();
        CORE_ADDR pc
          = gdbarch_convert_from_func_ptr_addr (gdbarch, msym_addr,
                                                current_top_target ());
@@ -363,8 +363,8 @@ lookup_minimal_symbol (const char *name, const char *sfile,
                       % MINIMAL_SYMBOL_HASH_SIZE);
 
                  symbol_name_matcher_ftype *match
-                   = get_symbol_name_matcher (language_def (lang),
-                                              lookup_name);
+                   = language_def (lang)->get_symbol_name_matcher
+                                                       (lookup_name);
                  struct minimal_symbol **msymbol_demangled_hash
                    = objfile->per_bfd->msymbol_demangled_hash;
 
@@ -467,7 +467,7 @@ linkage_name_str (const lookup_name_info &lookup_name)
   if (current_language->la_language == language_ada)
     return lookup_name.ada ().lookup_name ().c_str ();
 
-  return lookup_name.name ().c_str ();
+  return lookup_name.c_str ();
 }
 
 /* See minsyms.h.  */
@@ -507,7 +507,7 @@ iterate_over_minimal_symbols
       enum language lang = (enum language) liter;
       const language_defn *lang_def = language_def (lang);
       symbol_name_matcher_ftype *name_match
-       = get_symbol_name_matcher (lang_def, lookup_name);
+       = lang_def->get_symbol_name_matcher (lookup_name);
 
       unsigned int hash
        = lookup_name.search_name_hash (lang) % MINIMAL_SYMBOL_HASH_SIZE;
@@ -718,13 +718,13 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
       CORE_ADDR pc = pc_in;
 
       /* If this objfile has a minimal symbol table, go search it
-         using a binary search.  */
+        using a binary search.  */
 
       if (objfile->per_bfd->minimal_symbol_count > 0)
        {
          int best_zero_sized = -1;
 
-          msymbol = objfile->per_bfd->msymbols.get ();
+         msymbol = objfile->per_bfd->msymbols.get ();
          lo = 0;
          hi = objfile->per_bfd->minimal_symbol_count - 1;
 
@@ -766,8 +766,8 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
                }
 
              /* If we have multiple symbols at the same address, we want
-                hi to point to the last one.  That way we can find the
-                right symbol if it has an index greater than hi.  */
+                hi to point to the last one.  That way we can find the
+                right symbol if it has an index greater than hi.  */
              while (hi < objfile->per_bfd->minimal_symbol_count - 1
                     && (MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi])
                         == MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi + 1])))
@@ -800,9 +800,9 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
                      /* Some types of debug info, such as COFF,
                         don't fill the bfd_section member, so don't
                         throw away symbols on those platforms.  */
-                     && MSYMBOL_OBJ_SECTION (objfile, &msymbol[hi]) != NULL
+                     && msymbol[hi].obj_section (objfile) != nullptr
                      && (!matching_obj_sections
-                         (MSYMBOL_OBJ_SECTION (objfile, &msymbol[hi]),
+                         (msymbol[hi].obj_section (objfile),
                           section)))
                    {
                      hi--;
@@ -820,8 +820,8 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
                          == MSYMBOL_SIZE (&msymbol[hi - 1]))
                      && (MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi])
                          == MSYMBOL_VALUE_RAW_ADDRESS (&msymbol[hi - 1]))
-                     && (MSYMBOL_OBJ_SECTION (objfile, &msymbol[hi])
-                         == MSYMBOL_OBJ_SECTION (objfile, &msymbol[hi - 1])))
+                     && (msymbol[hi].obj_section (objfile)
+                         == msymbol[hi - 1].obj_section (objfile)))
                    {
                      hi--;
                      continue;
@@ -906,8 +906,8 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
                }
 
              /* The minimal symbol indexed by hi now is the best one in this
-                objfile's minimal symbol table.  See if it is the best one
-                overall.  */
+                objfile's minimal symbol table.  See if it is the best one
+                overall.  */
 
              if (hi >= 0
                  && ((best_symbol == NULL) ||
@@ -1008,8 +1008,12 @@ get_symbol_leading_char (bfd *abfd)
 {
   if (abfd != NULL)
     return bfd_get_symbol_leading_char (abfd);
-  if (symfile_objfile != NULL && symfile_objfile->obfd != NULL)
-    return bfd_get_symbol_leading_char (symfile_objfile->obfd);
+  if (current_program_space->symfile_object_file != NULL)
+    {
+      objfile *objf = current_program_space->symfile_object_file;
+      if (objf->obfd != NULL)
+       return bfd_get_symbol_leading_char (objf->obfd);
+    }
   return 0;
 }
 
@@ -1132,7 +1136,7 @@ minimal_symbol_reader::record_full (gdb::string_view name,
 
   if (symtab_create_debug >= 2)
     printf_unfiltered ("Recording minsym:  %-21s  %18s  %4d  %.*s\n",
-               mst_str (ms_type), hex_string (address), section,
+              mst_str (ms_type), hex_string (address), section,
               (int) name.size (), name.data ());
 
   if (m_msym_bunch_index == BUNCH_SIZE)
@@ -1153,7 +1157,7 @@ minimal_symbol_reader::record_full (gdb::string_view name,
     msymbol->m_name = name.data ();
 
   SET_MSYMBOL_VALUE_ADDRESS (msymbol, address);
-  MSYMBOL_SECTION (msymbol) = section;
+  msymbol->set_section_index (section);
 
   MSYMBOL_TYPE (msymbol) = ms_type;
 
@@ -1242,7 +1246,8 @@ compact_minimal_symbols (struct minimal_symbol *msymbol, int mcount,
        {
          if (MSYMBOL_VALUE_RAW_ADDRESS (copyfrom)
              == MSYMBOL_VALUE_RAW_ADDRESS ((copyfrom + 1))
-             && MSYMBOL_SECTION (copyfrom) == MSYMBOL_SECTION (copyfrom + 1)
+             && (copyfrom->section_index ()
+                 == (copyfrom + 1)->section_index ())
              && strcmp (copyfrom->linkage_name (),
                         (copyfrom + 1)->linkage_name ()) == 0)
            {
@@ -1342,9 +1347,9 @@ minimal_symbol_reader::install ()
        }
 
       /* Allocate enough space, into which we will gather the bunches
-         of new and existing minimal symbols, sort them, and then
-         compact out the duplicate entries.  Once we have a final
-         table, we will give back the excess space.  */
+        of new and existing minimal symbols, sort them, and then
+        compact out the duplicate entries.  Once we have a final
+        table, we will give back the excess space.  */
 
       alloc_count = m_msym_count + m_objfile->per_bfd->minimal_symbol_count;
       gdb::unique_xmalloc_ptr<minimal_symbol>
@@ -1359,10 +1364,10 @@ minimal_symbol_reader::install ()
                * sizeof (struct minimal_symbol));
 
       /* Walk through the list of minimal symbol bunches, adding each symbol
-         to the new contiguous array of symbols.  Note that we start with the
-         current, possibly partially filled bunch (thus we use the current
-         msym_bunch_index for the first bunch we copy over), and thereafter
-         each bunch is full.  */
+        to the new contiguous array of symbols.  Note that we start with the
+        current, possibly partially filled bunch (thus we use the current
+        msym_bunch_index for the first bunch we copy over), and thereafter
+        each bunch is full.  */
 
       mcount = m_objfile->per_bfd->minimal_symbol_count;
 
@@ -1379,7 +1384,7 @@ minimal_symbol_reader::install ()
       std::sort (msymbols, msymbols + mcount, minimal_symbol_is_less_than);
 
       /* Compact out any duplicates, and free up whatever space we are
-         no longer using.  */
+        no longer using.  */
 
       mcount = compact_minimal_symbols (msymbols, mcount, m_objfile);
       msym_holder.reset (XRESIZEVEC (struct minimal_symbol,
@@ -1387,8 +1392,8 @@ minimal_symbol_reader::install ()
                                     mcount));
 
       /* Attach the minimal symbol table to the specified objfile.
-         The strings themselves are also located in the storage_obstack
-         of this objfile.  */
+        The strings themselves are also located in the storage_obstack
+        of this objfile.  */
 
       if (m_objfile->per_bfd->minimal_symbol_count != 0)
        clear_minimal_symbol_hash_tables (m_objfile);
@@ -1418,9 +1423,8 @@ minimal_symbol_reader::install ()
                   /* This will be freed later, by compute_and_set_names.  */
                   char *demangled_name
                     = symbol_find_demangled_name (msym, msym->linkage_name ());
-                  symbol_set_demangled_name
-                    (msym, demangled_name,
-                     &m_objfile->per_bfd->storage_obstack);
+                  msym->set_demangled_name
+                    (demangled_name, &m_objfile->per_bfd->storage_obstack);
                   msym->name_set = 1;
                 }
               /* This mangled_name_hash computation has to be outside of
@@ -1440,7 +1444,7 @@ minimal_symbol_reader::install ()
             }
           {
             /* To limit how long we hold the lock, we only acquire it here
-               and not while we demangle the names above.  */
+               and not while we demangle the names above.  */
 #if CXX_STD_THREAD
             std::lock_guard<std::mutex> guard (demangled_mutex);
 #endif
@@ -1548,16 +1552,16 @@ minimal_symbol_upper_bound (struct bound_minimal_symbol minsym)
     = (minsym.objfile->per_bfd->msymbols.get ()
        + minsym.objfile->per_bfd->minimal_symbol_count);
   msymbol = minsym.minsym;
-  section = MSYMBOL_SECTION (msymbol);
+  section = msymbol->section_index ();
   for (iter = msymbol + 1; iter != past_the_end; ++iter)
     {
       if ((MSYMBOL_VALUE_RAW_ADDRESS (iter)
           != MSYMBOL_VALUE_RAW_ADDRESS (msymbol))
-         && MSYMBOL_SECTION (iter) == section)
+         && iter->section_index () == section)
        break;
     }
 
-  obj_section = MSYMBOL_OBJ_SECTION (minsym.objfile, minsym.minsym);
+  obj_section = minsym.obj_section ();
   if (iter != past_the_end
       && (MSYMBOL_VALUE_ADDRESS (minsym.objfile, iter)
          < obj_section_endaddr (obj_section)))
This page took 0.027871 seconds and 4 git commands to generate.