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.
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.
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
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);
\f
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 */
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);
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 */
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 */
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 */
_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;
}
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 */
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,
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 */
void
_initialize_mipsread (void)
{
- add_symtab_fns (&ecoff_sym_fns);
+ add_symtab_fns (bfd_target_ecoff_flavour, &ecoff_sym_fns);
}
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 */
void
_initialize_somread (void)
{
- add_symtab_fns (&som_sym_fns);
+ add_symtab_fns (bfd_target_som_flavour, &som_sym_fns);
}
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;
+
+ /* The "vtable" of symbol functions. */
+ const struct sym_fns *sym_fns;
+} registered_sym_fns;
-static VEC (sym_fns_ptr) *symtab_fns = NULL;
+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
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
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;
|| 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));
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. */
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. */
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 */
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);