From c256e171654791e456088ccb4c83d183650d8940 Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Wed, 25 Sep 2013 22:48:19 +0000 Subject: [PATCH] * 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. --- gdb/ChangeLog | 9 +++++++++ gdb/coffread.c | 3 +-- gdb/dbxread.c | 3 +-- gdb/elfread.c | 5 +---- gdb/machoread.c | 4 +--- gdb/mipsread.c | 3 +-- gdb/somread.c | 3 +-- gdb/symfile.c | 36 ++++++++++++++++++++++++------------ gdb/symfile.h | 8 +------- gdb/xcoffread.c | 4 +--- 10 files changed, 41 insertions(+), 37 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9830d8b6f60..4265e3b6d84 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,14 @@ 2013-09-25 Doug Evans + * 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. diff --git a/gdb/coffread.c b/gdb/coffread.c index e5151673979..959e96ac83d 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -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); diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 8188718130a..2bca65b2d73 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -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); diff --git a/gdb/elfread.c b/gdb/elfread.c index 1f9224a8aae..3f6fbd97f28 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -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; diff --git a/gdb/machoread.c b/gdb/machoread.c index 78af2f6e583..69a234cddf8 100644 --- a/gdb/machoread.c +++ b/gdb/machoread.c @@ -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, diff --git a/gdb/mipsread.c b/gdb/mipsread.c index b425780bbd2..fc4a268c313 100644 --- a/gdb/mipsread.c +++ b/gdb/mipsread.c @@ -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); } diff --git a/gdb/somread.c b/gdb/somread.c index 6c6cc14c117..c262196e0cc 100644 --- a/gdb/somread.c +++ b/gdb/somread.c @@ -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); } diff --git a/gdb/symfile.c b/gdb/symfile.c index 9f76c5e0f1c..9bb3c55a057 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -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; + + /* 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 @@ -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)); diff --git a/gdb/symfile.h b/gdb/symfile.h index 11cb3719b94..8e5909bd8bc 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -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. */ diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 17c45b96bae..7f34ac92293 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -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); -- 2.30.2