From: sami wagiaalla <swagiaal@redhat.com>
To: gdb-patches@sourceware.org
Subject: Re: [patch 2/2] Use custom hash function with bcache [Re: [RFC] Use custom hash function with bcache]
Date: Wed, 25 Aug 2010 18:32:00 -0000 [thread overview]
Message-ID: <4C7561B4.30101@redhat.com> (raw)
In-Reply-To: <m3aaoi2vix.fsf@fleche.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 24 bytes --]
Revised patch attached.
[-- Attachment #2: custom_hash_2.patch --]
[-- Type: text/x-patch, Size: 7967 bytes --]
Create and use a specialized bcache type for psymbols
2010-08-25 Sami Wagiaalla <swagiaal@redhat.com>
* symfile.c (reread_symbols): Use psymbol_bcache_free, and
psymbol_bcache_init.
* psymtab.h (psymbol_bcache_init): New function prototype.
(psymbol_bcache_free): New function prototype.
* psymtab.c (psymbol_bcache_init): New function.
(psymbol_bcache_free): New function.
(psymbol_bcache_full): New function.
(add_psymbol_to_bcache): use psymbol_bcache_full.
* objfiles.h (psymbol_cache): Change type of psymbol_cache to
psymbol_bcache.
* symmisc.c (print_symbol_bcache_statistics): Updated.
(print_objfile_statistics): Updated.
* objfiles.c (allocate_objfile): Use psymbol_bcache_init to initialize
psymbol_cache.
(free_objfile): Use psymbol_bcache_free.
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index c479d22..6fc8a1f 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -199,7 +199,7 @@ allocate_objfile (bfd *abfd, int flags)
struct objfile *objfile;
objfile = (struct objfile *) xzalloc (sizeof (struct objfile));
- objfile->psymbol_cache = bcache_xmalloc (psymbol_hash, psymbol_compare);
+ objfile->psymbol_cache = psymbol_bcache_init ();
objfile->macro_cache = bcache_xmalloc (NULL, NULL);
objfile->filename_cache = bcache_xmalloc (NULL, NULL);
/* We could use obstack_specify_allocation here instead, but
@@ -658,7 +658,7 @@ free_objfile (struct objfile *objfile)
if (objfile->static_psymbols.list)
xfree (objfile->static_psymbols.list);
/* Free the obstacks for non-reusable objfiles */
- bcache_xfree (objfile->psymbol_cache);
+ psymbol_bcache_free (objfile->psymbol_cache);
bcache_xfree (objfile->macro_cache);
bcache_xfree (objfile->filename_cache);
if (objfile->demangled_names_hash)
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 62fc1cb..ec4870b 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -249,7 +249,7 @@ struct objfile
/* A byte cache where we can stash arbitrary "chunks" of bytes that
will not change. */
- struct bcache *psymbol_cache; /* Byte cache for partial syms */
+ struct psymbol_bcache *psymbol_cache; /* Byte cache for partial syms */
struct bcache *macro_cache; /* Byte cache for macros */
struct bcache *filename_cache; /* Byte cache for file names. */
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index aa7e3a1..a80b975 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1275,7 +1275,7 @@ start_psymtab_common (struct objfile *objfile,
and name. These are the values which are set by
add_psymbol_to_bcache. */
-unsigned long
+static unsigned long
psymbol_hash (const void *addr, int length)
{
unsigned long h = 0;
@@ -1297,7 +1297,7 @@ psymbol_hash (const void *addr, int length)
For the comparison this function uses a symbols value,
language, domain, class and name. */
-int
+static int
psymbol_compare (const void *addr1, const void *addr2, int length)
{
struct partial_symbol *sym1 = (struct partial_symbol *) addr1;
@@ -1311,6 +1311,43 @@ psymbol_compare (const void *addr1, const void *addr2, int length)
&& sym1->ginfo.name == sym2->ginfo.name);
}
+/* Initialize a partial symbol bcache. */
+
+struct psymbol_bcache *
+psymbol_bcache_init (void)
+{
+ struct psymbol_bcache *bcache = XCALLOC (1, 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);
+}
+
+/* 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 const struct partial_symbol *
+psymbol_bcache_full (struct partial_symbol *sym,
+ struct psymbol_bcache *bcache,
+ int *added)
+{
+ return 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
@@ -1345,8 +1382,9 @@ add_psymbol_to_bcache (char *name, int namelength, int copy_name,
SYMBOL_SET_NAMES (&psymbol, name, namelength, copy_name, objfile);
/* Stash the partial symbol away in the cache */
- return bcache_full (&psymbol, sizeof (struct partial_symbol),
- objfile->psymbol_cache, added);
+ return psymbol_bcache_full (&psymbol,
+ objfile->psymbol_cache,
+ added);
}
/* Helper function, adds partial symbol to the given partial symbol
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 0786944..9182f33 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -20,8 +20,15 @@
#ifndef PSYMTAB_H
#define PSYMTAB_H
-extern unsigned long psymbol_hash (const void *addr, int length);
-extern int psymbol_compare (const void *addr1, const void *addr2, int length);
+/* A bcache for partial symbols. */
+
+struct psymbol_bcache
+{
+ struct bcache *bcache;
+};
+
+extern struct psymbol_bcache *psymbol_bcache_init (void);
+extern void psymbol_bcache_free (struct psymbol_bcache *);
void map_partial_symbol_names (void (*) (const char *, void *), void *);
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 048b8a8..087cd3a 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2431,9 +2431,8 @@ reread_symbols (void)
sizeof (objfile->static_psymbols));
/* Free the obstacks for non-reusable objfiles */
- bcache_xfree (objfile->psymbol_cache);
- objfile->psymbol_cache = bcache_xmalloc (psymbol_hash,
- psymbol_compare);
+ psymbol_bcache_free (objfile->psymbol_cache);
+ objfile->psymbol_cache = psymbol_bcache_init ();
bcache_xfree (objfile->macro_cache);
objfile->macro_cache = bcache_xmalloc (NULL, NULL);
bcache_xfree (objfile->filename_cache);
@@ -2459,8 +2458,7 @@ reread_symbols (void)
memset (&objfile->msymbol_demangled_hash, 0,
sizeof (objfile->msymbol_demangled_hash));
- objfile->psymbol_cache = bcache_xmalloc (psymbol_hash,
- psymbol_compare);
+ objfile->psymbol_cache = psymbol_bcache_init ();
objfile->macro_cache = bcache_xmalloc (NULL, NULL);
objfile->filename_cache = bcache_xmalloc (NULL, NULL);
/* obstack_init also initializes the obstack so it is
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 62e6b97..399843b 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -130,7 +130,8 @@ print_symbol_bcache_statistics (void)
ALL_PSPACE_OBJFILES (pspace, objfile)
{
printf_filtered (_("Byte cache statistics for '%s':\n"), objfile->name);
- print_bcache_statistics (objfile->psymbol_cache, "partial symbol cache");
+ print_bcache_statistics (objfile->psymbol_cache->bcache,
+ "partial symbol cache");
print_bcache_statistics (objfile->macro_cache, "preprocessor macro cache");
print_bcache_statistics (objfile->filename_cache, "file name cache");
}
@@ -188,7 +189,7 @@ print_objfile_statistics (void)
printf_filtered (_(" Total memory used for objfile obstack: %d\n"),
obstack_memory_used (&objfile->objfile_obstack));
printf_filtered (_(" Total memory used for psymbol cache: %d\n"),
- bcache_memory_used (objfile->psymbol_cache));
+ bcache_memory_used (objfile->psymbol_cache->bcache));
printf_filtered (_(" Total memory used for macro cache: %d\n"),
bcache_memory_used (objfile->macro_cache));
printf_filtered (_(" Total memory used for file name cache: %d\n"),
next prev parent reply other threads:[~2010-08-25 18:32 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-16 14:11 [RFC] Use custom hash function with bcache sami wagiaalla
2010-08-16 18:29 ` Doug Evans
2010-08-16 18:56 ` Doug Evans
2010-08-16 19:56 ` sami wagiaalla
2010-08-19 16:32 ` [patch 1/2] Use custom hash function with bcache [Re: [RFC] Use custom hash function with bcache] sami wagiaalla
2010-08-19 20:26 ` Tom Tromey
2010-08-25 18:30 ` sami wagiaalla
2010-08-30 20:53 ` Tom Tromey
2010-09-01 8:25 ` Regression for gdb.stabs/gdb11479.exp [Re: [patch 1/2] " Jan Kratochvil
2010-09-01 16:20 ` Joel Brobecker
2010-09-01 16:47 ` Joel Brobecker
2010-09-01 17:03 ` sami wagiaalla
2010-09-01 17:17 ` Joel Brobecker
2010-09-01 18:09 ` sami wagiaalla
2010-09-01 18:19 ` Jan Kratochvil
2010-09-01 18:24 ` Doug Evans
2010-09-01 18:38 ` Tom Tromey
2010-09-01 19:01 ` sami wagiaalla
2010-09-01 19:15 ` Doug Evans
2010-09-01 19:17 ` Doug Evans
2010-09-01 19:59 ` sami wagiaalla
2010-09-01 23:11 ` Doug Evans
2010-09-01 23:16 ` Doug Evans
2010-09-01 23:19 ` Doug Evans
2010-09-01 23:19 ` Doug Evans
2010-09-02 15:43 ` sami wagiaalla
2010-09-02 20:25 ` Doug Evans
2010-09-03 15:59 ` Doug Evans
2010-09-04 14:29 ` sami wagiaalla
2010-09-06 9:46 ` Daniel Jacobowitz
2010-08-16 19:14 ` [RFC] Use custom hash function with bcache Daniel Jacobowitz
2010-08-16 19:50 ` sami wagiaalla
2010-08-16 20:04 ` Daniel Jacobowitz
2010-08-16 20:11 ` sami wagiaalla
2010-08-16 20:49 ` Daniel Jacobowitz
2010-08-17 17:02 ` sami wagiaalla
2010-08-17 17:40 ` Daniel Jacobowitz
2010-08-17 23:26 ` Tom Tromey
2010-08-18 15:13 ` sami wagiaalla
2010-08-18 15:24 ` Tom Tromey
2010-08-19 16:33 ` sami wagiaalla
2010-08-19 16:37 ` [patch 2/2] Use custom hash function with bcache [Re: [RFC] Use custom hash function with bcache] sami wagiaalla
2010-08-19 20:32 ` [RFC] Use custom hash function with bcache Tom Tromey
2010-08-25 18:32 ` sami wagiaalla [this message]
2010-08-30 20:58 ` [patch 2/2] Use custom hash function with bcache [Re: [RFC] Use custom hash function with bcache] Tom Tromey
2010-08-30 21:13 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C7561B4.30101@redhat.com \
--to=swagiaal@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).