#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,
\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. */
/* 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)
}
}
- return objfile_psymtabs (objfile);
+ return objfile->psymtabs ();
}
/* Helper function for psym_map_symtabs_matching_filename that
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,
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;
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,
ordered_compare))
{
struct compunit_symtab *cust = psymtab_to_symtab (objfile, ps);
- struct block *block;
+ const struct block *block;
if (cust == NULL)
continue;
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;
&& 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
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. */
= 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)
}
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;
re_comp (regexp);
ALL_PSPACES (pspace)
- for (objfile *objfile : all_objfiles (pspace))
+ for (objfile *objfile : pspace->objfiles ())
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
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);