/* Read coff symbol tables and convert to internal format, for GDB.
- Copyright (C) 1987-2015 Free Software Foundation, Inc.
+ Copyright (C) 1987-2018 Free Software Foundation, Inc.
Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu).
This file is part of GDB.
#include "psymtab.h"
#include "build-id.h"
-extern void _initialize_coffread (void);
-
/* Key for COFF-associated data. */
static const struct objfile_data *coff_objfile_data_key;
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
NULL,
/* The start address is irrelevant, since we set
last_source_start_addr in coff_end_symtab. */
- 0);
+ 0,
+ /* Let buildsym.c deduce the language for this symtab. */
+ language_unknown);
record_debugformat ("COFF");
}
}
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 ()
/* Read a symbol file, after initialization by coff_symfile_init. */
static void
-coff_symfile_read (struct objfile *objfile, int symfile_flags)
+coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
struct coff_symfile_info *info;
- struct dbx_symfile_info *dbxinfo;
bfd *abfd = objfile->obfd;
coff_data_type *cdata = coff_data (abfd);
char *name = bfd_get_filename (abfd);
unsigned int num_symbols;
int symtab_offset;
int stringtab_offset;
- struct cleanup *back_to, *cleanup_minimal_symbols;
+ struct cleanup *back_to;
int stabstrsize;
- info = objfile_data (objfile, coff_objfile_data_key);
- dbxinfo = DBX_SYMFILE_INFO (objfile);
+ info = (struct coff_symfile_info *) objfile_data (objfile,
+ coff_objfile_data_key);
symfile_bfd = abfd; /* Kludge for swap routines. */
/* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */
if (val < 0)
error (_("\"%s\": can't get string table"), name);
- init_minimal_symbol_collection ();
- cleanup_minimal_symbols = make_cleanup_discard_minimal_symbols ();
+ minimal_symbol_reader reader (objfile);
/* 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. */
- install_minimal_symbols (objfile);
+ reader.install ();
if (pe_file)
{
}
}
- /* Free the installed minimal symbol data. */
- do_cleanups (cleanup_minimal_symbols);
-
- bfd_map_over_sections (abfd, coff_locate_sections, (void *) info);
+ if (!(objfile->flags & OBJF_READNEVER))
+ bfd_map_over_sections (abfd, coff_locate_sections, (void *) info);
if (info->stabsects)
{
/* Try to add separate debug file if no symbols table found. */
if (!objfile_has_partial_symbols (objfile))
{
- char *debugfile;
-
- debugfile = find_separate_debug_file_by_buildid (objfile);
+ std::string debugfile = find_separate_debug_file_by_buildid (objfile);
- if (debugfile == NULL)
+ if (debugfile.empty ())
debugfile = find_separate_debug_file_by_debuglink (objfile);
- make_cleanup (xfree, debugfile);
- if (debugfile)
+ if (!debugfile.empty ())
{
- bfd *abfd = symfile_bfd_open (debugfile);
+ gdb_bfd_ref_ptr abfd (symfile_bfd_open (debugfile.c_str ()));
- make_cleanup_bfd_unref (abfd);
- symbol_file_add_separate (abfd, debugfile, symfile_flags, objfile);
+ symbol_file_add_separate (abfd.get (), debugfile.c_str (),
+ symfile_flags, 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;
backtraces, so filter them out (from phdm@macqel.be). */
if (within_function)
break;
+ /* Fall through. */
case C_STAT:
case C_THUMBLABEL:
case C_THUMBSTAT:
/* At least on a 3b1, gcc generates swbeg and string labels
that look like this. Ignore them. */
break;
- /* Fall in for static symbols that don't start with '.' */
+ /* For static symbols that don't start with '.'... */
+ /* Fall through. */
case C_THUMBEXT:
case C_THUMBEXTFUNC:
case C_EXT:
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 ())