aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog32
-rw-r--r--gdb/coffread.c2
-rw-r--r--gdb/cp-namespace.c5
-rw-r--r--gdb/dbxread.c18
-rw-r--r--gdb/dwarf2read.c14
-rw-r--r--gdb/elfread.c29
-rw-r--r--gdb/jit.c2
-rw-r--r--gdb/mdebugread.c31
-rw-r--r--gdb/minsyms.c33
-rw-r--r--gdb/stabsread.c4
-rw-r--r--gdb/symfile.c10
-rw-r--r--gdb/symfile.h2
-rw-r--r--gdb/symtab.c114
-rw-r--r--gdb/symtab.h11
-rw-r--r--gdb/xcoffread.c18
15 files changed, 228 insertions, 97 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 93fdd8c..2554732 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,35 @@
+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
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 3e68698..98c563a 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1503,7 +1503,7 @@ process_coff_symbol (struct coff_symbol *cs,
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;
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index d2d8f2e..a7a387b 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -714,7 +714,6 @@ check_one_possible_namespace_symbol (const char *name, int len,
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);
@@ -723,7 +722,9 @@ check_one_possible_namespace_symbol (const char *name, int len,
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;
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index d5c7ff5..54d8b51 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -1726,7 +1726,7 @@ pos %d"),
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,
@@ -1738,7 +1738,7 @@ pos %d"),
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,
@@ -1756,7 +1756,7 @@ pos %d"),
|| (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,
@@ -1764,7 +1764,7 @@ pos %d"),
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,
@@ -1777,7 +1777,7 @@ pos %d"),
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,
@@ -1839,7 +1839,7 @@ pos %d"),
;
/* 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);
@@ -1857,7 +1857,7 @@ pos %d"),
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);
@@ -1921,7 +1921,7 @@ pos %d"),
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,
@@ -1989,7 +1989,7 @@ pos %d"),
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,
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 2f6e522..c859605 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2460,6 +2460,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
/*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,
@@ -2470,6 +2471,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
/*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,
@@ -2496,6 +2498,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
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,
@@ -2514,6 +2517,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
/*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,
@@ -2524,12 +2528,14 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
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);
@@ -2554,6 +2560,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
/* 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)
@@ -2564,6 +2571,7 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
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)
@@ -6572,7 +6580,7 @@ load_partial_dies (bfd *abfd, gdb_byte *buffer, gdb_byte *info_ptr,
|| 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);
@@ -6593,7 +6601,7 @@ load_partial_dies (bfd *abfd, gdb_byte *buffer, gdb_byte *info_ptr,
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)
@@ -8325,7 +8333,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
/* 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. */
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 89089e3..0885240 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -172,7 +172,8 @@ elf_locate_sections (bfd *ignore_abfd, asection *sectp, void *eip)
}
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)
{
@@ -181,8 +182,9 @@ record_minimal_symbol (char *name, CORE_ADDR address,
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);
}
/*
@@ -216,7 +218,8 @@ record_minimal_symbol (char *name, CORE_ADDR address,
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;
@@ -298,7 +301,8 @@ elf_symtab_read (struct objfile *objfile, int type,
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;
@@ -511,7 +515,7 @@ elf_symtab_read (struct objfile *objfile, int type,
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)
@@ -546,15 +550,12 @@ elf_symtab_read (struct objfile *objfile, int type,
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);
@@ -639,7 +640,7 @@ elf_symfile_read (struct objfile *objfile, int mainline)
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. */
@@ -657,7 +658,7 @@ elf_symfile_read (struct objfile *objfile, int mainline)
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. */
@@ -675,7 +676,7 @@ elf_symfile_read (struct objfile *objfile, int mainline)
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
diff --git a/gdb/jit.c b/gdb/jit.c
index a362098..ba4428b 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -253,7 +253,7 @@ JITed symbol file is not an object file, ignoring it.\n"));
/* 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;
}
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 7d29b97..e3f7f8a 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3095,7 +3095,7 @@ parse_partial_symbols (struct objfile *objfile)
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,
@@ -3105,7 +3105,7 @@ parse_partial_symbols (struct objfile *objfile)
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,
@@ -3123,7 +3123,7 @@ parse_partial_symbols (struct objfile *objfile)
|| (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,
@@ -3132,6 +3132,7 @@ parse_partial_symbols (struct objfile *objfile)
{
/* 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,
@@ -3143,7 +3144,7 @@ parse_partial_symbols (struct objfile *objfile)
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,
@@ -3205,7 +3206,7 @@ parse_partial_symbols (struct objfile *objfile)
;
/* 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);
@@ -3222,7 +3223,7 @@ parse_partial_symbols (struct objfile *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);
@@ -3239,7 +3240,7 @@ parse_partial_symbols (struct objfile *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,
@@ -3260,7 +3261,7 @@ parse_partial_symbols (struct objfile *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->global_psymbols,
0, sh.value,
@@ -3489,12 +3490,12 @@ parse_partial_symbols (struct objfile *objfile)
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);
@@ -3563,7 +3564,7 @@ parse_partial_symbols (struct objfile *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,
@@ -3604,7 +3605,7 @@ parse_partial_symbols (struct objfile *objfile)
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);
@@ -3680,7 +3681,7 @@ parse_partial_symbols (struct objfile *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,
@@ -3843,7 +3844,7 @@ handle_psymbol_enumerators (struct objfile *objfile, FDR *fh, int stype,
/* 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);
@@ -4788,7 +4789,7 @@ new_symbol (char *name)
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;
}
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 64d20d2..393a0ea 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -757,11 +757,12 @@ prim_record_minimal_symbol (const char *name, CORE_ADDR address,
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;
@@ -780,7 +781,10 @@ prim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address,
/* 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);
@@ -795,7 +799,7 @@ prim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address,
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;
@@ -828,6 +832,21 @@ prim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address,
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. */
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 274fe1a..fee2873 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -713,11 +713,11 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
}
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++;
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 30ae0df..b635691 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -3132,7 +3132,8 @@ start_psymtab_common (struct objfile *objfile,
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 */
@@ -3162,7 +3163,7 @@ add_psymbol_to_bcache (char *name, int namelength, domain_enum domain,
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),
@@ -3199,7 +3200,8 @@ append_psymbol_to_list (struct psymbol_allocation_list *list,
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 */
@@ -3211,7 +3213,7 @@ add_psymbol_to_list (char *name, int namelength, domain_enum domain,
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. */
diff --git a/gdb/symfile.h b/gdb/symfile.h
index c407315..f73d22d 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -194,7 +194,7 @@ extern void extend_psymbol_list (struct psymbol_allocation_list *,
/* #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,
diff --git a/gdb/symtab.c b/gdb/symtab.c
index e092ad4..b512bf3 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -427,6 +427,30 @@ symbol_init_language_specific (struct general_symbol_info *gsymbol,
/* 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. */
@@ -440,7 +464,7 @@ create_demangled_names_hash (struct objfile *objfile)
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);
}
@@ -496,10 +520,15 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
}
/* 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
@@ -522,9 +551,10 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
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
@@ -532,9 +562,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
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)
{
@@ -546,14 +574,22 @@ symbol_set_names (struct general_symbol_info *gsymbol,
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. */
@@ -589,8 +625,10 @@ symbol_set_names (struct general_symbol_info *gsymbol,
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)
@@ -599,25 +637,49 @@ symbol_set_names (struct general_symbol_info *gsymbol,
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;
}
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 2bc3dd5..f0c4ddb 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -192,10 +192,10 @@ extern void symbol_init_language_specific (struct general_symbol_info *symbol,
/* 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
@@ -1122,6 +1122,11 @@ extern void prim_record_minimal_symbol (const char *, CORE_ADDR,
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,
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index c56ab86..a93fbd2 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2606,7 +2606,7 @@ scan_xcoff_symtab (struct objfile *objfile)
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,
@@ -2617,7 +2617,7 @@ scan_xcoff_symtab (struct objfile *objfile)
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,
@@ -2635,7 +2635,7 @@ scan_xcoff_symtab (struct objfile *objfile)
|| (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,
@@ -2643,7 +2643,7 @@ scan_xcoff_symtab (struct objfile *objfile)
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,
@@ -2656,7 +2656,7 @@ scan_xcoff_symtab (struct objfile *objfile)
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,
@@ -2718,7 +2718,7 @@ scan_xcoff_symtab (struct objfile *objfile)
;
/* 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);
@@ -2736,7 +2736,7 @@ scan_xcoff_symtab (struct objfile *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);
@@ -2753,7 +2753,7 @@ scan_xcoff_symtab (struct objfile *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,
@@ -2782,7 +2782,7 @@ scan_xcoff_symtab (struct objfile *objfile)
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,