aboutsummaryrefslogtreecommitdiff
path: root/gdb/psymtab.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-03-07 04:20:19 -0700
committerTom Tromey <tom@tromey.com>2019-03-07 10:48:02 -0700
commit25629dfdb438c82f2bb711174042bb326a526aaf (patch)
treef0bd8f98faa31b5124de5963abe119507a095622 /gdb/psymtab.c
parentfe7266674110f34eacf2e9d2b308f76d33ce50ed (diff)
downloadgdb-25629dfdb438c82f2bb711174042bb326a526aaf.zip
gdb-25629dfdb438c82f2bb711174042bb326a526aaf.tar.gz
gdb-25629dfdb438c82f2bb711174042bb326a526aaf.tar.bz2
C++-ify bcache
This somewhat C++-ifies bcache. It replaces bcache_xmalloc and bcache_xfree with constructors; changes some functions into methods; and changes various structures to include a bcache directly (as opposed to a pointer to a bcache). Tested by the buildbot. gdb/ChangeLog 2019-03-07 Tom Tromey <tom@tromey.com> * symmisc.c (print_symbol_bcache_statistics): Update. (print_objfile_statistics): Update. * symfile.c (allocate_symtab): Update. * stabsread.c: Don't include bcache.h. * psymtab.h (struct psymbol_bcache): Don't declare. (class psymtab_storage) <psymbol_cache>: Now a bcache. (psymbol_bcache_init, psymbol_bcache_free) (psymbol_bcache_get_bcache): Don't declare. * psymtab.c (struct psymbol_bcache): Remove. (psymtab_storage::psymtab_storage): Update. (psymtab_storage::~psymtab_storage): Update. (psymbol_bcache_init, psymbol_bcache_free) (psymbol_bcache_get_bcache, psymbol_bcache_full): Remove. (add_psymbol_to_bcache): Update. (allocate_psymtab): Update. * objfiles.h (struct objfile_per_bfd_storage) <filename_cache, macro_cache>: No longer pointers. * objfiles.c (get_objfile_bfd_data): Don't call bcache_xmalloc. (free_objfile_per_bfd_storage): Don't call bcache_xfree. * macrotab.c (macro_bcache): Update. * macroexp.c: Don't include bcache.h. * gdbtypes.c (check_types_worklist): Update. (types_deeply_equal): Remove TRY/CATCH. Update. * elfread.c (elf_symtab_read): Update. * dwarf2read.c: Don't include bcache.h. * buildsym.c (buildsym_compunit::get_macro_table): Update. * bcache.h (bcache, bcache_full, bcache_xffree, bcache_xmalloc) (print_bcache_statistics, bcache_memory_used): Don't declare. (struct bcache): Move from bcache.c. Add constructor, destructor, methods. Rename all data members. * bcache.c (struct bcache): Move to bcache.h. (bcache::expand_hash_table): Rename from expand_hash_table. (bcache): Remove. (bcache::insert): Rename from bcache_full. (bcache::compare): Rename from bcache_compare. (bcache_xmalloc): Remove. (bcache::~bcache): Rename from bcache_xfree. (bcache::print_statistics): Rename from print_bcache_statistics. (bcache::memory_used): Rename from bcache_memory_used.
Diffstat (limited to 'gdb/psymtab.c')
-rw-r--r--gdb/psymtab.c68
1 files changed, 9 insertions, 59 deletions
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 17db297..96b4fa0 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -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"
@@ -38,11 +37,6 @@
#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,
+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. */
@@ -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)