Follow-up to Support style in 'frame|thread apply'
[deliverable/binutils-gdb.git] / gdb / psymtab.c
index e034fda3402654207592e54d420fc2fb82223301..584a5e97fd8a8d1db7a69f6a8df543ec494bd5b2 100644 (file)
@@ -26,7 +26,6 @@
 #include "source.h"
 #include "addrmap.h"
 #include "gdbtypes.h"
-#include "bcache.h"
 #include "ui-out.h"
 #include "command.h"
 #include "readline/readline.h"
 #include <algorithm>
 #include <set>
 
-struct psymbol_bcache
-{
-  struct bcache *bcache;
-};
-
 static struct partial_symbol *match_partial_symbol (struct objfile *,
                                                    struct partial_symtab *,
                                                    int,
@@ -67,14 +61,16 @@ static struct compunit_symtab *psymtab_to_symtab (struct objfile *objfile,
 
 \f
 
+static unsigned long psymbol_hash (const void *addr, int length);
+static int psymbol_compare (const void *addr1, const void *addr2, int length);
+
 psymtab_storage::psymtab_storage ()
-  : psymbol_cache (psymbol_bcache_init ())
+  : psymbol_cache (psymbol_hash, psymbol_compare)
 {
 }
 
 psymtab_storage::~psymtab_storage ()
 {
-  psymbol_bcache_free (psymbol_cache);
 }
 
 /* See psymtab.h.  */
@@ -104,7 +100,7 @@ psymtab_storage::allocate_psymtab ()
 
 /* See psymtab.h.  */
 
-objfile_psymtabs
+psymtab_storage::partial_symtab_range
 require_partial_symbols (struct objfile *objfile, int verbose)
 {
   if ((objfile->flags & OBJF_PSYMTABS_READ) == 0)
@@ -129,7 +125,7 @@ require_partial_symbols (struct objfile *objfile, int verbose)
        }
     }
 
-  return objfile_psymtabs (objfile);
+  return objfile->psymtabs ();
 }
 
 /* Helper function for psym_map_symtabs_matching_filename that
@@ -502,7 +498,7 @@ psym_lookup_symbol (struct objfile *objfile,
             partial symtab is empty, we can assume it won't here
             because lookup_partial_symbol succeeded.  */
          const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (stab);
