* symfile.h (add_psymbol_to_list): Update prototype.
* symfile.c (add_psymbol_to_bcache): Add copy_name argument.
(add_psymbol_to_list): Likewise.
* stabsread.c (define_symbol): Update.
* mdebugread.c (parse_partial_symbols): Update.
(handle_psymbol_enumerators): Update.
(new_symbol): Update.
* dbxread.c (read_dbx_symtab): Update.
* coffread.c (process_coff_symbol): Update.
* symtab.h (prim_record_minimal_symbol_full): Declare.
(SYMBOL_SET_NAMES): Add copy_name argument.
* symtab.c (struct demangled_name_entry): New struct.
(hash_demangled_name_entry): New function.
(eq_demangled_name_entry): Likewise.
(create_demangled_names_hash): Use new functions.
(symbol_set_names): Use struct demangled_name_entry. Add
copy_name argument.
* minsyms.c (prim_record_minimal_symbol_full): New function.
(prim_record_minimal_symbol_and_info): Use it.
* elfread.c (record_minimal_symbol): Add name_len and copy_name
arguments. Call prim_record_minimal_symbol_full.
(elf_symtab_read): Add copy_names argument.
(elf_symfile_read): Update calls to elf_symtab_read.
* dwarf2read.c (add_partial_symbol): Don't copy symbol names.
(load_partial_dies): Likewise.
(new_symbol): Likewise.
* cp-namespace.c (check_one_possible_namespace_symbol): Don't save
name on the obstack. Update call to SYMBOL_SET_NAMES.
+2009-11-16 Tom Tromey <tromey@redhat.com>
+
+ * xcoffread.c (scan_xcoff_symtab): Update.
+ * symfile.h (add_psymbol_to_list): Update prototype.
+ * symfile.c (add_psymbol_to_bcache): Add copy_name argument.
+ (add_psymbol_to_list): Likewise.
+ * stabsread.c (define_symbol): Update.
+ * mdebugread.c (parse_partial_symbols): Update.
+ (handle_psymbol_enumerators): Update.
+ (new_symbol): Update.
+ * dbxread.c (read_dbx_symtab): Update.
+ * coffread.c (process_coff_symbol): Update.
+ * symtab.h (prim_record_minimal_symbol_full): Declare.
+ (SYMBOL_SET_NAMES): Add copy_name argument.
+ * symtab.c (struct demangled_name_entry): New struct.
+ (hash_demangled_name_entry): New function.
+ (eq_demangled_name_entry): Likewise.
+ (create_demangled_names_hash): Use new functions.
+ (symbol_set_names): Use struct demangled_name_entry. Add
+ copy_name argument.
+ * minsyms.c (prim_record_minimal_symbol_full): New function.
+ (prim_record_minimal_symbol_and_info): Use it.
+ * elfread.c (record_minimal_symbol): Add name_len and copy_name
+ arguments. Call prim_record_minimal_symbol_full.
+ (elf_symtab_read): Add copy_names argument.
+ (elf_symfile_read): Update calls to elf_symtab_read.
+ * dwarf2read.c (add_partial_symbol): Don't copy symbol names.
+ (load_partial_dies): Likewise.
+ (new_symbol): Likewise.
+ * cp-namespace.c (check_one_possible_namespace_symbol): Don't save
+ name on the obstack. Update call to SYMBOL_SET_NAMES.
+
2009-11-15 Pedro Alves <pedro@codesourcery.com>
* infrun.c (handle_inferior_event): When handling a fork or vfork
name = cs->c_name;
name = EXTERNAL_NAME (name, objfile->obfd);
SYMBOL_LANGUAGE (sym) = current_subfile->language;
- SYMBOL_SET_NAMES (sym, name, strlen (name), objfile);
+ SYMBOL_SET_NAMES (sym, name, strlen (name), 1, objfile);
/* default assumptions */
SYMBOL_VALUE (sym) = cs->c_value;
if (sym == NULL)
{
struct type *type;
- name_copy = obsavestring (name, len, &objfile->objfile_obstack);
type = init_type (TYPE_CODE_NAMESPACE, 0, 0, name_copy, objfile);
sym = obstack_alloc (&objfile->objfile_obstack, sizeof (struct symbol));
memset (sym, 0, sizeof (struct symbol));
SYMBOL_LANGUAGE (sym) = language_cplus;
- SYMBOL_SET_NAMES (sym, name_copy, len, objfile);
+ /* Note that init_type copied the name to the objfile's
+ obstack. */
+ SYMBOL_SET_NAMES (sym, TYPE_NAME (type), len, 0, objfile);
SYMBOL_CLASS (sym) = LOC_TYPEDEF;
SYMBOL_TYPE (sym) = type;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
namestring = gdbarch_static_transform_name (gdbarch,
namestring);
- add_psymbol_to_list (sym_name, sym_len,
+ add_psymbol_to_list (sym_name, sym_len, 1,
VAR_DOMAIN, LOC_STATIC,
&objfile->static_psymbols,
0, nlist.n_value,
data_sect_index);
/* The addresses in these entries are reported to be
wrong. See the code that reads 'G's for symtabs. */
- add_psymbol_to_list (sym_name, sym_len,
+ add_psymbol_to_list (sym_name, sym_len, 1,
VAR_DOMAIN, LOC_STATIC,
&objfile->global_psymbols,
0, nlist.n_value,
|| (p == namestring + 1
&& namestring[0] != ' '))
{
- add_psymbol_to_list (sym_name, sym_len,
+ add_psymbol_to_list (sym_name, sym_len, 1,
STRUCT_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
nlist.n_value, 0,
if (p[2] == 't')
{
/* Also a typedef with the same name. */
- add_psymbol_to_list (sym_name, sym_len,
+ add_psymbol_to_list (sym_name, sym_len, 1,
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
nlist.n_value, 0,
case 't':
if (p != namestring) /* a name is there, not just :T... */
{
- add_psymbol_to_list (sym_name, sym_len,
+ add_psymbol_to_list (sym_name, sym_len, 1,
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
nlist.n_value, 0,
;
/* Note that the value doesn't matter for
enum constants in psymtabs, just in symtabs. */
- add_psymbol_to_list (p, q - p,
+ add_psymbol_to_list (p, q - p, 1,
VAR_DOMAIN, LOC_CONST,
&objfile->static_psymbols, 0,
0, psymtab_language, objfile);
case 'c':
/* Constant, e.g. from "const" in Pascal. */
- add_psymbol_to_list (sym_name, sym_len,
+ add_psymbol_to_list (sym_name, sym_len, 1,
VAR_DOMAIN, LOC_CONST,
&objfile->static_psymbols, nlist.n_value,
0, psymtab_language, objfile);
pst->textlow = nlist.n_value;
textlow_not_set = 0;
}
- add_psymbol_to_list (sym_name, sym_len,
+ add_psymbol_to_list (sym_name, sym_len, 1,
VAR_DOMAIN, LOC_BLOCK,
&objfile->static_psymbols,
0, nlist.n_value,
pst->textlow = nlist.n_value;
textlow_not_set = 0;
}
- add_psymbol_to_list (sym_name, sym_len,
+ add_psymbol_to_list (sym_name, sym_len, 1,
VAR_DOMAIN, LOC_BLOCK,
&objfile->global_psymbols,
0, nlist.n_value,
/*prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
mst_text, objfile); */
psym = add_psymbol_to_list (actual_name, strlen (actual_name),
+ built_actual_name,
VAR_DOMAIN, LOC_BLOCK,
&objfile->global_psymbols,
0, pdi->lowpc + baseaddr,
/*prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
mst_file_text, objfile); */
psym = add_psymbol_to_list (actual_name, strlen (actual_name),
+ built_actual_name,
VAR_DOMAIN, LOC_BLOCK,
&objfile->static_psymbols,
0, pdi->lowpc + baseaddr,
addr = decode_locdesc (pdi->locdesc, cu);
if (pdi->locdesc || pdi->has_type)
psym = add_psymbol_to_list (actual_name, strlen (actual_name),
+ built_actual_name,
VAR_DOMAIN, LOC_STATIC,
&objfile->global_psymbols,
0, addr + baseaddr,
/*prim_record_minimal_symbol (actual_name, addr + baseaddr,
mst_file_data, objfile); */
psym = add_psymbol_to_list (actual_name, strlen (actual_name),
+ built_actual_name,
VAR_DOMAIN, LOC_STATIC,
&objfile->static_psymbols,
0, addr + baseaddr,
case DW_TAG_base_type:
case DW_TAG_subrange_type:
add_psymbol_to_list (actual_name, strlen (actual_name),
+ built_actual_name,
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, objfile);
break;
case DW_TAG_namespace:
add_psymbol_to_list (actual_name, strlen (actual_name),
+ built_actual_name,
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->global_psymbols,
0, (CORE_ADDR) 0, cu->language, objfile);
/* NOTE: carlton/2003-10-07: See comment in new_symbol about
static vs. global. */
add_psymbol_to_list (actual_name, strlen (actual_name),
+ built_actual_name,
STRUCT_DOMAIN, LOC_TYPEDEF,
(cu->language == language_cplus
|| cu->language == language_java)
break;
case DW_TAG_enumerator:
add_psymbol_to_list (actual_name, strlen (actual_name),
+ built_actual_name,
VAR_DOMAIN, LOC_CONST,
(cu->language == language_cplus
|| cu->language == language_java)
|| part_die->tag == DW_TAG_subrange_type))
{
if (building_psymtab && part_die->name != NULL)
- add_psymbol_to_list (part_die->name, strlen (part_die->name),
+ add_psymbol_to_list (part_die->name, strlen (part_die->name), 0,
VAR_DOMAIN, LOC_TYPEDEF,
&cu->objfile->static_psymbols,
0, (CORE_ADDR) 0, cu->language, cu->objfile);
if (part_die->name == NULL)
complaint (&symfile_complaints, _("malformed enumerator DIE ignored"));
else if (building_psymtab)
- add_psymbol_to_list (part_die->name, strlen (part_die->name),
+ add_psymbol_to_list (part_die->name, strlen (part_die->name), 0,
VAR_DOMAIN, LOC_CONST,
(cu->language == language_cplus
|| cu->language == language_java)
/* Cache this symbol's name and the name's demangled form (if any). */
SYMBOL_LANGUAGE (sym) = cu->language;
- SYMBOL_SET_NAMES (sym, name, strlen (name), objfile);
+ SYMBOL_SET_NAMES (sym, name, strlen (name), 0, objfile);
/* Default assumptions.
Use the passed type or decode it from the die. */
}
static struct minimal_symbol *
-record_minimal_symbol (char *name, CORE_ADDR address,
+record_minimal_symbol (const char *name, int name_len, int copy_name,
+ CORE_ADDR address,
enum minimal_symbol_type ms_type,
asection *bfd_section, struct objfile *objfile)
{
if (ms_type == mst_text || ms_type == mst_file_text)
address = gdbarch_smash_text_address (gdbarch, address);
- return prim_record_minimal_symbol_and_info
- (name, address, ms_type, bfd_section->index, bfd_section, objfile);
+ return prim_record_minimal_symbol_full (name, name_len, copy_name, address,
+ ms_type, bfd_section->index,
+ bfd_section, objfile);
}
/*
static void
elf_symtab_read (struct objfile *objfile, int type,
- long number_of_symbols, asymbol **symbol_table)
+ long number_of_symbols, asymbol **symbol_table,
+ int copy_names)
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
long storage_needed;
symaddr += ANOFFSET (objfile->section_offsets, sect->index);
msym = record_minimal_symbol
- ((char *) sym->name, symaddr, mst_solib_trampoline, sect, objfile);
+ (sym->name, strlen (sym->name), copy_names,
+ symaddr, mst_solib_trampoline, sect, objfile);
if (msym != NULL)
msym->filename = filesymname;
continue;
continue; /* Skip this symbol. */
}
msym = record_minimal_symbol
- ((char *) sym->name, symaddr,
+ (sym->name, strlen (sym->name), copy_names, symaddr,
ms_type, sym->section, objfile);
if (msym)
if (len > 4 && strcmp (sym->name + len - 4, "@plt") == 0)
{
- char *base_name = xmalloc (len - 4 + 1);
struct minimal_symbol *mtramp;
- memcpy (base_name, sym->name, len - 4);
- base_name[len - 4] = '\0';
- mtramp = record_minimal_symbol (base_name, symaddr,
+ mtramp = record_minimal_symbol (sym->name, len - 4, 1,
+ symaddr,
mst_solib_trampoline,
sym->section, objfile);
- xfree (base_name);
if (mtramp)
{
MSYMBOL_SIZE (mtramp) = MSYMBOL_SIZE (msym);
error (_("Can't read symbols from %s: %s"), bfd_get_filename (objfile->obfd),
bfd_errmsg (bfd_get_error ()));
- elf_symtab_read (objfile, ST_REGULAR, symcount, symbol_table);
+ elf_symtab_read (objfile, ST_REGULAR, symcount, symbol_table, 0);
}
/* Add the dynamic symbols. */
error (_("Can't read symbols from %s: %s"), bfd_get_filename (objfile->obfd),
bfd_errmsg (bfd_get_error ()));
- elf_symtab_read (objfile, ST_DYNAMIC, dynsymcount, dyn_symbol_table);
+ elf_symtab_read (objfile, ST_DYNAMIC, dynsymcount, dyn_symbol_table, 0);
}
/* Add synthetic symbols - for instance, names for any PLT entries. */
for (i = 0; i < synthcount; i++)
synth_symbol_table[i] = synthsyms + i;
make_cleanup (xfree, synth_symbol_table);
- elf_symtab_read (objfile, ST_SYNTHETIC, synthcount, synth_symbol_table);
+ elf_symtab_read (objfile, ST_SYNTHETIC, synthcount, synth_symbol_table, 1);
}
/* Install any minimal symbols that have been collected as the current
/* We assume that these virtual addresses are absolute, and do not
treat them as offsets. */
sai->other[i].addr = bfd_get_section_vma (nbfd, sec);
- sai->other[i].name = (char *) bfd_get_section_name (nbfd, sec);
+ sai->other[i].name = xstrdup (bfd_get_section_name (nbfd, sec));
sai->other[i].sectindex = sec->index;
++i;
}
namestring = gdbarch_static_transform_name
(gdbarch, namestring);
- add_psymbol_to_list (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_STATIC,
&objfile->static_psymbols,
0, sh.value,
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
/* The addresses in these entries are reported to be
wrong. See the code that reads 'G's for symtabs. */
- add_psymbol_to_list (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_STATIC,
&objfile->global_psymbols,
0, sh.value,
|| (p == namestring + 1
&& namestring[0] != ' '))
{
- add_psymbol_to_list (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring, 1,
STRUCT_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
sh.value, 0,
{
/* Also a typedef with the same name. */
add_psymbol_to_list (namestring, p - namestring,
+ 1,
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
sh.value, 0,
case 't':
if (p != namestring) /* a name is there, not just :T... */
{
- add_psymbol_to_list (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
sh.value, 0,
;
/* Note that the value doesn't matter for
enum constants in psymtabs, just in symtabs. */
- add_psymbol_to_list (p, q - p,
+ add_psymbol_to_list (p, q - p, 1,
VAR_DOMAIN, LOC_CONST,
&objfile->static_psymbols, 0,
0, psymtab_language, objfile);
continue;
case 'c':
/* Constant, e.g. from "const" in Pascal. */
- add_psymbol_to_list (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_CONST,
&objfile->static_psymbols, sh.value,
0, psymtab_language, objfile);
xfree (name);
}
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
- add_psymbol_to_list (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_BLOCK,
&objfile->static_psymbols,
0, sh.value,
xfree (name);
}
sh.value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
- add_psymbol_to_list (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_BLOCK,
&objfile->global_psymbols,
0, sh.value,
symbol table, and the MAIN__ symbol via the minimal
symbol table. */
if (sh.st == stProc)
- add_psymbol_to_list (name, strlen (name),
+ add_psymbol_to_list (name, strlen (name), 1,
VAR_DOMAIN, LOC_BLOCK,
&objfile->global_psymbols,
0, sh.value, psymtab_language, objfile);
else
- add_psymbol_to_list (name, strlen (name),
+ add_psymbol_to_list (name, strlen (name), 1,
VAR_DOMAIN, LOC_BLOCK,
&objfile->static_psymbols,
0, sh.value, psymtab_language, objfile);
&& sh.iss != 0
&& sh.index != cur_sdx + 2)
{
- add_psymbol_to_list (name, strlen (name),
+ add_psymbol_to_list (name, strlen (name), 1,
STRUCT_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
0, (CORE_ADDR) 0,
continue;
}
/* Use this gdb symbol */
- add_psymbol_to_list (name, strlen (name),
+ add_psymbol_to_list (name, strlen (name), 1,
VAR_DOMAIN, class,
&objfile->static_psymbols,
0, sh.value, psymtab_language, objfile);
break;
}
name = debug_info->ssext + psh->iss;
- add_psymbol_to_list (name, strlen (name),
+ add_psymbol_to_list (name, strlen (name), 1,
VAR_DOMAIN, class,
&objfile->global_psymbols,
0, svalue,
/* Note that the value doesn't matter for enum constants
in psymtabs, just in symtabs. */
- add_psymbol_to_list (name, strlen (name),
+ add_psymbol_to_list (name, strlen (name), 1,
VAR_DOMAIN, LOC_CONST,
&objfile->static_psymbols, 0,
(CORE_ADDR) 0, psymtab_language, objfile);
memset (s, 0, sizeof (*s));
SYMBOL_LANGUAGE (s) = psymtab_language;
- SYMBOL_SET_NAMES (s, name, strlen (name), current_objfile);
+ SYMBOL_SET_NAMES (s, name, strlen (name), 1, current_objfile);
return s;
}
newly created. */
struct minimal_symbol *
-prim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address,
- enum minimal_symbol_type ms_type,
- int section,
- asection *bfd_section,
- struct objfile *objfile)
+prim_record_minimal_symbol_full (const char *name, int name_len, int copy_name,
+ CORE_ADDR address,
+ enum minimal_symbol_type ms_type,
+ int section,
+ asection *bfd_section,
+ struct objfile *objfile)
{
struct obj_section *obj_section;
struct msym_bunch *new;
/* It's safe to strip the leading char here once, since the name
is also stored stripped in the minimal symbol table. */
if (name[0] == get_symbol_leading_char (objfile->obfd))
- ++name;
+ {
+ ++name;
+ --name_len;
+ }
if (ms_type == mst_file_text && strncmp (name, "__gnu_compiled", 14) == 0)
return (NULL);
msymbol = &msym_bunch->contents[msym_bunch_index];
SYMBOL_INIT_LANGUAGE_SPECIFIC (msymbol, language_unknown);
SYMBOL_LANGUAGE (msymbol) = language_auto;
- SYMBOL_SET_NAMES (msymbol, (char *)name, strlen (name), objfile);
+ SYMBOL_SET_NAMES (msymbol, name, name_len, copy_name, objfile);
SYMBOL_VALUE_ADDRESS (msymbol) = address;
SYMBOL_SECTION (msymbol) = section;
return msymbol;
}
+/* Record a minimal symbol in the msym bunches. Returns the symbol
+ newly created. */
+
+struct minimal_symbol *
+prim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address,
+ enum minimal_symbol_type ms_type,
+ int section,
+ asection *bfd_section,
+ struct objfile *objfile)
+{
+ return prim_record_minimal_symbol_full (name, strlen (name), 1,
+ address, ms_type, section,
+ bfd_section, objfile);
+}
+
/* Compare two minimal symbols by address and return a signed result based
on unsigned comparisons, so that we sort into unsigned numeric order.
Within groups with the same address, sort by name. */
}
if (new_name != NULL)
{
- SYMBOL_SET_NAMES (sym, new_name, strlen (new_name), objfile);
+ SYMBOL_SET_NAMES (sym, new_name, strlen (new_name), 1, objfile);
xfree (new_name);
}
else
- SYMBOL_SET_NAMES (sym, string, p - string, objfile);
+ SYMBOL_SET_NAMES (sym, string, p - string, 1, objfile);
}
p++;
different domain (or address) is possible and correct. */
static const struct partial_symbol *
-add_psymbol_to_bcache (char *name, int namelength, domain_enum domain,
+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 */
PSYMBOL_DOMAIN (&psymbol) = domain;
PSYMBOL_CLASS (&psymbol) = class;
- SYMBOL_SET_NAMES (&psymbol, name, namelength, objfile);
+ 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),
cache. */
const struct partial_symbol *
-add_psymbol_to_list (char *name, int namelength, domain_enum domain,
+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 */
int added;
/* Stash the partial symbol away in the cache */
- psym = add_psymbol_to_bcache (name, namelength, domain, class,
+ psym = add_psymbol_to_bcache (name, namelength, copy_name, domain, class,
val, coreaddr, language, objfile, &added);
/* Do not duplicate global partial symbols. */
/* #include "demangle.h" */
extern const
-struct partial_symbol *add_psymbol_to_list (char *, int, domain_enum,
+struct partial_symbol *add_psymbol_to_list (char *, int, int, domain_enum,
enum address_class,
struct psymbol_allocation_list *,
long, CORE_ADDR,
/* Functions to initialize a symbol's mangled name. */
+/* Objects of this type are stored in the demangled name hash table. */
+struct demangled_name_entry
+{
+ char *mangled;
+ char demangled[1];
+};
+
+/* Hash function for the demangled name hash. */
+static hashval_t
+hash_demangled_name_entry (const void *data)
+{
+ const struct demangled_name_entry *e = data;
+ return htab_hash_string (e->mangled);
+}
+
+/* Equality function for the demangled name hash. */
+static int
+eq_demangled_name_entry (const void *a, const void *b)
+{
+ const struct demangled_name_entry *da = a;
+ const struct demangled_name_entry *db = b;
+ return strcmp (da->mangled, db->mangled) == 0;
+}
+
/* Create the hash table used for demangled names. Each hash entry is
a pair of strings; one for the mangled name and one for the demangled
name. The entry is hashed via just the mangled name. */
1% in symbol reading. */
objfile->demangled_names_hash = htab_create_alloc
- (256, htab_hash_string, (int (*) (const void *, const void *)) streq,
+ (256, hash_demangled_name_entry, eq_demangled_name_entry,
NULL, xcalloc, xfree);
}
}
/* Set both the mangled and demangled (if any) names for GSYMBOL based
- on LINKAGE_NAME and LEN. The hash table corresponding to OBJFILE
- is used, and the memory comes from that objfile's objfile_obstack.
- LINKAGE_NAME is copied, so the pointer can be discarded after
- calling this function. */
+ on LINKAGE_NAME and LEN. Ordinarily, NAME is copied onto the
+ objfile's obstack; but if COPY_NAME is 0 and if NAME is
+ NUL-terminated, then this function assumes that NAME is already
+ correctly saved (either permanently or with a lifetime tied to the
+ objfile), and it will not be copied.
+
+ The hash table corresponding to OBJFILE is used, and the memory
+ comes from that objfile's objfile_obstack. LINKAGE_NAME is copied,
+ so the pointer can be discarded after calling this function. */
/* We have to be careful when dealing with Java names: when we run
into a Java minimal symbol, we don't know it's a Java symbol, so it
void
symbol_set_names (struct general_symbol_info *gsymbol,
- const char *linkage_name, int len, struct objfile *objfile)
+ const char *linkage_name, int len, int copy_name,
+ struct objfile *objfile)
{
- char **slot;
+ struct demangled_name_entry **slot;
/* A 0-terminated copy of the linkage name. */
const char *linkage_name_copy;
/* A copy of the linkage name that might have a special Java prefix
const char *lookup_name;
/* The length of lookup_name. */
int lookup_len;
-
- if (objfile->demangled_names_hash == NULL)
- create_demangled_names_hash (objfile);
+ struct demangled_name_entry entry;
if (gsymbol->language == language_ada)
{
been observed with Java. Because we don't store the demangled
name with the symbol, we don't need to use the same trick
as Java. */
- gsymbol->name = obstack_alloc (&objfile->objfile_obstack, len + 1);
- memcpy (gsymbol->name, linkage_name, len);
- gsymbol->name[len] = '\0';
+ if (!copy_name)
+ gsymbol->name = (char *) linkage_name;
+ else
+ {
+ gsymbol->name = obstack_alloc (&objfile->objfile_obstack, len + 1);
+ memcpy (gsymbol->name, linkage_name, len);
+ gsymbol->name[len] = '\0';
+ }
gsymbol->language_specific.cplus_specific.demangled_name = NULL;
return;
}
+ if (objfile->demangled_names_hash == NULL)
+ create_demangled_names_hash (objfile);
+
/* The stabs reader generally provides names that are not
NUL-terminated; most of the other readers don't do this, so we
can just use the given copy, unless we're in the Java case. */
linkage_name_copy = linkage_name;
}
- slot = (char **) htab_find_slot (objfile->demangled_names_hash,
- lookup_name, INSERT);
+ entry.mangled = (char *) lookup_name;
+ slot = ((struct demangled_name_entry **)
+ htab_find_slot (objfile->demangled_names_hash,
+ &entry, INSERT));
/* If this name is not in the hash table, add it. */
if (*slot == NULL)
linkage_name_copy);
int demangled_len = demangled_name ? strlen (demangled_name) : 0;
- /* If there is a demangled name, place it right after the mangled name.
- Otherwise, just place a second zero byte after the end of the mangled
- name. */
- *slot = obstack_alloc (&objfile->objfile_obstack,
- lookup_len + demangled_len + 2);
- memcpy (*slot, lookup_name, lookup_len + 1);
+ /* Suppose we have demangled_name==NULL, copy_name==0, and
+ lookup_name==linkage_name. In this case, we already have the
+ mangled name saved, and we don't have a demangled name. So,
+ you might think we could save a little space by not recording
+ this in the hash table at all.
+
+ It turns out that it is actually important to still save such
+ an entry in the hash table, because storing this name gives
+ us better backache hit rates for partial symbols. */
+ if (!copy_name && lookup_name == linkage_name)
+ {
+ *slot = obstack_alloc (&objfile->objfile_obstack,
+ offsetof (struct demangled_name_entry,
+ demangled)
+ + demangled_len + 1);
+ (*slot)->mangled = (char *) lookup_name;
+ }
+ else
+ {
+ /* If we must copy the mangled name, put it directly after
+ the demangled name so we can have a single
+ allocation. */
+ *slot = obstack_alloc (&objfile->objfile_obstack,
+ offsetof (struct demangled_name_entry,
+ demangled)
+ + lookup_len + demangled_len + 2);
+ (*slot)->mangled = &((*slot)->demangled[demangled_len + 1]);
+ strcpy ((*slot)->mangled, lookup_name);
+ }
+
if (demangled_name != NULL)
{
- memcpy (*slot + lookup_len + 1, demangled_name, demangled_len + 1);
+ strcpy ((*slot)->demangled, demangled_name);
xfree (demangled_name);
}
else
- (*slot)[lookup_len + 1] = '\0';
+ (*slot)->demangled[0] = '\0';
}
- gsymbol->name = *slot + lookup_len - len;
- if ((*slot)[lookup_len + 1] != '\0')
+ gsymbol->name = (*slot)->mangled;
+ if ((*slot)->demangled[0] != '\0')
gsymbol->language_specific.cplus_specific.demangled_name
- = &(*slot)[lookup_len + 1];
+ = (*slot)->demangled;
else
gsymbol->language_specific.cplus_specific.demangled_name = NULL;
}
/* Set the linkage and natural names of a symbol, by demangling
the linkage name. */
-#define SYMBOL_SET_NAMES(symbol,linkage_name,len,objfile) \
- symbol_set_names (&(symbol)->ginfo, linkage_name, len, objfile)
+#define SYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile) \
+ symbol_set_names (&(symbol)->ginfo, linkage_name, len, copy_name, objfile)
extern void symbol_set_names (struct general_symbol_info *symbol,
- const char *linkage_name, int len,
+ const char *linkage_name, int len, int copy_name,
struct objfile *objfile);
/* Now come lots of name accessor macros. Short version as to when to
enum minimal_symbol_type,
struct objfile *);
+extern struct minimal_symbol *prim_record_minimal_symbol_full
+ (const char *, int, int, CORE_ADDR,
+ enum minimal_symbol_type,
+ int section, asection * bfd_section, struct objfile *);
+
extern struct minimal_symbol *prim_record_minimal_symbol_and_info
(const char *, CORE_ADDR,
enum minimal_symbol_type,
namestring = gdbarch_static_transform_name
(gdbarch, namestring);
- add_psymbol_to_list (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_STATIC,
&objfile->static_psymbols,
0, symbol.n_value,
symbol.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile));
/* The addresses in these entries are reported to be
wrong. See the code that reads 'G's for symtabs. */
- add_psymbol_to_list (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_STATIC,
&objfile->global_psymbols,
0, symbol.n_value,
|| (p == namestring + 1
&& namestring[0] != ' '))
{
- add_psymbol_to_list (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring, 1,
STRUCT_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
symbol.n_value, 0,
if (p[2] == 't')
{
/* Also a typedef with the same name. */
- add_psymbol_to_list (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
symbol.n_value, 0,
case 't':
if (p != namestring) /* a name is there, not just :T... */
{
- add_psymbol_to_list (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
symbol.n_value, 0,
;
/* Note that the value doesn't matter for
enum constants in psymtabs, just in symtabs. */
- add_psymbol_to_list (p, q - p,
+ add_psymbol_to_list (p, q - p, 1,
VAR_DOMAIN, LOC_CONST,
&objfile->static_psymbols, 0,
0, psymtab_language, objfile);
case 'c':
/* Constant, e.g. from "const" in Pascal. */
- add_psymbol_to_list (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_CONST,
&objfile->static_psymbols, symbol.n_value,
0, psymtab_language, objfile);
xfree (name);
}
symbol.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
- add_psymbol_to_list (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_BLOCK,
&objfile->static_psymbols,
0, symbol.n_value,
continue;
symbol.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
- add_psymbol_to_list (namestring, p - namestring,
+ add_psymbol_to_list (namestring, p - namestring, 1,
VAR_DOMAIN, LOC_BLOCK,
&objfile->global_psymbols,
0, symbol.n_value,