aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2013-09-25 22:48:19 +0000
committerDoug Evans <dje@google.com>2013-09-25 22:48:19 +0000
commitc256e171654791e456088ccb4c83d183650d8940 (patch)
treef71a1f5875963eb8eff25aefb51e2fcb454128c4
parentf56ce88372c4b5848638bab8b10b71042725a100 (diff)
downloadgdb-c256e171654791e456088ccb4c83d183650d8940.zip
gdb-c256e171654791e456088ccb4c83d183650d8940.tar.gz
gdb-c256e171654791e456088ccb4c83d183650d8940.tar.bz2
* 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.
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/coffread.c3
-rw-r--r--gdb/dbxread.c3
-rw-r--r--gdb/elfread.c5
-rw-r--r--gdb/machoread.c4
-rw-r--r--gdb/mipsread.c3
-rw-r--r--gdb/somread.c3
-rw-r--r--gdb/symfile.c36
-rw-r--r--gdb/symfile.h8
-rw-r--r--gdb/xcoffread.c4
10 files changed, 41 insertions, 37 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9830d8b..4265e3b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/coffread.c b/gdb/coffread.c
index e515167..959e96a 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 8188718..2bca65b 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 1f9224a..3f6fbd9 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 78af2f6..69a234c 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 b425780..fc4a268 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 6c6cc14..c262196 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 9f76c5e..9bb3c55 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 11cb371..8e5909b 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 17c45b9..7f34ac9 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);