-         struct block *block = BLOCKVECTOR_BLOCK (bv, block_index);
+         const struct block *block = BLOCKVECTOR_BLOCK (bv, block_index);
 
          sym = block_find_symbol (block, name, domain,
                                   block_find_non_opaque_type_preferred,
@@ -1169,8 +1165,8 @@ psymtab_to_fullname (struct partial_symtab *ps)
 
 static int
 map_block (const char *name, domain_enum domain, struct objfile *objfile,
-          struct block *block,
-          int (*callback) (struct block *, struct symbol *, void *),
+          const struct block *block,
+          int (*callback) (const struct block *, struct symbol *, void *),
           void *data, symbol_name_match_type match)
 {
   struct block_iterator iter;
@@ -1200,7 +1196,7 @@ static void
 psym_map_matching_symbols (struct objfile *objfile,
                           const char *name, domain_enum domain,
                           int global,
-                          int (*callback) (struct block *,
+                          int (*callback) (const struct block *,
                                            struct symbol *, void *),
                           void *data,
                           symbol_name_match_type match,
@@ -1216,7 +1212,7 @@ psym_map_matching_symbols (struct objfile *objfile,
                                   ordered_compare))
        {
          struct compunit_symtab *cust = psymtab_to_symtab (objfile, ps);
-         struct block *block;
+         const struct block *block;
 
          if (cust == NULL)
            continue;
@@ -1341,7 +1337,7 @@ psym_expand_symtabs_matching
   for (partial_symtab *ps : require_partial_symbols (objfile, 1))
     ps->searched_flag = PST_NOT_SEARCHED;
 
-  for (partial_symtab *ps : objfile_psymtabs (objfile))
+  for (partial_symtab *ps : objfile->psymtabs ())
     {
       QUIT;
 
@@ -1589,52 +1585,6 @@ psymbol_compare (const void *addr1, const void *addr2, int length)
           && sym1->name == sym2->name);
 }
 
-/* Initialize a partial symbol bcache.  */
-
-struct psymbol_bcache *
-psymbol_bcache_init (void)
-{
-  struct psymbol_bcache *bcache = XCNEW (struct psymbol_bcache);
-
-  bcache->bcache = bcache_xmalloc (psymbol_hash, psymbol_compare);
-  return bcache;
-}
-
-/* Free a partial symbol bcache.  */
-
-void
-psymbol_bcache_free (struct psymbol_bcache *bcache)
-{
-  if (bcache == NULL)
-    return;
-
-  bcache_xfree (bcache->bcache);
-  xfree (bcache);
-}
-
-/* Return the internal bcache of the psymbol_bcache BCACHE.  */
-
-struct bcache *
-psymbol_bcache_get_bcache (struct psymbol_bcache *bcache)
-{
-  return bcache->bcache;
-}
-
-/* Find a copy of the SYM in BCACHE.  If BCACHE has never seen this
-   symbol before, add a copy to BCACHE.  In either case, return a pointer
-   to BCACHE's copy of the symbol.  If optional ADDED is not NULL, return
-   1 in case of new entry or 0 if returning an old entry.  */
-
-static struct partial_symbol *
-psymbol_bcache_full (struct partial_symbol *sym,
-                     struct psymbol_bcache *bcache,
-                     int *added)
-{
-  return ((struct partial_symbol *)
-         bcache_full (sym, sizeof (struct partial_symbol), bcache->bcache,
-                      added));
-}
-
 /* Helper function, initialises partial symbol structure and stashes
    it into objfile's bcache.  Note that our caching mechanism will
    use all fields of struct partial_symbol to determine hash value of the
@@ -1664,9 +1614,9 @@ add_psymbol_to_bcache (const char *name, int namelength, int copy_name,
   symbol_set_names (&psymbol, name, namelength, copy_name, objfile->per_bfd);
 
   /* Stash the partial symbol away in the cache.  */
-  return psymbol_bcache_full (&psymbol,
-                             objfile->partial_symtabs->psymbol_cache,
-                             added);
+  return ((struct partial_symbol *)
+         objfile->partial_symtabs->psymbol_cache.insert
+         (&psymbol, sizeof (struct partial_symbol), added));
 }
 
 /* Helper function, adds partial symbol to the given partial symbol list.  */
@@ -1741,8 +1691,8 @@ allocate_psymtab (const char *filename, struct objfile *objfile)
     = objfile->partial_symtabs->allocate_psymtab ();
 
   psymtab->filename
-    = (const char *) bcache (filename, strlen (filename) + 1,
-                            objfile->per_bfd->filename_cache);
+    = ((const char *) objfile->per_bfd->filename_cache.insert
+       (filename, strlen (filename) + 1));
   psymtab->compunit_symtab = NULL;
 
   if (symtab_create_debug)
@@ -1942,7 +1892,7 @@ maintenance_print_psymbols (const char *args, int from_tty)
     }
 
   found = 0;
-  for (objfile *objfile : all_objfiles (current_program_space))
+  for (objfile *objfile : current_program_space->objfiles ())
     {
       int printed_objfile_header = 0;
       int print_for_objfile = 1;
@@ -2035,7 +1985,7 @@ maintenance_info_psymtabs (const char *regexp, int from_tty)
     re_comp (regexp);
 
   ALL_PSPACES (pspace)
-    for (objfile *objfile : all_objfiles (pspace))
+    for (objfile *objfile : pspace->objfiles ())
       {
        struct gdbarch *gdbarch = get_objfile_arch (objfile);
 
@@ -2145,10 +2095,10 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
   struct symbol *sym;
   struct compunit_symtab *cust = NULL;
   const struct blockvector *bv;
-  struct block *b;
+  const struct block *b;
   int length;
 
-  for (objfile *objfile : all_objfiles (current_program_space))
+  for (objfile *objfile : current_program_space->objfiles ())
     for (partial_symtab *ps : require_partial_symbols (objfile, 1))
       {
        struct gdbarch *gdbarch = get_objfile_arch (objfile);
This page took 0.027758 seconds and 4 git commands to generate.