* bcache.c, bcache.h: New files to implement a byte cache.

* Makefile.in (SFILES): Add bcache.c.
	(symtab_h): Add bcache.h.
	(HFILES_NO_SRCDIR): add bcache.h
	(COMMON_OBJS): Add bcache.o
	(bcache.o): New target.
	* dbxread.c (start_psymtab): Make global_syms & static_syms
 	type "partial_symbol **".
	* hpread.c (hpread_start_symtab):  Ditto.
	* os9kread.c (os9k_start_psymtab):  Ditto.
	* stabsread.h (start_psymtab):  Ditto.
	* {symfile.c, symfile.h} (start_psymtab_common):  Ditto.
	* maint.c (maintenance_print_statistics): Call
 	print_symbol_bcache_statistics.
	* objfiles.c (allocate_objfile): Initialize psymbol bcache malloc
	and free pointers.
	* solib.c (allocate_rt_common_objfile): Ditto.
	* symfile.c (reread_symbols):  Ditto.
	(free_objfile): Free psymbol bcache when objfile is freed.
	(objfile_relocate): Use new indirect psymbol pointers.
	* objfiles.h (struct objfile): Add psymbol cache.
	* symfile.c (compare_psymbols): Now passed pointers to pointers to
	psymbols.
	(reread_symbols): Free psymbol bcache when freeing other objfile
	resources.
	(add_psymbol_to_list, add_psymbol_addr_to_list): Initialize new
	psymbol using the psymbol bcache.
	(init_psymbol_list): Psymbol lists now contain pointers rather than
	the actual psymbols.
	* symfile.h (psymbol_allocation_list): Psymbol lists now dynamically
	grown arrays of pointers.
	(ADD_PSYMBOL_VT_TO_LIST): Initialize new symbol using the psymbol
	bcache.
	* symmisc.c (print_partial_symbols): Now takes pointer to pointer
	to partial symbol.
	(print_symbol_bcache_statistics): New function to print per objfile
 	bcache statistics.
	(print_partial_symbol, print_partial_symbols,
 	maintenance_check_symtabs, extend_psymbol_list):
 	Account for change to pointer to pointer to partial symbol.
	* symtab.c (find_pc_psymbol, lookup_partial_symbol, decode_line_2,
	make_symbol_completion_list):
 	Account for change to pointer to pointer to partial symbol.
	* symtab.h (bcache.h): Include.
	* xcoffread.c (xcoff_start_psymtab): Make global_syms & static_syms
 	type "partial_symbol **".
This commit is contained in:
Fred Fish 1996-02-16 22:14:47 +00:00
parent ef2074c25a
commit 2ad5709f00
16 changed files with 456 additions and 113 deletions

View file

