-/* Allocate and partially fill a partial symtab. It will be
- completely filled at the end of the symbol list.
-
- FILENAME is the name of the symbol-file we are reading from. */
-
-struct partial_symtab *
-start_psymtab_common (struct objfile *objfile,
- struct section_offsets *section_offsets,
- const char *filename,
- CORE_ADDR textlow, struct partial_symbol **global_syms,
- struct partial_symbol **static_syms)
-{
- struct partial_symtab *psymtab;
-
- psymtab = allocate_psymtab (filename, objfile);
- psymtab->section_offsets = section_offsets;
- psymtab->textlow = textlow;
- psymtab->texthigh = psymtab->textlow; /* default */
- psymtab->globals_offset = global_syms - objfile->global_psymbols.list;
- psymtab->statics_offset = static_syms - objfile->static_psymbols.list;
- return (psymtab);
-}
-\f
-/* 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
- structure. In other words, having two symbols with the same name but
- different domain (or address) is possible and correct. */
-
-static const struct partial_symbol *
-add_psymbol_to_bcache (char *name, int namelength, int copy_name,
- domain_enum domain,
- enum address_class class,
- long val, /* Value as a long */
- CORE_ADDR coreaddr, /* Value as a CORE_ADDR */
- enum language language, struct objfile *objfile,
- int *added)
-{
- /* psymbol is static so that there will be no uninitialized gaps in the
- structure which might contain random data, causing cache misses in
- bcache. */
- static struct partial_symbol psymbol;
-
- /* However, we must ensure that the entire 'value' field has been
- zeroed before assigning to it, because an assignment may not
- write the entire field. */
- memset (&psymbol.ginfo.value, 0, sizeof (psymbol.ginfo.value));
- /* val and coreaddr are mutually exclusive, one of them *will* be zero */
- if (val != 0)
- {
- SYMBOL_VALUE (&psymbol) = val;
- }
- else
- {
- SYMBOL_VALUE_ADDRESS (&psymbol) = coreaddr;
- }
- SYMBOL_SECTION (&psymbol) = 0;
- SYMBOL_LANGUAGE (&psymbol) = language;
- PSYMBOL_DOMAIN (&psymbol) = domain;
- PSYMBOL_CLASS (&psymbol) = class;
-
- 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);
-}
-
-/* Helper function, adds partial symbol to the given partial symbol
- list. */
-
-static void
-append_psymbol_to_list (struct psymbol_allocation_list *list,
- const struct partial_symbol *psym,
- struct objfile *objfile)
-{
- if (list->next >= list->list + list->size)
- extend_psymbol_list (list, objfile);
- *list->next++ = (struct partial_symbol *) psym;
- OBJSTAT (objfile, n_psyms++);
-}
-
-/* Add a symbol with a long value to a psymtab.
- Since one arg is a struct, we pass in a ptr and deref it (sigh).
- Return the partial symbol that has been added. */
-
-/* NOTE: carlton/2003-09-11: The reason why we return the partial
- symbol is so that callers can get access to the symbol's demangled
- name, which they don't have any cheap way to determine otherwise.
- (Currenly, dwarf2read.c is the only file who uses that information,
- though it's possible that other readers might in the future.)
- Elena wasn't thrilled about that, and I don't blame her, but we
- couldn't come up with a better way to get that information. If
- it's needed in other situations, we could consider breaking up
- SYMBOL_SET_NAMES to provide access to the demangled name lookup
- cache. */
-
-const struct partial_symbol *
-add_psymbol_to_list (char *name, int namelength, int copy_name,
- domain_enum domain,
- enum address_class class,
- struct psymbol_allocation_list *list,
- long val, /* Value as a long */
- CORE_ADDR coreaddr, /* Value as a CORE_ADDR */
- enum language language, struct objfile *objfile)
-{
- const struct partial_symbol *psym;
-
- int added;
-
- /* Stash the partial symbol away in the cache */
- psym = add_psymbol_to_bcache (name, namelength, copy_name, domain, class,
- val, coreaddr, language, objfile, &added);
-
- /* Do not duplicate global partial symbols. */
- if (list == &objfile->global_psymbols
- && !added)
- return psym;
-
- /* Save pointer to partial symbol in psymtab, growing symtab if needed. */
- append_psymbol_to_list (list, psym, objfile);
- return psym;
-}
-
-/* Initialize storage for partial symbols. */
-
-void
-init_psymbol_list (struct objfile *objfile, int total_symbols)
-{
- /* Free any previously allocated psymbol lists. */
-
- if (objfile->global_psymbols.list)
- {
- xfree (objfile->global_psymbols.list);
- }
- if (objfile->static_psymbols.list)
- {
- xfree (objfile->static_psymbols.list);
- }
-
- /* Current best guess is that approximately a twentieth
- of the total symbols (in a debugging file) are global or static
- oriented symbols */
-
- objfile->global_psymbols.size = total_symbols / 10;
- objfile->static_psymbols.size = total_symbols / 10;
-
- if (objfile->global_psymbols.size > 0)
- {
- objfile->global_psymbols.next =
- objfile->global_psymbols.list = (struct partial_symbol **)
- xmalloc ((objfile->global_psymbols.size
- * sizeof (struct partial_symbol *)));
- }
- if (objfile->static_psymbols.size > 0)
- {
- objfile->static_psymbols.next =
- objfile->static_psymbols.list = (struct partial_symbol **)
- xmalloc ((objfile->static_psymbols.size
- * sizeof (struct partial_symbol *)));
- }
-}
-