+2016-10-21 Tom Tromey <tom@tromey.com>
+
+ * xcoffread.c (record_minimal_symbol, scan_xcoff_symtab): Add
+ "reader" argument. Update.
+ (xcoff_initial_scan): Update.
+ * symfile.h (mdebug_build_psymtabs): Add "reader" argument.
+ * mipsread.c (mipscoff_symfile_read): Update.
+ (read_alphacoff_dynamic_symtab): Add "reader" argument. Update.
+ * minsyms.h (minimal_symbol_reader) <record, record_full>:
+ Declare.
+ <m_msym_bunch, m_msym_bunch_index, m_msym_count>: New members.
+ <record_with_info>: New function, renamed from
+ prim_record_minimal_symbol_and_info.
+ * minsyms.c (msym_bunch, msym_bunch_index, msym_count): Remove
+ globals.
+ (minimal_symbol_reader): Initialize new members.
+ (minimal_symbol_reader::record): Renamed from
+ prim_record_minimal_symbol.
+ (minimal_symbol_reader::record_full): Renamed from
+ prim_record_minimal_symbol_full.
+ (prim_record_minimal_symbol_and_info): Move to minsyms.h; rename.
+ * mdebugread.c (mdebug_build_psymtabs, parse_partial_symbols)
+ (record_minimal_symbol): Add "reader" argument. Update.
+ (elfmdebug_build_psymtabs): Update.
+ * machoread.c (macho_symtab_add_minsym, macho_symtab_read): Add
+ "reader" argument. Update.
+ (macho_symfile_read): Update.
+ * elfread.c (record_minimal_symbol, elf_symtab_read)
+ (elf_rel_plt_read): Add "reader" argument. Update.
+ (elf_read_minimal_symbols): Update.
+ * dbxread.c (record_minimal_symbol, read_dbx_dynamic_symtab)
+ (read_dbx_symtab): Add "reader" argument. Update.
+ (dbx_symfile_read): Update.
+ * coffread.c (record_minimal_symbol, coff_symtab_read): Add
+ "reader" argument. Update.
+ (coff_symfile_read): Update.
+ * coff-pe-read.h (read_pe_exported_syms): Add "reader" argument.
+ * coff-pe-read.c (add_pe_exported_sym, add_pe_forwarded_sym)
+ (read_pe_exported_syms): Add "reader" argument. Update.
+
2016-10-21 Tom Tromey <tom@tromey.com>
* xcoffread.c (xcoff_initial_scan): Update.
OBJFILE is the objfile struct of DLL_NAME. */
static void
-add_pe_exported_sym (const char *sym_name,
+add_pe_exported_sym (minimal_symbol_reader &reader,
+ const char *sym_name,
unsigned long func_rva,
int ordinal,
const struct read_pe_section_data *section_data,
" for entry \"%s\" in dll \"%s\"\n"),
section_data->section_name, sym_name, dll_name);
- prim_record_minimal_symbol_and_info (qualified_name, vma,
- section_data->ms_type,
- section_data->index, objfile);
+ reader.record_with_info (qualified_name, vma, section_data->ms_type,
+ section_data->index);
/* Enter the plain name as well, which might not be unique. */
- prim_record_minimal_symbol_and_info (bare_name, vma, section_data->ms_type,
- section_data->index, objfile);
+ reader.record_with_info (bare_name, vma, section_data->ms_type,
+ section_data->index);
if (debug_coff_pe_read > 1)
fprintf_unfiltered (gdb_stdlog, _("Adding exported symbol \"%s\""
" in dll \"%s\"\n"), sym_name, dll_name);
OBJFILE is the objfile struct of DLL_NAME. */
static int
-add_pe_forwarded_sym (const char *sym_name, const char *forward_dll_name,
+add_pe_forwarded_sym (minimal_symbol_reader &reader,
+ const char *sym_name, const char *forward_dll_name,
const char *forward_func_name, int ordinal,
const char *dll_name, struct objfile *objfile)
{
code. */
baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
- prim_record_minimal_symbol_and_info (qualified_name, vma - baseaddr,
- msymtype, section, objfile);
+ reader.record_with_info (qualified_name, vma - baseaddr, msymtype, section);
/* Enter the plain name as well, which might not be unique. */
- prim_record_minimal_symbol_and_info (bare_name, vma - baseaddr, msymtype,
- section, objfile);
+ reader.record_with_info (bare_name, vma - baseaddr, msymtype, section);
xfree (qualified_name);
xfree (bare_name);
pe_implied_import_dll in pe-dll.c. */
void
-read_pe_exported_syms (struct objfile *objfile)
+read_pe_exported_syms (minimal_symbol_reader &reader,
+ struct objfile *objfile)
{
bfd *dll = objfile->obfd;
unsigned long nbnormal, nbforward;
forward_dll_name[len] = '\0';
forward_func_name = ++sep;
}
- if (add_pe_forwarded_sym (funcname, forward_dll_name,
+ if (add_pe_forwarded_sym (reader, funcname, forward_dll_name,
forward_func_name, ordinal,
dll_name, objfile) != 0)
++nbforward;
char *sym_name = (char *) (erva + name_rva);
section_found = 1;
- add_pe_exported_sym (sym_name, func_rva, ordinal,
+ add_pe_exported_sym (reader, sym_name, func_rva, ordinal,
section_data + sectix, dll_name, objfile);
++nbnormal;
break;
if (name_rva == 0)
{
- add_pe_exported_sym (NULL, func_rva, ordinal,
+ add_pe_exported_sym (reader, NULL, func_rva, ordinal,
section_data, dll_name, objfile);
++nbnormal;
}
/* Read the export table and convert it to minimal symbol table
entries */
-extern void read_pe_exported_syms (struct objfile *objfile);
+extern void read_pe_exported_syms (minimal_symbol_reader &reader,
+ struct objfile *objfile);
/* Extract from ABFD the offset of the .text section.
Returns default value 0x1000 if information is not found. */
struct internal_syment *,
union internal_auxent *);
-static void coff_symtab_read (long, unsigned int, struct objfile *);
+static void coff_symtab_read (minimal_symbol_reader &,
+ long, unsigned int, struct objfile *);
\f
/* We are called once per section from coff_symfile_read. We
need to examine each section we are passed, check to see
}
static struct minimal_symbol *
-record_minimal_symbol (struct coff_symbol *cs, CORE_ADDR address,
+record_minimal_symbol (minimal_symbol_reader &reader,
+ struct coff_symbol *cs, CORE_ADDR address,
enum minimal_symbol_type type, int section,
struct objfile *objfile)
{
return NULL;
}
- return prim_record_minimal_symbol_and_info (cs->c_name, address,
- type, section, objfile);
+ return reader.record_with_info (cs->c_name, address, type, section);
}
\f
/* coff_symfile_init ()
/* Now that the executable file is positioned at symbol table,
process it and define symbols accordingly. */
- coff_symtab_read ((long) symtab_offset, num_symbols, objfile);
+ coff_symtab_read (reader, (long) symtab_offset, num_symbols, objfile);
/* Install any minimal symbols that have been collected as the
current minimal symbols for this objfile. */
We read them one at a time using read_one_sym (). */
static void
-coff_symtab_read (long symtab_offset, unsigned int nsyms,
+coff_symtab_read (minimal_symbol_reader &reader,
+ long symtab_offset, unsigned int nsyms,
struct objfile *objfile)
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
int section = cs_to_section (cs, objfile);
tmpaddr = cs->c_value;
- record_minimal_symbol (cs, tmpaddr, mst_text,
+ record_minimal_symbol (reader, cs, tmpaddr, mst_text,
section, objfile);
fcn_line_ptr = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr;
ms_type = mst_unknown;
}
- msym = record_minimal_symbol (cs, tmpaddr, ms_type,
+ msym = record_minimal_symbol (reader, cs, tmpaddr, ms_type,
sec, objfile);
if (msym)
gdbarch_coff_make_msymbol_special (gdbarch,
{
/* We've got no debugging symbols, but it's a portable
executable, so try to read the export table. */
- read_pe_exported_syms (objfile);
+ read_pe_exported_syms (reader, objfile);
}
if (get_last_source_file ())
static void dbx_psymtab_to_symtab_1 (struct objfile *, struct partial_symtab *);
-static void read_dbx_dynamic_symtab (struct objfile *objfile);
+static void read_dbx_dynamic_symtab (minimal_symbol_reader &reader,
+ struct objfile *objfile);
-static void read_dbx_symtab (struct objfile *);
+static void read_dbx_symtab (minimal_symbol_reader &, struct objfile *);
static void free_bincl_list (struct objfile *);
static void dbx_symfile_finish (struct objfile *);
-static void record_minimal_symbol (const char *, CORE_ADDR, int,
+static void record_minimal_symbol (minimal_symbol_reader &,
+ const char *, CORE_ADDR, int,
struct objfile *);
static void add_new_header_file (char *, int);
#endif
\f
static void
-record_minimal_symbol (const char *name, CORE_ADDR address, int type,
+record_minimal_symbol (minimal_symbol_reader &reader,
+ const char *name, CORE_ADDR address, int type,
struct objfile *objfile)
{
enum minimal_symbol_type ms_type;
&& address < lowest_text_address)
lowest_text_address = address;
- prim_record_minimal_symbol_and_info
- (name, address, ms_type, section, objfile);
+ reader.record_with_info (name, address, ms_type, section);
}
\f
/* Scan and build partial symbols for a symbol file.
/* Read stabs data from executable file and define symbols. */
- read_dbx_symtab (objfile);
+ read_dbx_symtab (reader, objfile);
/* Add the dynamic symbols. */
- read_dbx_dynamic_symtab (objfile);
+ read_dbx_dynamic_symtab (reader, objfile);
/* Install any minimal symbols that have been collected as the current
minimal symbols for this objfile. */
add them to the minimal symbol table. */
static void
-read_dbx_dynamic_symtab (struct objfile *objfile)
+read_dbx_dynamic_symtab (minimal_symbol_reader &reader,
+ struct objfile *objfile)
{
bfd *abfd = objfile->obfd;
struct cleanup *back_to;
if (sym->flags & BSF_GLOBAL)
type |= N_EXT;
- record_minimal_symbol (bfd_asymbol_name (sym), sym_value,
+ record_minimal_symbol (reader, bfd_asymbol_name (sym), sym_value,
type, objfile);
}
}
}
name = bfd_asymbol_name (*rel->sym_ptr_ptr);
- prim_record_minimal_symbol (name, address, mst_solib_trampoline,
- objfile);
+ reader.record (name, address, mst_solib_trampoline);
}
do_cleanups (back_to);
debugging information is available. */
static void
-read_dbx_symtab (struct objfile *objfile)
+read_dbx_symtab (minimal_symbol_reader &reader, struct objfile *objfile)
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct external_nlist *bufp = 0; /* =0 avoids gcc -Wall glitch. */
record_it:
namestring = set_namestring (objfile, &nlist);
- record_minimal_symbol (namestring, nlist.n_value,
+ record_minimal_symbol (reader, namestring, nlist.n_value,
nlist.n_type, objfile); /* Always */
continue;
}
static struct minimal_symbol *
-record_minimal_symbol (const char *name, int name_len, int copy_name,
+record_minimal_symbol (minimal_symbol_reader &reader,
+ const char *name, int name_len, int copy_name,
CORE_ADDR address,
enum minimal_symbol_type ms_type,
asection *bfd_section, struct objfile *objfile)
|| ms_type == mst_text_gnu_ifunc)
address = gdbarch_addr_bits_remove (gdbarch, address);
- return prim_record_minimal_symbol_full (name, name_len, copy_name, address,
- ms_type,
- gdb_bfd_section_index (objfile->obfd,
- bfd_section),
- objfile);
+ return reader.record_full (name, name_len, copy_name, address,
+ ms_type,
+ gdb_bfd_section_index (objfile->obfd,
+ bfd_section));
}
/* Read the symbol table of an ELF file.
#define ST_SYNTHETIC 2
static void
-elf_symtab_read (struct objfile *objfile, int type,
+elf_symtab_read (minimal_symbol_reader &reader,
+ struct objfile *objfile, int type,
long number_of_symbols, asymbol **symbol_table,
int copy_names)
{
continue;
msym = record_minimal_symbol
- (sym->name, strlen (sym->name), copy_names,
+ (reader, sym->name, strlen (sym->name), copy_names,
symaddr, mst_solib_trampoline, sect, objfile);
if (msym != NULL)
{
continue; /* Skip this symbol. */
}
msym = record_minimal_symbol
- (sym->name, strlen (sym->name), copy_names, symaddr,
+ (reader, sym->name, strlen (sym->name), copy_names, symaddr,
ms_type, sym->section, objfile);
if (msym)
{
int len = atsign - sym->name;
- record_minimal_symbol (sym->name, len, 1, symaddr,
+ record_minimal_symbol (reader, sym->name, len, 1, symaddr,
ms_type, sym->section, objfile);
}
}
{
struct minimal_symbol *mtramp;
- mtramp = record_minimal_symbol (sym->name, len - 4, 1,
+ mtramp = record_minimal_symbol (reader, sym->name, len - 4, 1,
symaddr,
mst_solib_trampoline,
sym->section, objfile);
DYN_SYMBOL_TABLE is no longer easily available for OBJFILE. */
static void
-elf_rel_plt_read (struct objfile *objfile, asymbol **dyn_symbol_table)
+elf_rel_plt_read (minimal_symbol_reader &reader,
+ struct objfile *objfile, asymbol **dyn_symbol_table)
{
bfd *obfd = objfile->obfd;
const struct elf_backend_data *bed = get_elf_backend_data (obfd);
memcpy (&string_buffer[name_len], SYMBOL_GOT_PLT_SUFFIX,
got_suffix_len + 1);
- msym = record_minimal_symbol (string_buffer, name_len + got_suffix_len,
+ msym = record_minimal_symbol (reader, string_buffer,
+ name_len + got_suffix_len,
1, address, mst_slot_got_plt, got_plt,
objfile);
if (msym)
bfd_get_filename (objfile->obfd),
bfd_errmsg (bfd_get_error ()));
- elf_symtab_read (objfile, ST_REGULAR, symcount, symbol_table, 0);
+ elf_symtab_read (reader, objfile, ST_REGULAR, symcount, symbol_table, 0);
}
/* Add the dynamic symbols. */
bfd_get_filename (objfile->obfd),
bfd_errmsg (bfd_get_error ()));
- elf_symtab_read (objfile, ST_DYNAMIC, dynsymcount, dyn_symbol_table, 0);
+ elf_symtab_read (reader, objfile, ST_DYNAMIC, dynsymcount,
+ dyn_symbol_table, 0);
- elf_rel_plt_read (objfile, dyn_symbol_table);
+ elf_rel_plt_read (reader, objfile, dyn_symbol_table);
}
/* Contrary to binutils --strip-debug/--only-keep-debug the strip command from
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,
+ elf_symtab_read (reader, objfile, ST_SYNTHETIC, synthcount,
synth_symbol_table, 1);
}
/* Add symbol SYM to the minimal symbol table of OBJFILE. */
static void
-macho_symtab_add_minsym (struct objfile *objfile, const asymbol *sym)
+macho_symtab_add_minsym (minimal_symbol_reader &reader,
+ struct objfile *objfile, const asymbol *sym)
{
if (sym->name == NULL || *sym->name == '\0')
{
else
return; /* Skip this symbol. */
- prim_record_minimal_symbol_and_info
- (sym->name, symaddr, ms_type,
- gdb_bfd_section_index (objfile->obfd, sym->section),
- objfile);
+ reader.record_with_info (sym->name, symaddr, ms_type,
+ gdb_bfd_section_index (objfile->obfd,
+ sym->section));
}
}
NUMBER_OF_SYMBOLS for OBJFILE. Registers OSO filenames found. */
static void
-macho_symtab_read (struct objfile *objfile,
+macho_symtab_read (minimal_symbol_reader &reader,
+ struct objfile *objfile,
long number_of_symbols, asymbol **symbol_table,
VEC (oso_el) **oso_vector_ptr)
{
else
{
/* Non-debugging symbols go to the minimal symbol table. */
- macho_symtab_add_minsym (objfile, sym);
+ macho_symtab_add_minsym (reader, objfile, sym);
}
break;
bfd_get_filename (objfile->obfd),
bfd_errmsg (bfd_get_error ()));
- macho_symtab_read (objfile, symcount, symbol_table, &oso_vector);
+ macho_symtab_read (reader, objfile, symcount, symbol_table,
+ &oso_vector);
reader.install ();
}
static int upgrade_type (int, struct type **, int, union aux_ext *,
int, char *);
-static void parse_partial_symbols (struct objfile *);
+static void parse_partial_symbols (minimal_symbol_reader &,
+ struct objfile *);
static int has_opaque_xref (FDR *, SYMR *);
different sections are relocated via the SECTION_OFFSETS. */
void
-mdebug_build_psymtabs (struct objfile *objfile,
+mdebug_build_psymtabs (minimal_symbol_reader &reader,
+ struct objfile *objfile,
const struct ecoff_debug_swap *swap,
struct ecoff_debug_info *info)
{
(*swap->swap_fdr_in) (objfile->obfd, fdr_src, fdr_ptr);
}
- parse_partial_symbols (objfile);
+ parse_partial_symbols (reader, objfile);
#if 0
/* Check to make sure file was compiled with -g. If not, warn the
belongs to, and then records this new minimal symbol. */
static void
-record_minimal_symbol (const char *name, const CORE_ADDR address,
+record_minimal_symbol (minimal_symbol_reader &reader,
+ const char *name, const CORE_ADDR address,
enum minimal_symbol_type ms_type, int storage_class,
struct objfile *objfile)
{
section = -1;
}
- prim_record_minimal_symbol_and_info (name, address, ms_type,
- section, objfile);
+ reader.record_with_info (name, address, ms_type, section);
}
/* Master parsing procedure for first-pass reading of file symbols
into a partial_symtab. */
static void
-parse_partial_symbols (struct objfile *objfile)
+parse_partial_symbols (minimal_symbol_reader &reader,
+ struct objfile *objfile)
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
const bfd_size_type external_sym_size = debug_swap->external_sym_size;
unknown_ext_complaint (name);
}
if (!ECOFF_IN_ELF (cur_bfd))
- record_minimal_symbol (name, svalue, ms_type, ext_in->asym.sc,
+ record_minimal_symbol (reader, name, svalue, ms_type, ext_in->asym.sc,
objfile);
}
if (sh.st == stStaticProc)
{
namestring = debug_info->ss + fh->issBase + sh.iss;
- record_minimal_symbol (namestring, sh.value,
+ record_minimal_symbol (reader, namestring, sh.value,
mst_file_text, sh.sc,
objfile);
}
case scPData:
case scXData:
namestring = debug_info->ss + fh->issBase + sh.iss;
- record_minimal_symbol (namestring, sh.value,
+ record_minimal_symbol (reader, namestring, sh.value,
mst_file_data, sh.sc,
objfile);
sh.value += ANOFFSET (objfile->section_offsets,
/* FIXME! Shouldn't this use cases for bss,
then have the default be abs? */
namestring = debug_info->ss + fh->issBase + sh.iss;
- record_minimal_symbol (namestring, sh.value,
+ record_minimal_symbol (reader, namestring, sh.value,
mst_file_bss, sh.sc,
objfile);
sh.value += ANOFFSET (objfile->section_offsets,
int new_sdx;
case stStaticProc:
- prim_record_minimal_symbol_and_info (name, minsym_value,
- mst_file_text,
- SECT_OFF_TEXT (objfile),
- objfile);
+ reader.record_with_info (name, minsym_value,
+ mst_file_text,
+ SECT_OFF_TEXT (objfile));
/* FALLTHROUGH */
case stStatic: /* Variable */
if (SC_IS_DATA (sh.sc))
- prim_record_minimal_symbol_and_info (name, minsym_value,
- mst_file_data,
- SECT_OFF_DATA (objfile),
- objfile);
+ reader.record_with_info (name, minsym_value,
+ mst_file_data,
+ SECT_OFF_DATA (objfile));
else
- prim_record_minimal_symbol_and_info (name, minsym_value,
- mst_file_bss,
- SECT_OFF_BSS (objfile),
- objfile);
+ reader.record_with_info (name, minsym_value,
+ mst_file_bss,
+ SECT_OFF_BSS (objfile));
theclass = LOC_STATIC;
break;
error (_("Error reading ECOFF debugging information: %s"),
bfd_errmsg (bfd_get_error ()));
- mdebug_build_psymtabs (objfile, swap, info);
+ mdebug_build_psymtabs (reader, objfile, swap, info);
reader.install ();
}
struct minimal_symbol contents[BUNCH_SIZE];
};
-/* Bunch currently being filled up.
- The next field points to chain of filled bunches. */
-
-static struct msym_bunch *msym_bunch;
-
-/* Number of slots filled in current bunch. */
-
-static int msym_bunch_index;
-
-/* Total number of minimal symbols recorded so far for the objfile. */
-
-static int msym_count;
-
/* See minsyms.h. */
unsigned int
/* See minsyms.h. */
minimal_symbol_reader::minimal_symbol_reader (struct objfile *obj)
-: m_objfile (obj)
-{
- msym_count = 0;
- msym_bunch = NULL;
- /* Note that presetting msym_bunch_index to BUNCH_SIZE causes the
+: m_objfile (obj),
+ m_msym_bunch (NULL),
+ /* Note that presetting m_msym_bunch_index to BUNCH_SIZE causes the
first call to save a minimal symbol to allocate the memory for
the first bunch. */
- msym_bunch_index = BUNCH_SIZE;
+ m_msym_bunch_index (BUNCH_SIZE),
+ m_msym_count (0)
+{
}
/* Discard the currently collected minimal symbols, if any. If we wish
{
struct msym_bunch *next;
- while (msym_bunch != NULL)
+ while (m_msym_bunch != NULL)
{
- next = msym_bunch->next;
- xfree (msym_bunch);
- msym_bunch = next;
+ next = m_msym_bunch->next;
+ xfree (m_msym_bunch);
+ m_msym_bunch = next;
}
}
/* See minsyms.h. */
void
-prim_record_minimal_symbol (const char *name, CORE_ADDR address,
- enum minimal_symbol_type ms_type,
- struct objfile *objfile)
+minimal_symbol_reader::record (const char *name, CORE_ADDR address,
+ enum minimal_symbol_type ms_type)
{
int section;
case mst_text_gnu_ifunc:
case mst_file_text:
case mst_solib_trampoline:
- section = SECT_OFF_TEXT (objfile);
+ section = SECT_OFF_TEXT (m_objfile);
break;
case mst_data:
case mst_file_data:
- section = SECT_OFF_DATA (objfile);
+ section = SECT_OFF_DATA (m_objfile);
break;
case mst_bss:
case mst_file_bss:
- section = SECT_OFF_BSS (objfile);
+ section = SECT_OFF_BSS (m_objfile);
break;
default:
section = -1;
}
- prim_record_minimal_symbol_and_info (name, address, ms_type,
- section, objfile);
+ record_with_info (name, address, ms_type, section);
}
/* See minsyms.h. */
struct minimal_symbol *
-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,
- struct objfile *objfile)
+minimal_symbol_reader::record_full (const char *name, int name_len,
+ int copy_name,
+ CORE_ADDR address,
+ enum minimal_symbol_type ms_type,
+ int section)
{
struct msym_bunch *newobj;
struct minimal_symbol *msymbol;
/* 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))
+ if (name[0] == get_symbol_leading_char (m_objfile->obfd))
{
++name;
--name_len;
if (ms_type == mst_file_text && startswith (name, "__gnu_compiled"))
return (NULL);
- if (msym_bunch_index == BUNCH_SIZE)
+ if (m_msym_bunch_index == BUNCH_SIZE)
{
newobj = XCNEW (struct msym_bunch);
- msym_bunch_index = 0;
- newobj->next = msym_bunch;
- msym_bunch = newobj;
+ m_msym_bunch_index = 0;
+ newobj->next = m_msym_bunch;
+ m_msym_bunch = newobj;
}
- msymbol = &msym_bunch->contents[msym_bunch_index];
+ msymbol = &m_msym_bunch->contents[m_msym_bunch_index];
MSYMBOL_SET_LANGUAGE (msymbol, language_auto,
- &objfile->per_bfd->storage_obstack);
- MSYMBOL_SET_NAMES (msymbol, name, name_len, copy_name, objfile);
+ &m_objfile->per_bfd->storage_obstack);
+ MSYMBOL_SET_NAMES (msymbol, name, name_len, copy_name, m_objfile);
SET_MSYMBOL_VALUE_ADDRESS (msymbol, address);
MSYMBOL_SECTION (msymbol) = section;
/* If we already read minimal symbols for this objfile, then don't
ever allocate a new one. */
- if (!objfile->per_bfd->minsyms_read)
+ if (!m_objfile->per_bfd->minsyms_read)
{
- msym_bunch_index++;
- objfile->per_bfd->n_minsyms++;
+ m_msym_bunch_index++;
+ m_objfile->per_bfd->n_minsyms++;
}
- msym_count++;
+ m_msym_count++;
return msymbol;
}
-/* See minsyms.h. */
-
-struct minimal_symbol *
-prim_record_minimal_symbol_and_info (const char *name, CORE_ADDR address,
- enum minimal_symbol_type ms_type,
- int section,
- struct objfile *objfile)
-{
- return prim_record_minimal_symbol_full (name, strlen (name), 1,
- address, ms_type,
- 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 (m_objfile->per_bfd->minsyms_read)
return;
- if (msym_count > 0)
+ if (m_msym_count > 0)
{
if (symtab_create_debug)
{
fprintf_unfiltered (gdb_stdlog,
"Installing %d minimal symbols of objfile %s.\n",
- msym_count, objfile_name (m_objfile));
+ m_msym_count, objfile_name (m_objfile));
}
/* Allocate enough space in the obstack, into which we will gather the
compact out the duplicate entries. Once we have a final table,
we will give back the excess space. */
- alloc_count = msym_count + m_objfile->per_bfd->minimal_symbol_count + 1;
+ alloc_count = m_msym_count + m_objfile->per_bfd->minimal_symbol_count + 1;
obstack_blank (&m_objfile->per_bfd->storage_obstack,
alloc_count * sizeof (struct minimal_symbol));
msymbols = (struct minimal_symbol *)
mcount = m_objfile->per_bfd->minimal_symbol_count;
- for (bunch = msym_bunch; bunch != NULL; bunch = bunch->next)
+ for (bunch = m_msym_bunch; bunch != NULL; bunch = bunch->next)
{
- for (bindex = 0; bindex < msym_bunch_index; bindex++, mcount++)
+ for (bindex = 0; bindex < m_msym_bunch_index; bindex++, mcount++)
msymbols[mcount] = bunch->contents[bindex];
- msym_bunch_index = BUNCH_SIZE;
+ m_msym_bunch_index = BUNCH_SIZE;
}
/* Sort the minimal symbols by address. */
as opaque and use functions provided by minsyms.c to inspect them.
*/
+struct msym_bunch;
+
/* An RAII-based object that is used to record minimal symbols while
they are being read. */
class minimal_symbol_reader
{
public:
- /* Prepare to start collecting minimal symbols. This should be called
- by a symbol reader to initialize the minimal symbol module.
- Currently, minimal symbol table creation is not reentrant; it
- relies on global (static) variables in minsyms.c. */
+ /* Prepare to start collecting minimal symbols. This should be
+ called by a symbol reader to initialize the minimal symbol
+ module. */
explicit minimal_symbol_reader (struct objfile *);
void install ();
+ /* Record a new minimal symbol. This is the "full" entry point;
+ simpler convenience entry points are also provided below.
+
+ This returns a new minimal symbol. It is ok to modify the returned
+ minimal symbol (though generally not necessary). It is not ok,
+ though, to stash the pointer anywhere; as minimal symbols may be
+ moved after creation. The memory for the returned minimal symbol
+ is still owned by the minsyms.c code, and should not be freed.
+
+ Arguments are:
+
+ NAME - the symbol's name
+ NAME_LEN - the length of the name
+ COPY_NAME - if true, the minsym code must make a copy of NAME. If
+ false, then NAME must be NUL-terminated, and must have a lifetime
+ that is at least as long as OBJFILE's lifetime.
+ ADDRESS - the address of the symbol
+ MS_TYPE - the type of the symbol
+ SECTION - the symbol's section
+ appropriate obj_section for the minimal symbol. This can be NULL.
+ OBJFILE - the objfile associated with the minimal symbol. */
+
+ struct minimal_symbol *record_full (const char *name,
+ int name_len,
+ int copy_name,
+ CORE_ADDR address,
+ enum minimal_symbol_type ms_type,
+ int section);
+
+ /* Like record_full, but:
+ - uses strlen to compute NAME_LEN,
+ - passes COPY_NAME = 1,
+ - and passes a default SECTION, depending on the type
+
+ This variant does not return the new symbol. */
+
+ void record (const char *, CORE_ADDR, enum minimal_symbol_type);
+
+ /* Like record_full, but:
+ - uses strlen to compute NAME_LEN,
+ - passes COPY_NAME = 1. */
+
+ struct minimal_symbol *record_with_info (const char *name,
+ CORE_ADDR address,
+ enum minimal_symbol_type ms_type,
+ int section)
+ {
+ return record_full (name, strlen (name), 1, address, ms_type, section);
+ }
+
private:
/* No need for these. They are intentionally not defined anywhere. */
minimal_symbol_reader (const minimal_symbol_reader &);
struct objfile *m_objfile;
-};
-/* Record a new minimal symbol. This is the "full" entry point;
- simpler convenience entry points are also provided below.
-
- This returns a new minimal symbol. It is ok to modify the returned
- minimal symbol (though generally not necessary). It is not ok,
- though, to stash the pointer anywhere; as minimal symbols may be
- moved after creation. The memory for the returned minimal symbol
- is still owned by the minsyms.c code, and should not be freed.
-
- Arguments are:
-
- NAME - the symbol's name
- NAME_LEN - the length of the name
- COPY_NAME - if true, the minsym code must make a copy of NAME. If
- false, then NAME must be NUL-terminated, and must have a lifetime
- that is at least as long as OBJFILE's lifetime.
- ADDRESS - the address of the symbol
- MS_TYPE - the type of the symbol
- SECTION - the symbol's section
- appropriate obj_section for the minimal symbol. This can be NULL.
- OBJFILE - the objfile associated with the minimal symbol. */
-
-struct minimal_symbol *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,
- struct objfile *objfile);
-
-/* Like prim_record_minimal_symbol_full, but:
- - uses strlen to compute NAME_LEN,
- - passes COPY_NAME = 1,
- - and passes a default SECTION, depending on the type
-
- This variant does not return the new symbol. */
+ /* Bunch currently being filled up.
+ The next field points to chain of filled bunches. */
-void prim_record_minimal_symbol (const char *, CORE_ADDR,
- enum minimal_symbol_type,
- struct objfile *);
+ struct msym_bunch *m_msym_bunch;
-/* Like prim_record_minimal_symbol_full, but:
- - uses strlen to compute NAME_LEN,
- - passes COPY_NAME = 1. */
+ /* Number of slots filled in current bunch. */
-struct minimal_symbol *prim_record_minimal_symbol_and_info
- (const char *,
- CORE_ADDR,
- enum minimal_symbol_type,
- int section,
- struct objfile *);
+ int m_msym_bunch_index;
+
+ /* Total number of minimal symbols recorded so far for the
+ objfile. */
+
+ int m_msym_count;
+};
/* Create the terminating entry of OBJFILE's minimal symbol table.
If OBJFILE->msymbols is zero, allocate a single entry from
#include "psymtab.h"
static void
-read_alphacoff_dynamic_symtab (struct section_offsets *,
+read_alphacoff_dynamic_symtab (minimal_symbol_reader &,
+ struct section_offsets *,
struct objfile *objfile);
/* Initialize anything that needs initializing when a completely new
(abfd, (asection *) NULL, &ecoff_data (abfd)->debug_info)))
error (_("Error reading symbol table: %s"), bfd_errmsg (bfd_get_error ()));
- mdebug_build_psymtabs (objfile, &ecoff_backend (abfd)->debug_swap,
+ mdebug_build_psymtabs (reader, objfile, &ecoff_backend (abfd)->debug_swap,
&ecoff_data (abfd)->debug_info);
/* Add alpha coff dynamic symbols. */
- read_alphacoff_dynamic_symtab (objfile->section_offsets, objfile);
+ read_alphacoff_dynamic_symtab (reader, objfile->section_offsets, objfile);
/* Install any minimal symbols that have been collected as the current
minimal symbols for this objfile. */
them to the minimal symbol table. */
static void
-read_alphacoff_dynamic_symtab (struct section_offsets *section_offsets,
+read_alphacoff_dynamic_symtab (minimal_symbol_reader &reader,
+ struct section_offsets *section_offsets,
struct objfile *objfile)
{
bfd *abfd = objfile->obfd;
}
}
- prim_record_minimal_symbol (name, sym_value, ms_type, objfile);
+ reader.record (name, sym_value, ms_type);
}
do_cleanups (cleanups);
/* From mdebugread.c */
-extern void mdebug_build_psymtabs (struct objfile *,
+extern void mdebug_build_psymtabs (minimal_symbol_reader &,
+ struct objfile *,
const struct ecoff_debug_swap *,
struct ecoff_debug_info *);
static void xcoff_initial_scan (struct objfile *, int);
-static void scan_xcoff_symtab (struct objfile *);
+static void scan_xcoff_symtab (minimal_symbol_reader &,
+ struct objfile *);
static char *xcoff_next_symbol_text (struct objfile *);
This function can read past the end of the symbol table
(into the string table) but this does no harm. */
-/* Create a new minimal symbol (using prim_record_minimal_symbol_and_info).
+/* Create a new minimal symbol (using record_with_info).
Creation of all new minimal symbols should go through this function
- rather than calling the various prim_record_[...] functions in order
+ rather than calling the various record functions in order
to make sure that all symbol addresses get properly relocated.
Arguments are:
OBJFILE - the objfile associated with the minimal symbol. */
static void
-record_minimal_symbol (const char *name, CORE_ADDR address,
+record_minimal_symbol (minimal_symbol_reader &reader,
+ const char *name, CORE_ADDR address,
enum minimal_symbol_type ms_type,
int n_scnum,
struct objfile *objfile)
{
-
if (name[0] == '.')
++name;
- prim_record_minimal_symbol_and_info (name, address, ms_type,
- secnum_to_section (n_scnum, objfile),
- objfile);
+ reader.record_with_info (name, address, ms_type,
+ secnum_to_section (n_scnum, objfile));
}
/* xcoff has static blocks marked in `.bs', `.es' pairs. They cannot be
}
static void
-scan_xcoff_symtab (struct objfile *objfile)
+scan_xcoff_symtab (minimal_symbol_reader &reader,
+ struct objfile *objfile)
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
CORE_ADDR toc_offset = 0; /* toc offset value in data section. */
if (!misc_func_recorded)
{
record_minimal_symbol
- (last_csect_name, last_csect_val,
+ (reader, last_csect_name, last_csect_val,
mst_text, last_csect_sec, objfile);
misc_func_recorded = 1;
}
table, except for section symbols. */
if (*namestring != '.')
record_minimal_symbol
- (namestring, symbol.n_value,
+ (reader, namestring, symbol.n_value,
sclass == C_HIDEXT ? mst_file_data : mst_data,
symbol.n_scnum, objfile);
break;
main_aux[0].x_sym.x_fcnary.x_fcn.x_lnnoptr;
record_minimal_symbol
- (namestring, symbol.n_value,
+ (reader, namestring, symbol.n_value,
sclass == C_HIDEXT ? mst_file_text : mst_text,
symbol.n_scnum, objfile);
misc_func_recorded = 1;
symbols, we will choose mst_text over
mst_solib_trampoline. */
record_minimal_symbol
- (namestring, symbol.n_value,
+ (reader, namestring, symbol.n_value,
mst_solib_trampoline, symbol.n_scnum, objfile);
misc_func_recorded = 1;
break;
XMC_BS might be possible too. */
if (*namestring != '.')
record_minimal_symbol
- (namestring, symbol.n_value,
+ (reader, namestring, symbol.n_value,
sclass == C_HIDEXT ? mst_file_data : mst_data,
symbol.n_scnum, objfile);
break;
table, except for section symbols. */
if (*namestring != '.')
record_minimal_symbol
- (namestring, symbol.n_value,
+ (reader, namestring, symbol.n_value,
sclass == C_HIDEXT ? mst_file_bss : mst_bss,
symbol.n_scnum, objfile);
break;
it as a function. This will take care of functions like
strcmp() compiled by xlc. */
- record_minimal_symbol (last_csect_name, last_csect_val,
+ record_minimal_symbol (reader, last_csect_name, last_csect_val,
mst_text, last_csect_sec, objfile);
misc_func_recorded = 1;
}
/* Now that the symbol table data of the executable file are all in core,
process them and define symbols accordingly. */
- scan_xcoff_symtab (objfile);
+ scan_xcoff_symtab (reader, objfile);
/* Install any minimal symbols that have been collected as the current
minimal symbols for this objfile. */