@ -148,9 +148,9 @@ LOCAL FUNCTION
DESCRIPTION
Given pointer to two partial symbol table entries, compare
them by name and return -N, 0, or +N (ala strcmp). Typically
used by sorting routines like qsort().
Given pointers to pointers to two partial symbol table entries,
compare them by name and return -N, 0, or +N (ala strcmp).
Typically used by sorting routines like qsort().
NOTES
@ -167,8 +167,8 @@ compare_psymbols (s1p, s2p)
const PTR s1p;
const PTR s2p;
{
register char *st1 = SYMBOL_NAME ((struct partial_symbol *) s1p);
register char *st2 = SYMBOL_NAME ((struct partial_symbol *) s2p);
register char *st1 = SYMBOL_NAME (*(struct partial_symbol **) s1p);
register char *st2 = SYMBOL_NAME (*(struct partial_symbol **) s2p);
if ((st1[0] - st2[0]) || !st1[0])
{
@ -191,7 +191,7 @@ sort_pst_symbols (pst)
/* Sort the global list; don't sort the static list */
qsort (pst -> objfile -> global_psymbols.list + pst -> globals_offset,
pst -> n_global_syms, sizeof (struct partial_symbol),
pst -> n_global_syms, sizeof (struct partial_symbol *),
compare_psymbols);
}
@ -1192,6 +1192,7 @@ reread_symbols ()
objfile->static_psymbols.size = 0;
/* Free the obstacks for non-reusable objfiles */
obstack_free (&objfile -> psymbol_cache.cache, 0);
obstack_free (&objfile -> psymbol_obstack, 0);
obstack_free (&objfile -> symbol_obstack, 0);
obstack_free (&objfile -> type_obstack, 0);
@ -1211,6 +1212,8 @@ reread_symbols ()
objfile -> md = NULL;
/* obstack_specify_allocation also initializes the obstack so
it is empty. */
obstack_specify_allocation (&objfile -> psymbol_cache.cache, 0, 0,
xmalloc, free);
obstack_specify_allocation (&objfile -> psymbol_obstack, 0, 0,
xmalloc, free);
obstack_specify_allocation (&objfile -> symbol_obstack, 0, 0,
@ -1616,8 +1619,8 @@ start_psymtab_common (objfile, section_offsets,
struct section_offsets *section_offsets;
char *filename;
CORE_ADDR textlow;
struct partial_symbol *global_syms;
struct partial_symbol *static_syms;
struct partial_symbol **global_syms;
struct partial_symbol **static_syms;
{
struct partial_symtab *psymtab;
@ -1651,24 +1654,29 @@ add_psymbol_to_list (name, namelength, namespace, class, list, val, language,
struct objfile *objfile;
{
register struct partial_symbol *psym;
register char *demangled_name;
char *buf = alloca (namelength + 1);
struct partial_symbol psymbol;
/* Create local copy of the partial symbol */
memcpy (buf, name, namelength);
buf[namelength] = '\0';
SYMBOL_NAME (&psymbol) = bcache (buf, namelength + 1, &objfile->psymbol_cache);
SYMBOL_VALUE (&psymbol) = val;
SYMBOL_SECTION (&psymbol) = 0;
SYMBOL_LANGUAGE (&psymbol) = language;
PSYMBOL_NAMESPACE (&psymbol) = namespace;
PSYMBOL_CLASS (&psymbol) = class;
SYMBOL_INIT_LANGUAGE_SPECIFIC (&psymbol, language);
/* Stash the partial symbol away in the cache */
psym = bcache (&psymbol, sizeof (struct partial_symbol), &objfile->psymbol_cache);
/* Save pointer to partial symbol in psymtab, growing symtab if needed. */
if (list->next >= list->list + list->size)
{
extend_psymbol_list (list,objfile);
extend_psymbol_list (list, objfile);
}
psym = list->next++;
SYMBOL_NAME (psym) =
(char *) obstack_alloc (&objfile->psymbol_obstack, namelength + 1);
memcpy (SYMBOL_NAME (psym), name, namelength);
SYMBOL_NAME (psym)[namelength] = '\0';
SYMBOL_VALUE (psym) = val;
SYMBOL_SECTION (psym) = 0;
SYMBOL_LANGUAGE (psym) = language;
PSYMBOL_NAMESPACE (psym) = namespace;
PSYMBOL_CLASS (psym) = class;
SYMBOL_INIT_LANGUAGE_SPECIFIC (psym, language);
*list->next++ = psym;
OBJSTAT (objfile, n_psyms++);
}
@ -1687,24 +1695,29 @@ add_psymbol_addr_to_list (name, namelength, namespace, class, list, val,
struct objfile *objfile;
{
register struct partial_symbol *psym;
register char *demangled_name;
char *buf = alloca (namelength + 1);
struct partial_symbol psymbol;
/* Create local copy of the partial symbol */
memcpy (buf, name, namelength);
buf[namelength] = '\0';
SYMBOL_NAME (&psymbol) = bcache (buf, namelength + 1, &objfile->psymbol_cache);
SYMBOL_VALUE_ADDRESS (&psymbol) = val;
SYMBOL_SECTION (&psymbol) = 0;
SYMBOL_LANGUAGE (&psymbol) = language;
PSYMBOL_NAMESPACE (&psymbol) = namespace;
PSYMBOL_CLASS (&psymbol) = class;
SYMBOL_INIT_LANGUAGE_SPECIFIC (&psymbol, language);
/* Stash the partial symbol away in the cache */
psym = bcache (&psymbol, sizeof (struct partial_symbol), &objfile->psymbol_cache);
/* Save pointer to partial symbol in psymtab, growing symtab if needed. */
if (list->next >= list->list + list->size)
{
extend_psymbol_list (list,objfile);
extend_psymbol_list (list, objfile);
}
psym = list->next++;
SYMBOL_NAME (psym) =
(char *) obstack_alloc (&objfile->psymbol_obstack, namelength + 1);
memcpy (SYMBOL_NAME (psym), name, namelength);
SYMBOL_NAME (psym)[namelength] = '\0';
SYMBOL_VALUE_ADDRESS (psym) = val;
SYMBOL_SECTION (psym) = 0;
SYMBOL_LANGUAGE (psym) = language;
PSYMBOL_NAMESPACE (psym) = namespace;
PSYMBOL_CLASS (psym) = class;
SYMBOL_INIT_LANGUAGE_SPECIFIC (psym, language);
*list->next++ = psym;
OBJSTAT (objfile, n_psyms++);
}
@ -1735,13 +1748,13 @@ init_psymbol_list (objfile, total_symbols)
objfile -> global_psymbols.size = total_symbols / 10;
objfile -> static_psymbols.size = total_symbols / 10;
objfile -> global_psymbols.next =
objfile -> global_psymbols.list = (struct partial_symbol *)
objfile -> global_psymbols.list = (struct partial_symbol **)
xmmalloc (objfile -> md, objfile -> global_psymbols.size
* sizeof (struct partial_symbol));
* sizeof (struct partial_symbol *));
objfile -> static_psymbols.next =
objfile -> static_psymbols.list = (struct partial_symbol *)
objfile -> static_psymbols.list = (struct partial_symbol **)
xmmalloc (objfile -> md, objfile -> static_psymbols.size
* sizeof (struct partial_symbol));
* sizeof (struct partial_symbol *));
}
void