This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
FYI: sym_fns cleanup
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 30 Sep 2010 13:14:06 -0600
- Subject: FYI: sym_fns cleanup
I'm checking this in.
While doing other objfile work, I happened to notice that objfile::sf is
not a pointer-to-const.
This patch makes it const and updates all the users of this field, and
all the definitions of sym_fns objects.
Built and regtested on x86-64 (compile farm).
Tom
2010-09-30 Tom Tromey <tromey@redhat.com>
* symfile.h (struct sym_fns) <next>: Remove.
(add_symtab_fns): Update.
* symfile.c (sym_fns_ptr): New typedef.
(symtab_fns): Now a VEC.
(add_symtab_fns): Update. Change argument type.
(find_sym_fns): Update. Change return type.
(get_symfile_segment_data): Update.
* objfiles.h (struct objfile) <sf>: Now const.
* somread.c (som_sym_fns): Now const. Update.
* xcoffread.c (xcoff_sym_fns): Now const. Update.
* mipsread.c (ecoff_sym_fns): Now const. Update.
* machoread.c (macho_sym_fns): Now const. Update.
* elfread.c (elf_sym_fns): Now const. Update.
(elf_sym_fns_gdb_index): Likewise.
* dbxread.c (aout_sym_fns): Now const. Update.
* coffread.c (coff_sym_fns): Now const. Update.
Index: coffread.c
===================================================================
RCS file: /cvs/src/src/gdb/coffread.c,v
retrieving revision 1.110
diff -u -r1.110 coffread.c
--- coffread.c 10 Sep 2010 16:12:22 -0000 1.110
+++ coffread.c 30 Sep 2010 19:11:10 -0000
@@ -2126,7 +2126,7 @@
/* Register our ability to parse symbols for coff BFD files. */
-static struct sym_fns coff_sym_fns =
+static const struct sym_fns coff_sym_fns =
{
bfd_target_coff_flavour,
coff_new_init, /* sym_new_init: init anything gbl to entire symtab */
@@ -2138,8 +2138,7 @@
a file. */
NULL, /* sym_read_linetable */
default_symfile_relocate, /* sym_relocate: Relocate a debug section. */
- &psym_functions,
- NULL /* next: pointer to next struct sym_fns */
+ &psym_functions
};
void
Index: dbxread.c
===================================================================
RCS file: /cvs/src/src/gdb/dbxread.c,v
retrieving revision 1.116
diff -u -r1.116 dbxread.c
--- dbxread.c 14 May 2010 17:53:15 -0000 1.116
+++ dbxread.c 30 Sep 2010 19:11:11 -0000
@@ -3573,7 +3573,7 @@
dbx_symfile_read (objfile, 0);
}
-static struct sym_fns aout_sym_fns =
+static const struct sym_fns aout_sym_fns =
{
bfd_target_aout_flavour,
dbx_new_init, /* sym_new_init: init anything gbl to entire symtab */
@@ -3586,8 +3586,7 @@
a file. */
NULL, /* sym_read_linetable */
default_symfile_relocate, /* sym_relocate: Relocate a debug section. */
- &psym_functions,
- NULL /* next: pointer to next struct sym_fns */
+ &psym_functions
};
void
Index: elfread.c
===================================================================
RCS file: /cvs/src/src/gdb/elfread.c,v
retrieving revision 1.97
diff -u -r1.97 elfread.c
--- elfread.c 13 Jul 2010 20:51:33 -0000 1.97
+++ elfread.c 30 Sep 2010 19:11:11 -0000
@@ -41,7 +41,7 @@
extern void _initialize_elfread (void);
/* Forward declaration. */
-static struct sym_fns elf_sym_fns_gdb_index;
+static const struct sym_fns elf_sym_fns_gdb_index;
/* The struct elfinfo is available only during ELF symbol table and
psymtab reading. It is destroyed at the completion of psymtab-reading.
@@ -1034,7 +1034,7 @@
/* Register that we are able to handle ELF object file formats. */
-static struct sym_fns elf_sym_fns =
+static const struct sym_fns elf_sym_fns =
{
bfd_target_elf_flavour,
elf_new_init, /* sym_new_init: init anything gbl to entire symtab */
@@ -1046,13 +1046,12 @@
a file. */
NULL, /* sym_read_linetable */
default_symfile_relocate, /* sym_relocate: Relocate a debug section. */
- &psym_functions,
- NULL /* next: pointer to next struct sym_fns */
+ &psym_functions
};
/* The same as elf_sym_fns, but not registered and uses the
DWARF-specific GNU index rather than psymtab. */
-static struct sym_fns elf_sym_fns_gdb_index =
+static const struct sym_fns elf_sym_fns_gdb_index =
{
bfd_target_elf_flavour,
elf_new_init, /* sym_new_init: init anything gbl to entire symab */
@@ -1064,8 +1063,7 @@
a file. */
NULL, /* sym_read_linetable */
default_symfile_relocate, /* sym_relocate: Relocate a debug section. */
- &dwarf2_gdb_index_functions,
- NULL /* next: pointer to next struct sym_fns */
+ &dwarf2_gdb_index_functions
};
void
Index: machoread.c
===================================================================
RCS file: /cvs/src/src/gdb/machoread.c,v
retrieving revision 1.21
diff -u -r1.21 machoread.c
--- machoread.c 10 Mar 2010 18:20:06 -0000 1.21
+++ machoread.c 30 Sep 2010 19:11:11 -0000
@@ -837,7 +837,7 @@
}
}
-static struct sym_fns macho_sym_fns = {
+static const struct sym_fns macho_sym_fns = {
bfd_target_mach_o_flavour,
macho_new_init, /* sym_new_init: init anything gbl to entire symtab */
@@ -849,8 +849,7 @@
a file. */
NULL, /* sym_read_linetable */
macho_symfile_relocate, /* sym_relocate: Relocate a debug section. */
- &psym_functions,
- NULL /* next: pointer to next struct sym_fns */
+ &psym_functions
};
void
Index: mipsread.c
===================================================================
RCS file: /cvs/src/src/gdb/mipsread.c,v
retrieving revision 1.33
diff -u -r1.33 mipsread.c
--- mipsread.c 10 Mar 2010 18:20:06 -0000 1.33
+++ mipsread.c 30 Sep 2010 19:11:11 -0000
@@ -390,7 +390,7 @@
/* Initialization. */
-static struct sym_fns ecoff_sym_fns =
+static const struct sym_fns ecoff_sym_fns =
{
bfd_target_ecoff_flavour,
mipscoff_new_init, /* sym_new_init: init anything gbl to entire symtab */
@@ -402,8 +402,7 @@
a file. */
NULL, /* sym_read_linetable */
default_symfile_relocate, /* sym_relocate: Relocate a debug section. */
- &psym_functions,
- NULL /* next: pointer to next struct sym_fns */
+ &psym_functions
};
/* Provide a prototype to silence -Wmissing-prototypes. */
Index: objfiles.h
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.h,v
retrieving revision 1.76
diff -u -r1.76 objfiles.h
--- objfiles.h 24 Sep 2010 11:15:55 -0000 1.76
+++ objfiles.h 30 Sep 2010 19:11:11 -0000
@@ -293,7 +293,7 @@
allocated memory, and is shared by all objfiles that use the
object module reader of this type. */
- struct sym_fns *sf;
+ const struct sym_fns *sf;
/* The per-objfile information about the entry point, the scope (file/func)
containing the entry point, and the scope of the user's main() func. */
Index: somread.c
===================================================================
RCS file: /cvs/src/src/gdb/somread.c,v
retrieving revision 1.46
diff -u -r1.46 somread.c
--- somread.c 10 Mar 2010 18:20:06 -0000 1.46
+++ somread.c 30 Sep 2010 19:11:11 -0000
@@ -427,7 +427,7 @@
/* Register that we are able to handle SOM object file formats. */
-static struct sym_fns som_sym_fns =
+static const struct sym_fns som_sym_fns =
{
bfd_target_som_flavour,
som_new_init, /* sym_new_init: init anything gbl to entire symtab */
@@ -439,8 +439,7 @@
a file. */
NULL, /* sym_read_linetable */
default_symfile_relocate, /* sym_relocate: Relocate a debug section. */
- &psym_functions,
- NULL /* next: pointer to next struct sym_fns */
+ &psym_functions
};
void
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.295
diff -u -r1.295 symfile.c
--- symfile.c 31 Aug 2010 20:10:42 -0000 1.295
+++ symfile.c 30 Sep 2010 19:11:11 -0000
@@ -102,7 +102,7 @@
int get_section_index (struct objfile *, char *);
-static struct sym_fns *find_sym_fns (bfd *);
+static const struct sym_fns *find_sym_fns (bfd *);
static void decrement_reading_symtab (void *);
@@ -147,7 +147,10 @@
calls add_symtab_fns() to register information on each format it is
prepared to read. */
-static struct sym_fns *symtab_fns = NULL;
+typedef const struct sym_fns *sym_fns_ptr;
+DEF_VEC_P (sym_fns_ptr);
+
+static VEC (sym_fns_ptr) *symtab_fns = NULL;
/* Flag for whether user will be reloading symbols multiple times.
Defaults to ON for VxWorks, otherwise OFF. */
@@ -1702,10 +1705,9 @@
handle. */
void
-add_symtab_fns (struct sym_fns *sf)
+add_symtab_fns (const struct sym_fns *sf)
{
- sf->next = symtab_fns;
- symtab_fns = sf;
+ VEC_safe_push (sym_fns_ptr, symtab_fns, sf);
}
/* Initialize OBJFILE to read symbols from its associated BFD. It
@@ -1713,18 +1715,19 @@
struct sym_fns in the objfile structure, that contains cached
information about the symbol file. */
-static struct sym_fns *
+static const struct sym_fns *
find_sym_fns (bfd *abfd)
{
- struct sym_fns *sf;
+ const struct sym_fns *sf;
enum bfd_flavour our_flavour = bfd_get_flavour (abfd);
+ int i;
if (our_flavour == bfd_target_srec_flavour
|| our_flavour == bfd_target_ihex_flavour
|| our_flavour == bfd_target_tekhex_flavour)
return NULL; /* No symbols. */
- for (sf = symtab_fns; sf != NULL; sf = sf->next)
+ for (i = 0; VEC_iterate (sym_fns_ptr, symtab_fns, i, sf); ++i)
if (our_flavour == sf->sym_flavour)
return sf;
@@ -3587,7 +3590,7 @@
struct symfile_segment_data *
get_symfile_segment_data (bfd *abfd)
{
- struct sym_fns *sf = find_sym_fns (abfd);
+ const struct sym_fns *sf = find_sym_fns (abfd);
if (sf == NULL)
return NULL;
Index: symfile.h
===================================================================
RCS file: /cvs/src/src/gdb/symfile.h,v
retrieving revision 1.73
diff -u -r1.73 symfile.h
--- symfile.h 14 Sep 2010 22:50:30 -0000 1.73
+++ symfile.h 30 Sep 2010 19:11:11 -0000
@@ -345,14 +345,6 @@
/* The "quick" (aka partial) symbol functions for this symbol
reader. */
const struct quick_symbol_functions *qf;
-
- /* Finds the next struct sym_fns. They are allocated and
- initialized in whatever module implements the functions pointed
- to; an initializer calls add_symtab_fns to add them to the global
- chain. */
-
- struct sym_fns *next;
-
};
extern struct section_addr_info *
@@ -384,7 +376,7 @@
extern struct symtab *allocate_symtab (char *, struct objfile *);
-extern void add_symtab_fns (struct sym_fns *);
+extern void add_symtab_fns (const struct sym_fns *);
/* This enum encodes bit-flags passed as ADD_FLAGS parameter to
syms_from_objfile, symbol_file_add, etc. */
Index: xcoffread.c
===================================================================
RCS file: /cvs/src/src/gdb/xcoffread.c,v
retrieving revision 1.79
diff -u -r1.79 xcoffread.c
--- xcoffread.c 17 May 2010 18:48:51 -0000 1.79
+++ xcoffread.c 30 Sep 2010 19:11:12 -0000
@@ -3028,7 +3028,7 @@
/* Register our ability to parse symbols for xcoff BFD files. */
-static struct sym_fns xcoff_sym_fns =
+static const struct sym_fns xcoff_sym_fns =
{
/* It is possible that coff and xcoff should be merged as
@@ -3051,8 +3051,7 @@
a file. */
aix_process_linenos, /* sym_read_linetable */
default_symfile_relocate, /* sym_relocate: Relocate a debug section. */
- &psym_functions,
- NULL /* next: pointer to next struct sym_fns */
+ &psym_functions
};
/* Provide a prototype to silence -Wmissing-prototypes. */