* symfile.h (struct sym_fns): Delete member "sym_flavour".

All uses updated.
	(add_symtab_fns): Update prototype.
	* symfile.c (sym_fns_ptr): Delete.  Replace with ...
	(registered_sym_fns): ... this.
	(symtab_fns): Update.
	(add_symtab_fns): New arg "flavour".  All callers updated.
	(find_sym_fns): Rewrite to use new sym_fns registry.
This commit is contained in:
Doug Evans 2013-09-25 22:48:19 +00:00
parent f56ce88372
commit c256e17165
10 changed files with 41 additions and 37 deletions

View file

@ -1,5 +1,14 @@
2013-09-25 Doug Evans <dje@google.com>
* symfile.h (struct sym_fns): Delete member "sym_flavour".
All uses updated.
(add_symtab_fns): Update prototype.
* symfile.c (sym_fns_ptr): Delete. Replace with ...
(registered_sym_fns): ... this.
(symtab_fns): Update.
(add_symtab_fns): New arg "flavour". All callers updated.
(find_sym_fns): Rewrite to use new sym_fns registry.
* symfile.h (struct sym_fns): Add "objfile" argument to
sym_read_linetable. All uses updated.

View file

@ -2250,7 +2250,6 @@ coff_read_enum_type (int index, int length, int lastsym,
static const struct sym_fns coff_sym_fns =
{
bfd_target_coff_flavour,
coff_new_init, /* sym_new_init: init anything gbl to
entire symtab */
coff_symfile_init, /* sym_init: read initial info, setup
@ -2283,7 +2282,7 @@ coff_free_info (struct objfile *objfile, void *arg)
void
_initialize_coffread (void)
{
add_symtab_fns (&coff_sym_fns);
add_symtab_fns (bfd_target_coff_flavour, &coff_sym_fns);
coff_objfile_data_key = register_objfile_data_with_cleanup (NULL,
coff_free_info);

View file

@ -3564,7 +3564,6 @@ stabsect_build_psymtabs (struct objfile *objfile, char *stab_name,
static const struct sym_fns aout_sym_fns =
{
bfd_target_aout_flavour,
dbx_new_init, /* init anything gbl to entire symtab */
dbx_symfile_init, /* read initial info, setup for sym_read() */
dbx_symfile_read, /* read a symbol file into symtab */
@ -3581,7 +3580,7 @@ static const struct sym_fns aout_sym_fns =
void
_initialize_dbxread (void)
{
add_symtab_fns (&aout_sym_fns);
add_symtab_fns (bfd_target_aout_flavour, &aout_sym_fns);
dbx_objfile_data_key
= register_objfile_data_with_cleanup (NULL, dbx_free_symfile_info);

View file

@ -1721,7 +1721,6 @@ static const struct sym_probe_fns elf_probe_fns =
static const struct sym_fns elf_sym_fns =
{
bfd_target_elf_flavour,
elf_new_init, /* init anything gbl to entire symtab */
elf_symfile_init, /* read initial info, setup for sym_read() */
elf_symfile_read, /* read a symbol file into symtab */
@ -1740,7 +1739,6 @@ static const struct sym_fns elf_sym_fns =
static const struct sym_fns elf_sym_fns_lazy_psyms =
{
bfd_target_elf_flavour,
elf_new_init, /* init anything gbl to entire symtab */
elf_symfile_init, /* read initial info, setup for sym_read() */
elf_symfile_read, /* read a symbol file into symtab */
@ -1758,7 +1756,6 @@ static const struct sym_fns elf_sym_fns_lazy_psyms =
DWARF-specific GNU index rather than psymtab. */
static const struct sym_fns elf_sym_fns_gdb_index =
{
bfd_target_elf_flavour,
elf_new_init, /* init anything gbl to entire symab */
elf_symfile_init, /* read initial info, setup for sym_red() */
elf_symfile_read, /* read a symbol file into symtab */
@ -1786,7 +1783,7 @@ void
_initialize_elfread (void)
{
probe_key = register_objfile_data_with_cleanup (NULL, probe_key_free);
add_symtab_fns (&elf_sym_fns);
add_symtab_fns (bfd_target_elf_flavour, &elf_sym_fns);
elf_objfile_gnu_ifunc_cache_data = register_objfile_data ();
gnu_ifunc_fns_p = &elf_gnu_ifunc_fns;

View file

@ -1029,8 +1029,6 @@ macho_symfile_offsets (struct objfile *objfile,
}
static const struct sym_fns macho_sym_fns = {
bfd_target_mach_o_flavour,
macho_new_init, /* init anything gbl to entire symtab */
macho_symfile_init, /* read initial info, setup for sym_read() */
macho_symfile_read, /* read a symbol file into symtab */
@ -1050,7 +1048,7 @@ extern initialize_file_ftype _initialize_machoread;
void
_initialize_machoread (void)
{
add_symtab_fns (&macho_sym_fns);
add_symtab_fns (bfd_target_mach_o_flavour, &macho_sym_fns);
add_setshow_zuinteger_cmd ("mach-o", class_obscure,
&mach_o_debug_level,

View file

@ -405,7 +405,6 @@ read_alphacoff_dynamic_symtab (struct section_offsets *section_offsets,
static const struct sym_fns ecoff_sym_fns =
{
bfd_target_ecoff_flavour,
mipscoff_new_init, /* init anything gbl to entire symtab */
mipscoff_symfile_init, /* read initial info, setup for sym_read() */
mipscoff_symfile_read, /* read a symbol file into symtab */
@ -425,5 +424,5 @@ void _initialize_mipsread (void);
void
_initialize_mipsread (void)
{
add_symtab_fns (&ecoff_sym_fns);
add_symtab_fns (bfd_target_ecoff_flavour, &ecoff_sym_fns);
}

View file

@ -534,7 +534,6 @@ som_symfile_offsets (struct objfile *objfile,
static const struct sym_fns som_sym_fns =
{
bfd_target_som_flavour,
som_new_init, /* init anything gbl to entire symtab */
som_symfile_init, /* read initial info, setup for sym_read() */
som_symfile_read, /* read a symbol file into symtab */
@ -553,5 +552,5 @@ initialize_file_ftype _initialize_somread;
void
_initialize_somread (void)
{
add_symtab_fns (&som_sym_fns);
add_symtab_fns (bfd_target_som_flavour, &som_sym_fns);
}

View file

@ -130,10 +130,18 @@ void _initialize_symfile (void);
calls add_symtab_fns() to register information on each format it is
prepared to read. */
typedef const struct sym_fns *sym_fns_ptr;
DEF_VEC_P (sym_fns_ptr);
typedef struct
{
/* BFD flavour that we handle. */
enum bfd_flavour sym_flavour;
static VEC (sym_fns_ptr) *symtab_fns = NULL;
/* The "vtable" of symbol functions. */
const struct sym_fns *sym_fns;
} registered_sym_fns;
DEF_VEC_O (registered_sym_fns);
static VEC (registered_sym_fns) *symtab_fns = NULL;
/* If non-zero, shared library symbols will be added automatically
when the inferior is created, new libraries are loaded, or when
@ -1746,14 +1754,18 @@ get_section_index (struct objfile *objfile, char *section_name)
return -1;
}
/* Link SF into the global symtab_fns list. Called on startup by the
_initialize routine in each object file format reader, to register
information about each format the reader is prepared to handle. */
/* Link SF into the global symtab_fns list.
FLAVOUR is the file format that SF handles.
Called on startup by the _initialize routine in each object file format
reader, to register information about each format the reader is prepared
to handle. */
void
add_symtab_fns (const struct sym_fns *sf)
add_symtab_fns (enum bfd_flavour flavour, const struct sym_fns *sf)
{
VEC_safe_push (sym_fns_ptr, symtab_fns, sf);
registered_sym_fns fns = { flavour, sf };
VEC_safe_push (registered_sym_fns, symtab_fns, &fns);
}
/* Initialize OBJFILE to read symbols from its associated BFD. It
@ -1764,7 +1776,7 @@ add_symtab_fns (const struct sym_fns *sf)
static const struct sym_fns *
find_sym_fns (bfd *abfd)
{
const struct sym_fns *sf;
registered_sym_fns *rsf;
enum bfd_flavour our_flavour = bfd_get_flavour (abfd);
int i;
@ -1773,9 +1785,9 @@ find_sym_fns (bfd *abfd)
|| our_flavour == bfd_target_tekhex_flavour)
return NULL; /* No symbols. */
for (i = 0; VEC_iterate (sym_fns_ptr, symtab_fns, i, sf); ++i)
if (our_flavour == sf->sym_flavour)
return sf;
for (i = 0; VEC_iterate (registered_sym_fns, symtab_fns, i, rsf); ++i)
if (our_flavour == rsf->sym_flavour)
return rsf->sym_fns;
error (_("I'm sorry, Dave, I can't do that. Symbol format `%s' unknown."),
bfd_get_target (abfd));

View file

@ -350,12 +350,6 @@ struct sym_probe_fns
struct sym_fns
{
/* BFD flavour that we handle, or (as a special kludge, see
xcoffread.c, (enum bfd_flavour)-1 for xcoff). */
enum bfd_flavour sym_flavour;
/* Initializes anything that is global to the entire symbol table.
It is called during symbol_file_add, when we begin debugging an
entirely new program. */
@ -454,7 +448,7 @@ extern bfd_byte *default_symfile_relocate (struct objfile *objfile,
extern struct symtab *allocate_symtab (const char *, struct objfile *)
ATTRIBUTE_NONNULL (1);
extern void add_symtab_fns (const struct sym_fns *);
extern void add_symtab_fns (enum bfd_flavour flavour, const struct sym_fns *);
/* This enum encodes bit-flags passed as ADD_FLAGS parameter to
symbol_file_add, etc. */

View file

@ -3104,8 +3104,6 @@ static const struct sym_fns xcoff_sym_fns =
xcoffread.c reads all the symbols and does in fact randomly access them
(in C_BSTAT and line number processing). */
bfd_target_xcoff_flavour,
xcoff_new_init, /* init anything gbl to entire symtab */
xcoff_symfile_init, /* read initial info, setup for sym_read() */
xcoff_initial_scan, /* read a symbol file into symtab */
@ -3194,7 +3192,7 @@ extern initialize_file_ftype _initialize_xcoffread;
void
_initialize_xcoffread (void)
{
add_symtab_fns (&xcoff_sym_fns);
add_symtab_fns (bfd_target_xcoff_flavour, &xcoff_sym_fns);
xcoff_objfile_data_key = register_objfile_data_with_cleanup (NULL,
xcoff_free_info);