aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Fish <fnf@specifix.com>1992-03-19 21:57:15 +0000
committerFred Fish <fnf@specifix.com>1992-03-19 21:57:15 +0000
commit80d68b1d49a92b6ea0b5b79d9be413f0002ae200 (patch)
tree6a042b0583d1b178e375b6288dc7d2811c763d90
parentdc52fc71183fc32594388a619c4fa55e83648ced (diff)
downloadfsf-binutils-gdb-80d68b1d49a92b6ea0b5b79d9be413f0002ae200.zip
fsf-binutils-gdb-80d68b1d49a92b6ea0b5b79d9be413f0002ae200.tar.gz
fsf-binutils-gdb-80d68b1d49a92b6ea0b5b79d9be413f0002ae200.tar.bz2
* coffread.c, mipsread.c, xcoffread.c, coffread.c, dbxread.c,
elfread.c (coff_symfile_finish): Add function, prototype, and add to the xxxx_sym_fns struct for each file type. Also reformat the xxxx_sym_fns vector to a standard format and add comments. * coffread.c, mipsread.c, xcoffread.c, coffread.c, dbxread.c, elfread.c (xxx_symfile_new_init, xxx_symfile_init, xxx_symfile_read): Pass pointer to struct objfile rather than pointer to sym_fns. Change references inside each function accordingly. Allocate any symbol file specific info in the per-objfile memory region. * dbxread.c (free_and_init_header_files): Break function into free_header_files(), called from dbx_symfile_finish(), and init_header_files(), called from dbx_new_init(). * dbxread.c (dbx_new_init): Move deallocation things to new dbx_symfile_finish function. * elfread.c (elf_new_init): Call buildsym_new_init(). * objfiles.c (free_objfile): Call the appropriate symfile_finish() routine for the objfile before deallocating other stuff. * sparc-tdep.c (get_longjmp_target): Cast target_read_memory arg. * symfile.h: Move struct sym_fns to before struct objfile def. Add sym_finish function pointer and change prototypes of other function pointers to reflect passing struct objfile pointer rather than struct sym_fns pointer. * symfile.c: Remove now obsolete symtab_fns pointer. * symfile.c (symfile_init): Renamed to find_sym_fns, and now only locates the correct sym_fns struct for the given objfile. * symfile.c (syms_from_objfile, symbol_file_add): Restructured for better support of mapped symbol tables. * symfile.c (symbol_file_command): Remove obsolete code using symfile_fns. * symfile.h: Remove duplicate declarations for symfile_objfile, entry_point, and object_files. * target.c (target_info): Compare symfile_objfile to NULL. * xcoffread.c (aixcoff_new_init): Move deallocation stuff to aixcoff_symfile_finish().
-rw-r--r--gdb/ChangeLog37
-rw-r--r--gdb/coffread.c62
-rw-r--r--gdb/dbxread.c173
-rw-r--r--gdb/elfread.c50
-rw-r--r--gdb/mipsread.c64
-rw-r--r--gdb/objfiles.c17
-rw-r--r--gdb/symfile.c184
-rw-r--r--gdb/symfile.h147
-rw-r--r--gdb/target.c11
-rw-r--r--gdb/xcoffread.c85
10 files changed, 520 insertions, 310 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5347244..6fb9b11 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,40 @@
+Thu Mar 19 13:54:11 1992 Fred Fish (fnf@cygnus.com)
+
+ * coffread.c, mipsread.c, xcoffread.c, coffread.c, dbxread.c,
+ elfread.c (coff_symfile_finish): Add function, prototype, and
+ add to the xxxx_sym_fns struct for each file type. Also reformat
+ the xxxx_sym_fns vector to a standard format and add comments.
+ * coffread.c, mipsread.c, xcoffread.c, coffread.c, dbxread.c,
+ elfread.c (xxx_symfile_new_init, xxx_symfile_init, xxx_symfile_read):
+ Pass pointer to struct objfile rather than pointer to sym_fns.
+ Change references inside each function accordingly. Allocate any
+ symbol file specific info in the per-objfile memory region.
+ * dbxread.c (free_and_init_header_files): Break function into
+ free_header_files(), called from dbx_symfile_finish(), and
+ init_header_files(), called from dbx_new_init().
+ * dbxread.c (dbx_new_init): Move deallocation things to new
+ dbx_symfile_finish function.
+ * elfread.c (elf_new_init): Call buildsym_new_init().
+ * objfiles.c (free_objfile): Call the appropriate symfile_finish()
+ routine for the objfile before deallocating other stuff.
+ * sparc-tdep.c (get_longjmp_target): Cast target_read_memory arg.
+ * symfile.h: Move struct sym_fns to before struct objfile def.
+ Add sym_finish function pointer and change prototypes of other
+ function pointers to reflect passing struct objfile pointer rather
+ than struct sym_fns pointer.
+ * symfile.c: Remove now obsolete symtab_fns pointer.
+ * symfile.c (symfile_init): Renamed to find_sym_fns, and now only
+ locates the correct sym_fns struct for the given objfile.
+ * symfile.c (syms_from_objfile, symbol_file_add): Restructured
+ for better support of mapped symbol tables.
+ * symfile.c (symbol_file_command): Remove obsolete code using
+ symfile_fns.
+ * symfile.h: Remove duplicate declarations for symfile_objfile,
+ entry_point, and object_files.
+ * target.c (target_info): Compare symfile_objfile to NULL.
+ * xcoffread.c (aixcoff_new_init): Move deallocation stuff to
+ aixcoff_symfile_finish().
+
Wed Mar 18 18:22:46 1992 Fred Fish (fnf@cygnus.com)
* infrun.c (IN_SOLIB_TRAMPOLINE): Add default definition.
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 49a8000..2804508 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -254,16 +254,19 @@ static void
read_coff_symtab PARAMS ((int, int, struct objfile *));
static void
-coff_new_init PARAMS ((void));
+find_linenos PARAMS ((bfd *, sec_ptr, PTR));
static void
-coff_symfile_read PARAMS ((struct sym_fns *, CORE_ADDR, int));
+coff_symfile_init PARAMS ((struct objfile *));
static void
-find_linenos PARAMS ((bfd *, sec_ptr, PTR));
+coff_new_init PARAMS ((struct objfile *));
static void
-coff_symfile_init PARAMS ((struct sym_fns *));
+coff_symfile_read PARAMS ((struct objfile *, CORE_ADDR, int));
+
+static void
+coff_symfile_finish PARAMS ((struct objfile *));
static void
record_minimal_symbol PARAMS ((char *, CORE_ADDR));
@@ -655,15 +658,15 @@ struct coff_symfile_info {
static int text_bfd_scnum;
static void
-coff_symfile_init (sf)
- struct sym_fns *sf;
+coff_symfile_init (objfile)
+ struct objfile *objfile;
{
asection *section;
- bfd *abfd = sf->sym_bfd;
+ bfd *abfd = objfile->obfd;
/* Allocate struct to keep track of the symfile */
- /* FIXME memory leak */
- sf->sym_private = xmalloc (sizeof (struct coff_symfile_info));
+ objfile -> sym_private = xmmalloc (objfile -> md,
+ sizeof (struct coff_symfile_info));
/* Save startup file's range of PC addresses to help blockframe.c
decide where the bottom of the stack is. */
@@ -737,13 +740,13 @@ static bfd *symfile_bfd;
/* ARGSUSED */
static void
-coff_symfile_read (sf, addr, mainline)
- struct sym_fns *sf;
+coff_symfile_read (objfile, addr, mainline)
+ struct objfile *objfile;
CORE_ADDR addr;
int mainline;
{
- struct coff_symfile_info *info = (struct coff_symfile_info *)sf->sym_private;
- bfd *abfd = sf->objfile->obfd;
+ struct coff_symfile_info *info;
+ bfd *abfd = objfile->obfd;
coff_data_type *cdata = coff_data (abfd);
char *name = bfd_get_filename (abfd);
int desc;
@@ -752,6 +755,7 @@ coff_symfile_read (sf, addr, mainline)
int symtab_offset;
int stringtab_offset;
+ info = (struct coff_symfile_info *) objfile -> sym_private;
symfile_bfd = abfd; /* Kludge for swap routines */
/* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */
@@ -808,7 +812,7 @@ coff_symfile_read (sf, addr, mainline)
/* Now that the executable file is positioned at symbol table,
process it and define symbols accordingly. */
- read_coff_symtab (desc, num_symbols, sf->objfile);
+ read_coff_symtab (desc, num_symbols, objfile);
iterate_over_symtabs (patch_opaque_types, (PTR) NULL, (PTR) NULL,
(PTR) NULL);
@@ -820,14 +824,31 @@ coff_symfile_read (sf, addr, mainline)
/* Install any minimal symbols that have been collected as the current
minimal symbols for this objfile. */
- install_minimal_symbols (sf -> objfile);
+ install_minimal_symbols (objfile);
}
static void
-coff_new_init ()
+coff_new_init (objfile)
+ struct objfile *objfile;
{
/* Nothin' to do */
}
+
+/* Perform any local cleanups required when we are done with a particular
+ objfile. I.E, we are in the process of discarding all symbol information
+ for an objfile, freeing up all memory held for it, and unlinking the
+ objfile struct from the global list of known objfiles. */
+
+static void
+coff_symfile_finish (objfile)
+ struct objfile *objfile;
+{
+ if (objfile -> sym_private != NULL)
+ {
+ mfree (objfile -> md, objfile -> sym_private);
+ }
+}
+
/* Given pointers to a symbol table in coff style exec file,
analyze them and create struct symtab's describing the symbols.
@@ -2103,8 +2124,13 @@ coff_read_enum_type (index, length, lastsym)
static struct sym_fns coff_sym_fns =
{
- "coff", 4,
- coff_new_init, coff_symfile_init, coff_symfile_read,
+ "coff", /* sym_name: name or name prefix of BFD target type */
+ 4, /* sym_namelen: number of significant sym_name chars */
+ coff_new_init, /* sym_new_init: init anything gbl to entire symtab */
+ coff_symfile_init, /* sym_init: read initial info, setup for sym_read() */
+ coff_symfile_read, /* sym_read: read a symbol file into symtab */
+ coff_symfile_finish, /* sym_finish: finished with file, cleanup */
+ NULL /* next: pointer to next struct sym_fns */
};
void
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 1f86c8a..1650c8a 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -62,7 +62,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Information is passed among various dbxread routines for accessing
symbol files. A pointer to this structure is kept in the sym_private
- field of the struct sym_fns passed in by symfile.h. */
+ field of the objfile struct passed in by symfile.h. */
struct dbx_symfile_info {
asection *text_sect; /* Text section accessor */
@@ -182,7 +182,10 @@ static int bincls_allocated;
/* Local function prototypes */
static void
-free_and_init_header_files PARAMS ((void));
+free_header_files PARAMS ((void));
+
+static void
+init_header_files PARAMS ((void));
static struct pending *
copy_pending PARAMS ((struct pending *, int, struct pending *));
@@ -223,13 +226,16 @@ static void
fill_symbuf PARAMS ((bfd *));
static void
-dbx_symfile_init PARAMS ((struct sym_fns *));
+dbx_symfile_init PARAMS ((struct objfile *));
+
+static void
+dbx_new_init PARAMS ((struct objfile *));
static void
-dbx_new_init PARAMS ((void));
+dbx_symfile_read PARAMS ((struct objfile *, CORE_ADDR, int));
static void
-dbx_symfile_read PARAMS ((struct sym_fns *, CORE_ADDR, int));
+dbx_symfile_finish PARAMS ((struct objfile *));
static void
record_minimal_symbol PARAMS ((char *, CORE_ADDR, int, struct objfile *));
@@ -243,23 +249,41 @@ add_old_header_file PARAMS ((char *, int));
static void
add_this_object_header_file PARAMS ((int));
-/* Free up old header file tables, and allocate new ones.
- We're reading a new symbol file now. */
+/* Free up old header file tables */
static void
-free_and_init_header_files ()
+free_header_files ()
{
register int i;
- for (i = 0; i < n_header_files; i++)
- free (header_files[i].name);
- if (header_files) /* First time null */
- free (header_files);
- if (this_object_header_files) /* First time null */
- free (this_object_header_files);
- n_allocated_header_files = 10;
- header_files = (struct header_file *) xmalloc (10 * sizeof (struct header_file));
+ if (header_files != NULL)
+ {
+ for (i = 0; i < n_header_files; i++)
+ {
+ free (header_files[i].name);
+ }
+ free (header_files);
+ header_files = NULL;
+ n_header_files = 0;
+ }
+ if (this_object_header_files)
+ {
+ free (this_object_header_files);
+ this_object_header_files = NULL;
+ }
+ n_allocated_header_files = 0;
+ n_allocated_this_object_header_files = 0;
+}
+
+/* Allocate new header file tables */
+
+static void
+init_header_files ()
+{
n_header_files = 0;
+ n_allocated_header_files = 10;
+ header_files = (struct header_file *)
+ xmalloc (10 * sizeof (struct header_file));
n_allocated_this_object_header_files = 10;
this_object_header_files = (int *) xmalloc (10 * sizeof (int));
@@ -402,18 +426,20 @@ record_minimal_symbol (name, address, type, objfile)
table (as opposed to a shared lib or dynamically loaded file). */
static void
-dbx_symfile_read (sf, addr, mainline)
- struct sym_fns *sf;
+dbx_symfile_read (objfile, addr, mainline)
+ struct objfile *objfile;
CORE_ADDR addr;
int mainline; /* FIXME comments above */
{
- struct dbx_symfile_info *info = (struct dbx_symfile_info *) (sf->sym_private);
- bfd *sym_bfd = sf->objfile->obfd;
+ struct dbx_symfile_info *info;
+ bfd *sym_bfd;
int val;
- val = bfd_seek (sf->objfile->obfd, info->symtab_offset, L_SET);
+ sym_bfd = objfile->obfd;
+ info = (struct dbx_symfile_info *) (objfile -> sym_private);
+ val = bfd_seek (objfile->obfd, info->symtab_offset, L_SET);
if (val < 0)
- perror_with_name (sf->objfile->name);
+ perror_with_name (objfile->name);
/* If mainline, set global string table pointers, and reinitialize global
partial symbol list. */
@@ -423,8 +449,8 @@ dbx_symfile_read (sf, addr, mainline)
}
/* If we are reinitializing, or if we have never loaded syms yet, init */
- if (mainline || sf->objfile->global_psymbols.size == 0 || sf->objfile->static_psymbols.size == 0)
- init_psymbol_list (info->symcount, sf->objfile);
+ if (mainline || objfile->global_psymbols.size == 0 || objfile->static_psymbols.size == 0)
+ init_psymbol_list (info->symcount, objfile);
/* FIXME POKING INSIDE BFD DATA STRUCTURES */
symbol_size = obj_symbol_entry_size (sym_bfd);
@@ -439,7 +465,7 @@ dbx_symfile_read (sf, addr, mainline)
process them and define symbols accordingly. */
read_dbx_symtab (addr - bfd_section_vma (sym_bfd, info->text_sect), /*offset*/
- sf->objfile, info->stringtab, info->stringtab_size,
+ objfile, info->stringtab, info->stringtab_size,
info->symcount,
bfd_section_vma (sym_bfd, info->text_sect),
bfd_section_size (sym_bfd, info->text_sect));
@@ -447,16 +473,16 @@ dbx_symfile_read (sf, addr, mainline)
/* Install any minimal symbols that have been collected as the current
minimal symbols for this objfile. */
- install_minimal_symbols (sf -> objfile);
+ install_minimal_symbols (objfile);
/* Free up any memory we allocated for ourselves. */
if (!mainline) {
- mfree (sf->objfile->md, info->stringtab); /* Stringtab is only saved for mainline */
+ mfree (objfile->md, info->stringtab); /* Stringtab is only saved for mainline */
}
- mfree (sf->objfile->md, info);
- sf->sym_private = NULL; /* Zap pointer to our (now gone) info struct */
-
+ mfree (objfile->md, info);
+ /* Zap pointer to our (now gone) info struct */
+ objfile -> sym_private = NULL;
if (!have_partial_symbols ()) {
wrap_here ("");
printf_filtered ("(no debugging symbols found)...");
@@ -469,25 +495,17 @@ dbx_symfile_read (sf, addr, mainline)
file, e.g. a shared library). */
static void
-dbx_new_init ()
+dbx_new_init (objfile)
+ struct objfile *objfile;
{
buildsym_new_init ();
-
- /* Don't put these on the cleanup chain; they need to stick around
- until the next call to dbx_new_init. *Then* we'll free them. */
- if (symfile_string_table)
- {
- free (symfile_string_table);
- symfile_string_table = 0;
- symfile_string_table_size = 0;
- }
- free_and_init_header_files ();
+ init_header_files ();
}
/* dbx_symfile_init ()
is the dbx-specific initialization routine for reading symbols.
- It is passed a struct sym_fns which contains, among other things,
+ It is passed a struct objfile which contains, among other things,
the BFD for the file whose symbols are being read, and a slot for a pointer
to "private data" which we fill with goodies.
@@ -499,18 +517,18 @@ dbx_new_init ()
FIXME, there should be a cleaner peephole into the BFD environment here. */
static void
-dbx_symfile_init (sf)
- struct sym_fns *sf;
+dbx_symfile_init (objfile)
+ struct objfile *objfile;
{
int val;
- bfd *sym_bfd = sf->objfile->obfd;
+ bfd *sym_bfd = objfile->obfd;
char *name = bfd_get_filename (sym_bfd);
struct dbx_symfile_info *info;
unsigned char size_temp[4];
/* Allocate struct to keep track of the symfile */
- sf->sym_private = xmmalloc (sf->objfile->md, sizeof (*info));
- info = (struct dbx_symfile_info *)sf->sym_private;
+ objfile-> sym_private = xmmalloc (objfile -> md, sizeof (*info));
+ info = (struct dbx_symfile_info *) objfile -> sym_private;
/* FIXME POKING INSIDE BFD DATA STRUCTURES */
#define STRING_TABLE_OFFSET (sym_bfd->origin + obj_str_filepos (sym_bfd))
@@ -535,7 +553,7 @@ dbx_symfile_init (sf)
if (info->stringtab_size >= 0)
{
/* Yes, this should be malloc, not xmalloc. We check its result. */
- info->stringtab = (char *) mmalloc (sf->objfile->md, info->stringtab_size);
+ info->stringtab = (char *) mmalloc (objfile->md, info->stringtab_size);
/* Caller is responsible for freeing the string table. No cleanup. */
}
else
@@ -556,6 +574,29 @@ dbx_symfile_init (sf)
info->symtab_offset = SYMBOL_TABLE_OFFSET;
}
+
+/* Perform any local cleanups required when we are done with a particular
+ objfile. I.E, we are in the process of discarding all symbol information
+ for an objfile, freeing up all memory held for it, and unlinking the
+ objfile struct from the global list of known objfiles. */
+
+static void
+dbx_symfile_finish (objfile)
+ struct objfile *objfile;
+{
+ if (objfile -> sym_private != NULL)
+ {
+ mfree (objfile -> md, objfile -> sym_private);
+ }
+ if (symfile_string_table)
+ {
+ free (symfile_string_table);
+ symfile_string_table = 0;
+ symfile_string_table_size = 0;
+ }
+ free_header_files ();
+}
+
/* Buffer for reading the symbol table entries. */
static struct internal_nlist symbuf[4096];
@@ -1665,14 +1706,38 @@ copy_pending (beg, begi, end)
/* Register our willingness to decode symbols for SunOS and a.out and
b.out files handled by BFD... */
-static struct sym_fns sunos_sym_fns = {"sunOs", 6,
- dbx_new_init, dbx_symfile_init, dbx_symfile_read};
+static struct sym_fns sunos_sym_fns =
+{
+ "sunOs", /* sym_name: name or name prefix of BFD target type */
+ 6, /* sym_namelen: number of significant sym_name chars */
+ dbx_new_init, /* sym_new_init: init anything gbl to entire symtab */
+ dbx_symfile_init, /* sym_init: read initial info, setup for sym_read() */
+ dbx_symfile_read, /* sym_read: read a symbol file into symtab */
+ dbx_symfile_finish, /* sym_finish: finished with file, cleanup */
+ NULL /* next: pointer to next struct sym_fns */
+};
-static struct sym_fns aout_sym_fns = {"a.out", 5,
- dbx_new_init, dbx_symfile_init, dbx_symfile_read};
+static struct sym_fns aout_sym_fns =
+{
+ "a.out", /* sym_name: name or name prefix of BFD target type */
+ 5, /* sym_namelen: number of significant sym_name chars */
+ dbx_new_init, /* sym_new_init: init anything gbl to entire symtab */
+ dbx_symfile_init, /* sym_init: read initial info, setup for sym_read() */
+ dbx_symfile_read, /* sym_read: read a symbol file into symtab */
+ dbx_symfile_finish, /* sym_finish: finished with file, cleanup */
+ NULL /* next: pointer to next struct sym_fns */
+};
-static struct sym_fns bout_sym_fns = {"b.out", 5,
- dbx_new_init, dbx_symfile_init, dbx_symfile_read};
+static struct sym_fns bout_sym_fns =
+{
+ "b.out", /* sym_name: name or name prefix of BFD target type */
+ 5, /* sym_namelen: number of significant sym_name chars */
+ dbx_new_init, /* sym_new_init: init anything gbl to entire symtab */
+ dbx_symfile_init, /* sym_init: read initial info, setup for sym_read() */
+ dbx_symfile_read, /* sym_read: read a symbol file into symtab */
+ dbx_symfile_finish, /* sym_finish: finished with file, cleanup */
+ NULL /* next: pointer to next struct sym_fns */
+};
void
_initialize_dbxread ()
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 6a89778..f49916c 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -50,13 +50,16 @@ struct elfinfo {
};
static void
-elf_symfile_init PARAMS ((struct sym_fns *));
+elf_symfile_init PARAMS ((struct objfile *));
static void
-elf_new_init PARAMS ((void));
+elf_new_init PARAMS ((struct objfile *));
static void
-elf_symfile_read PARAMS ((struct sym_fns *, CORE_ADDR, int));
+elf_symfile_read PARAMS ((struct objfile *, CORE_ADDR, int));
+
+static void
+elf_symfile_finish PARAMS ((struct objfile *));
static void
elf_symtab_read PARAMS ((bfd *, CORE_ADDR, int, struct objfile *));
@@ -271,12 +274,12 @@ elf_symtab_read (abfd, addr, mainline, objfile)
*/
static void
-elf_symfile_read (sf, addr, mainline)
- struct sym_fns *sf;
+elf_symfile_read (objfile, addr, mainline)
+ struct objfile *objfile;
CORE_ADDR addr;
int mainline;
{
- bfd *abfd = sf->objfile->obfd;
+ bfd *abfd = objfile->obfd;
struct elfinfo ei;
struct cleanup *back_to;
@@ -285,7 +288,7 @@ elf_symfile_read (sf, addr, mainline)
/* Process the normal ELF symbol table first. */
- elf_symtab_read (abfd, addr, mainline, sf->objfile);
+ elf_symtab_read (abfd, addr, mainline, objfile);
/* Now process the DWARF debugging information, which is contained in
special ELF sections. We first have to find them... */
@@ -298,7 +301,7 @@ elf_symfile_read (sf, addr, mainline)
bfd_get_filename (abfd),
addr, mainline,
ei.dboffset, ei.dbsize,
- ei.lnoffset, ei.lnsize, sf->objfile);
+ ei.lnoffset, ei.lnsize, objfile);
}
if (!have_partial_symbols ())
@@ -311,7 +314,7 @@ elf_symfile_read (sf, addr, mainline)
/* Install any minimal symbols that have been collected as the current
minimal symbols for this objfile. */
- install_minimal_symbols (sf -> objfile);
+ install_minimal_symbols (objfile);
do_cleanups (back_to);
}
@@ -324,8 +327,25 @@ elf_symfile_read (sf, addr, mainline)
just a stub. */
static void
-elf_new_init ()
+elf_new_init (objfile)
+ struct objfile *objfile;
+{
+ buildsym_new_init ();
+}
+
+/* Perform any local cleanups required when we are done with a particular
+ objfile. I.E, we are in the process of discarding all symbol information
+ for an objfile, freeing up all memory held for it, and unlinking the
+ objfile struct from the global list of known objfiles. */
+
+static void
+elf_symfile_finish (objfile)
+ struct objfile *objfile;
{
+ if (objfile -> sym_private != NULL)
+ {
+ mfree (objfile -> md, objfile -> sym_private);
+ }
}
/* ELF specific initialization routine for reading symbols.
@@ -338,8 +358,8 @@ elf_new_init ()
just a stub. */
static void
-elf_symfile_init (sf)
- struct sym_fns *sf;
+elf_symfile_init (objfile)
+ struct objfile *objfile;
{
}
@@ -360,14 +380,14 @@ elf_symfile_init (sf)
use "elf" in the same sense as "a.out" or "coff", to imply both the ELF
object file format and the DWARF debugging format. */
-static struct sym_fns elf_sym_fns = {
+static struct sym_fns elf_sym_fns =
+{
"elf", /* sym_name: name or name prefix of BFD target type */
3, /* sym_namelen: number of significant sym_name chars */
elf_new_init, /* sym_new_init: init anything gbl to entire symtab */
elf_symfile_init, /* sym_init: read initial info, setup for sym_read() */
elf_symfile_read, /* sym_read: read a symbol file into symtab */
- NULL, /* sym_bfd: accessor for symbol file being read */
- NULL, /* sym_private: sym_init & sym_read shared info */
+ elf_symfile_finish, /* sym_finish: finished with file, cleanup */
NULL /* next: pointer to next struct sym_fns */
};
diff --git a/gdb/mipsread.c b/gdb/mipsread.c
index 4695bdd..0504649 100644
--- a/gdb/mipsread.c
+++ b/gdb/mipsread.c
@@ -266,28 +266,29 @@ extern CORE_ADDR startup_file_start; /* From blockframe.c */
extern CORE_ADDR startup_file_end; /* From blockframe.c */
void
-mipscoff_new_init()
+mipscoff_new_init (objfile)
+ struct objfile *objfile;
{
- /* If we have a file symbol header lying around, blow it away. */
- if (cur_hdr)
- free ((char *)cur_hdr);
- cur_hdr = 0;
}
void
-mipscoff_symfile_init (sf)
- struct sym_fns *sf;
+mipscoff_symfile_init (objfile)
+ struct objfile *objfile;
{
- sf->sym_private = NULL;
+ if (objfile -> sym_private != NULL)
+ {
+ mfree (objfile -> md, objfile -> sym_private);
+ }
+ objfile -> sym_private = NULL;
}
void
-mipscoff_symfile_read(sf, addr, mainline)
- struct sym_fns *sf;
+mipscoff_symfile_read (objfile, addr, mainline)
+ struct objfile *objfile;
CORE_ADDR addr;
int mainline;
{
- bfd *abfd = sf->objfile->obfd;
+ bfd *abfd = objfile -> obfd;
int desc;
/* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */
@@ -300,14 +301,37 @@ mipscoff_symfile_read(sf, addr, mainline)
/* Now that the executable file is positioned at symbol table,
process it and define symbols accordingly. */
- read_mips_symtab(sf->objfile, desc);
+ read_mips_symtab(objfile, desc);
/* Install any minimal symbols that have been collected as the current
minimal symbols for this objfile. */
- install_minimal_symbols (sf -> objfile);
+ install_minimal_symbols (objfile);
}
+/* Perform any local cleanups required when we are done with a particular
+ objfile. I.E, we are in the process of discarding all symbol information
+ for an objfile, freeing up all memory held for it, and unlinking the
+ objfile struct from the global list of known objfiles. */
+
+static void
+mipscoff_symfile_finish (objfile)
+ struct objfile *objfile;
+{
+ if (objfile -> sym_private != NULL)
+ {
+ mfree (objfile -> md, objfile -> sym_private);
+ }
+
+ /* If we have a file symbol header lying around, blow it away. */
+
+ if (cur_hdr)
+ {
+ free ((char *)cur_hdr);
+ }
+ cur_hdr = 0;
+}
+
/* Allocate zeroed memory */
static char *
@@ -2952,9 +2976,17 @@ fixup_sigtramp()
/* Initialization */
-static struct sym_fns ecoff_sym_fns = {"ecoff", 5,
- mipscoff_new_init, mipscoff_symfile_init,
- mipscoff_symfile_read};
+static struct sym_fns ecoff_sym_fns =
+{
+ "ecoff", /* sym_name: name or name prefix of BFD target type */
+ 5, /* sym_namelen: number of significant sym_name chars */
+ mipscoff_new_init, /* sym_new_init: init anything gbl to entire symtab */
+ mipscoff_symfile_init,/* sym_init: read initial info, setup for sym_read() */
+ mipscoff_symfile_read,/* sym_read: read a symbol file into symtab */
+ mipscoff_symfile_finish,/* sym_finish: finished with file, cleanup */
+ NULL /* next: pointer to next struct sym_fns */
+};
+
_initialize_mipsread ()
{
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 677d605..c243005 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -173,7 +173,14 @@ allocate_objfile (abfd, mapped)
/* Destroy an objfile and all the symtabs and psymtabs under it. Note
that as much as possible is allocated on the symbol_obstack and
- psymbol_obstack, so that the memory can be efficiently freed. */
+ psymbol_obstack, so that the memory can be efficiently freed.
+
+ Things which we do NOT free because they are not in malloc'd memory
+ or not in memory specific to the objfile include:
+
+ objfile -> sf
+
+ */
void
free_objfile (objfile)
@@ -181,11 +188,15 @@ free_objfile (objfile)
{
struct objfile *ofp;
- if (objfile -> name)
+ if (objfile -> sf != NULL)
+ {
+ (*objfile -> sf -> sym_finish) (objfile);
+ }
+ if (objfile -> name != NULL)
{
mfree (objfile -> md, objfile -> name);
}
- if (objfile -> obfd)
+ if (objfile -> obfd != NULL)
{
bfd_close (objfile -> obfd);
}
diff --git a/gdb/symfile.c b/gdb/symfile.c
index aab80c3..5622095 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -40,8 +40,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Global variables owned by this file */
CORE_ADDR entry_point; /* Where execution starts in symfile */
-struct sym_fns *symtab_fns = NULL; /* List of all available sym_fns. */
-int readnow_symbol_files; /* Read full symbols immediately */
+int readnow_symbol_files; /* Read full symbols immediately */
/* External variables and functions referenced. */
@@ -70,19 +69,17 @@ compare_symbols PARAMS ((const void *, const void *));
static bfd *
symfile_bfd_open PARAMS ((char *));
-static struct sym_fns *
-symfile_init PARAMS ((struct objfile *));
+static void
+find_sym_fns PARAMS ((struct objfile *));
static void
clear_symtab_users_once PARAMS ((void));
-/* Saves the sym_fns of the current symbol table, so we can call
- the right XXX_new_init function when we free it. FIXME. This
- should be extended to calling the new_init function for each
- existing symtab or psymtab, since the main symbol file and
- subsequent added symbol files can have different types. */
+/* List of all available sym_fns. On gdb startup, each object file reader
+ calls add_symtab_fns() to register information on each format it is
+ prepared to read. */
-static struct sym_fns *symfile_fns;
+static struct sym_fns *symtab_fns = NULL;
/* When we need to allocate a new type, we need to know which type_obstack
to allocate the type on, since there is one for each objfile. The places
@@ -351,7 +348,6 @@ syms_from_objfile (objfile, addr, mainline, verbo)
int verbo;
{
asection *text_sect;
- struct sym_fns *sf;
/* There is a distinction between having no symbol table
(we refuse to read the file, leaving the old set of symbols around)
@@ -363,6 +359,7 @@ syms_from_objfile (objfile, addr, mainline, verbo)
/* Save startup file's range of PC addresses to help blockframe.c
decide where the bottom of the stack is. */
+
if (bfd_get_file_flags (objfile -> obfd) & EXEC_P)
{
/* Executable file -- record its entry point so we'll recognize
@@ -379,30 +376,34 @@ syms_from_objfile (objfile, addr, mainline, verbo)
startup_file_end = 0;
}
- sf = symfile_init (objfile);
+ find_sym_fns (objfile);
if (mainline)
{
/* Since no error yet, throw away the old symbol table. */
- if (symfile_objfile)
- free_objfile (symfile_objfile);
- symfile_objfile = NULL;
+ if (symfile_objfile != NULL)
+ {
+ free_objfile (symfile_objfile);
+ symfile_objfile = NULL;
+ }
- (*sf->sym_new_init) ();
+ (*objfile -> sf -> sym_new_init) (objfile);
/* For mainline, caller didn't know the specified address of the
text section. We fix that here. */
+
text_sect = bfd_get_section_by_name (objfile -> obfd, ".text");
addr = bfd_section_vma (objfile -> obfd, text_sect);
}
- /* Allow complaints to appear for this new file, and record how
- verbose to be. */
+ /* Initialize symbol reading routines for this objfile, allow complaints to
+ appear for this new file, and record how verbose to be, then do the
+ initial symbol reading for this file. */
- clear_complaints(1, verbo);
-
- (*sf->sym_read) (sf, addr, mainline);
+ (*objfile -> sf -> sym_init) (objfile);
+ clear_complaints (1, verbo);
+ (*objfile -> sf -> sym_read) (objfile, addr, mainline);
/* Don't allow char * to have a typename (else would get caddr_t.) */
/* Ditto void *. FIXME should do this for all the builtin types. */
@@ -414,14 +415,13 @@ syms_from_objfile (objfile, addr, mainline, verbo)
{
/* OK, make it the "real" symbol file. */
symfile_objfile = objfile;
- symfile_fns = sf;
}
/* If we have wiped out any old symbol tables, clean up. */
clear_symtab_users_once ();
/* We're done reading the symbol file; finish off complaints. */
- clear_complaints(0, verbo);
+ clear_complaints (0, verbo);
/* Fixup all the breakpoints that may have been redefined by this
symbol file. */
@@ -453,74 +453,96 @@ symbol_file_add (name, from_tty, addr, mainline, mapped, readnow)
{
struct objfile *objfile;
struct partial_symtab *psymtab;
+ bfd *abfd;
+ int mapped_it;
- /* Open a bfd for the file, then allocate a new objfile. */
-
- objfile = allocate_objfile (symfile_bfd_open (name), mapped);
-
- /* There is a distinction between having no symbol table
+ /* Open a bfd for the file and then check to see if the file has a
+ symbol table. There is a distinction between having no symbol table
(we refuse to read the file, leaving the old set of symbols around)
- and having no debugging symbols in your symbol table (we read
- the file and end up with a mostly empty symbol table, but with lots
- of stuff in the minimal symbol table). */
-
- if (!(bfd_get_file_flags (objfile -> obfd) & HAS_SYMS))
+ and having no debugging symbols in the symbol table (we read the file
+ and end up with a mostly empty symbol table, but with lots of stuff in
+ the minimal symbol table). We need to make the decision about whether
+ to continue with the file before allocating and building a objfile.
+
+ FIXME: This strategy works correctly when the debugging symbols are
+ intermixed with "normal" symbols. However, when the debugging symbols
+ are separate, such as with ELF/DWARF, it is perfectly plausible for
+ the symbol table to be missing but still have all the DWARF info
+ intact. Thus in general it is wrong to assume that having no symbol
+ table implies no debugging information. */
+
+ abfd = symfile_bfd_open (name);
+ if (!(bfd_get_file_flags (abfd) & HAS_SYMS))
{
error ("%s has no symbol-table", name);
}
+ if ((have_full_symbols () || have_partial_symbols ())
+ && mainline
+ && from_tty
+ && !query ("Load new symbol table from \"%s\"? ", name))
+ error ("Not confirmed.");
+
+ objfile = allocate_objfile (abfd, mapped);
+
/* If the objfile uses a mapped symbol file, and we have a psymtab for
it, then skip reading any symbols at this time. */
- if ((objfile -> psymtabs != NULL) && (objfile -> flags & OBJF_MAPPED))
+ if ((objfile -> flags & OBJF_MAPPED) && (objfile -> psymtabs != NULL))
{
+ /* We mapped in an existing symbol table file that already has had
+ the psymbols read in. So we can skip that part. Notify the user
+ that instead of reading the symbols, they have been mapped. */
if (from_tty || info_verbose)
{
- printf_filtered ("Mapped symbols for %s.\n", name);
+ printf_filtered ("Mapped symbols for %s...", name);
+ wrap_here ("");
fflush (stdout);
}
}
else
{
- if ((have_full_symbols () || have_partial_symbols ())
- && mainline
- && from_tty
- && !query ("Load new symbol table from \"%s\"? ", name))
- error ("Not confirmed.");
-
+ /* We either created a new mapped symbol table, mapped an existing
+ symbol table file with no partial symbols, or need to read an
+ unmapped symbol table. */
if (from_tty || info_verbose)
{
printf_filtered ("Reading symbols from %s...", name);
wrap_here ("");
fflush (stdout);
}
-
syms_from_objfile (objfile, addr, mainline, from_tty);
-
- readnow |= readnow_symbol_files;
- if (readnow)
- {
- if (from_tty || info_verbose)
- {
- printf_filtered ("expanding to full symbols...");
- wrap_here ("");
- fflush (stdout);
- }
-
- for (psymtab = objfile -> psymtabs;
- psymtab != NULL;
- psymtab = psymtab -> next)
- {
- (void) psymtab_to_symtab (psymtab);
- }
- }
+ }
+
+ /* We now have at least a partial symbol table. Check to see if the
+ user requested that all symbols be read on initial access via either
+ the gdb startup command line or on a per symbol file basis. Expand
+ all partial symbol tables for this objfile if so. */
+ readnow |= readnow_symbol_files;
+ if (readnow)
+ {
if (from_tty || info_verbose)
{
- printf_filtered ("done.\n");
+ printf_filtered ("expanding to full symbols...");
+ wrap_here ("");
fflush (stdout);
}
+
+ for (psymtab = objfile -> psymtabs;
+ psymtab != NULL;
+ psymtab = psymtab -> next)
+ {
+ (void) psymtab_to_symtab (psymtab);
+ }
+ }
+
+ if (from_tty || info_verbose)
+ {
+ printf_filtered ("done.\n");
+ fflush (stdout);
}
+
return (objfile);
}
@@ -550,15 +572,6 @@ symbol_file_command (args, from_tty)
error ("Not confirmed.");
free_all_objfiles ();
symfile_objfile = NULL;
- /* FIXME, this does not account for the main file and subsequent
- files (shared libs, dynloads, etc) having different formats.
- It only calls the cleanup routine for the main file's format. */
- if (symfile_fns)
- {
- (*symfile_fns -> sym_new_init) ();
- free (symfile_fns);
- symfile_fns = 0;
- }
}
else
{
@@ -649,8 +662,10 @@ symfile_bfd_open (name)
return (sym_bfd);
}
-/* Link a new symtab_fns into the global symtab_fns list.
- Called by various _initialize routines. */
+/* Link a new symtab_fns into the global symtab_fns list. Called on gdb
+ startup by the _initialize routine in each object file format reader,
+ to register information about each format the the reader is prepared
+ to handle. */
void
add_symtab_fns (sf)
@@ -662,32 +677,27 @@ add_symtab_fns (sf)
/* Initialize to read symbols from the symbol file sym_bfd. It either
- returns or calls error(). The result is a malloc'd struct sym_fns
- that contains cached information about the symbol file. */
+ returns or calls error(). The result is an initialized struct sym_fns
+ in the objfile structure, that contains cached information about the
+ symbol file. */
-static struct sym_fns *
-symfile_init (objfile)
+static void
+find_sym_fns (objfile)
struct objfile *objfile;
{
struct sym_fns *sf, *sf2;
- for (sf = symtab_fns; sf != NULL; sf = sf->next)
+ for (sf = symtab_fns; sf != NULL; sf = sf -> next)
{
- if (!strncmp (bfd_get_target (objfile -> obfd), sf->sym_name, sf->sym_namelen))
+ if (strncmp (bfd_get_target (objfile -> obfd),
+ sf -> sym_name, sf -> sym_namelen) == 0)
{
- sf2 = (struct sym_fns *)xmalloc (sizeof (*sf2));
- /* FIXME, who frees this? */
- *sf2 = *sf;
- sf2->objfile = objfile;
- sf2->sym_bfd = objfile -> obfd;
- sf2->sym_private = 0; /* Not alloc'd yet */
- (*sf2->sym_init) (sf2);
- return sf2;
+ objfile -> sf = sf;
+ return;
}
}
error ("I'm sorry, Dave, I can't do that. Symbol format `%s' unknown.",
bfd_get_target (objfile -> obfd));
- return 0; /* Appease lint. */
}
/* This function runs the load command of our current target. */
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 6dbd2d7..1d9b7dd 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -28,6 +28,60 @@ struct psymbol_allocation_list {
int size;
};
+/* Structure to keep track of symbol reading functions for various
+ object file types. */
+
+struct sym_fns {
+
+ /* is the name, or name prefix, of the BFD "target type" that this
+ set of functions handles. E.g. "a.out" or "sunOs" or "coff" or "elf". */
+
+ char *sym_name;
+
+ /* counts how many bytes of sym_name should be checked against the
+ BFD target type of the file being read. If an exact match is
+ desired, specify the number of characters in sym_name plus 1 for the
+ NUL. If a prefix match is desired, specify the number of characters in
+ sym_name. */
+
+ int sym_namelen;
+
+ /* 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. */
+
+ void (*sym_new_init) PARAMS ((struct objfile *));
+
+ /* Reads any initial information from a symbol file, and initializes the
+ struct sym_fns SF in preparation for sym_read(). It is called every
+ time we read a symbol file for any reason. */
+
+ void (*sym_init) PARAMS ((struct objfile *));
+
+ /* sym_read (objfile, addr, mainline)
+ Reads a symbol file into a psymtab (or possibly a symtab).
+ OBJFILE is the objfile struct for the file we are reading. ADDR
+ is the offset between the file's specified start address and
+ its true address in memory. MAINLINE is 1 if this is the
+ main symbol table being read, and 0 if a secondary
+ symbol file (e.g. shared library or dynamically loaded file)
+ is being read. */
+
+ void (*sym_read) PARAMS ((struct objfile *, CORE_ADDR, int));
+
+ /* Called when we are finished with an objfile. Should do all cleanup
+ that is specific to the object file format for the particular objfile. */
+
+ void (*sym_finish) PARAMS ((struct objfile *));
+
+ /* 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;
+
+};
+
/* Master structure for keeping track of each input file from which
gdb reads symbols. One of these is allocated for each such file we
access, e.g. the exec_file, symbol_file, and any shared library object
@@ -117,7 +171,20 @@ struct objfile
the memory mapped malloc() package to manage storage for this objfile's
data. NULL if we are not. */
- void *md;
+ PTR md;
+
+ /* Structure which keeps track of functions that manipulate objfile's
+ of the same type as this objfile. I.E. the function to read partial
+ symbols for example. Note that this structure is in statically
+ allocated memory, and is shared by all objfiles that use the
+ object module reader of this type. */
+
+ struct sym_fns *sf;
+
+ /* Hook for information which is shared by sym_init and sym_read for
+ this objfile. It is typically a pointer to malloc'd memory. */
+
+ PTR sym_private;
};
@@ -133,69 +200,6 @@ struct objfile
#define OBJF_MAPPED (1 << 0) /* Objfile data is mmap'd */
-/* Structure to keep track of symbol reading functions for various
- object file types. */
-
-struct sym_fns {
-
- /* is the name, or name prefix, of the BFD "target type" that this
- set of functions handles. E.g. "a.out" or "sunOs" or "coff" or "elf". */
-
- char *sym_name;
-
- /* counts how many bytes of sym_name should be checked against the
- BFD target type of the file being read. If an exact match is
- desired, specify the number of characters in sym_name plus 1 for the
- NUL. If a prefix match is desired, specify the number of characters in
- sym_name. */
-
- int sym_namelen;
-
- /* 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. */
-
- void (*sym_new_init) PARAMS ((void));
-
- /* sym_init (sf)
- reads any initial information from a symbol file, and
- initializes the struct sym_fns SF in preparation for sym_read().
- It is called every time we read a symbol file for any reason. */
-
- void (*sym_init) PARAMS ((struct sym_fns *));
-
- /* sym_read (sf, addr, mainline)
- reads a symbol file into a psymtab (or possibly a symtab).
- SF is the struct sym_fns that sym_init initialized. ADDR
- is the offset between the file's specified start address and
- its true address in memory. MAINLINE is 1 if this is the
- main symbol table being read, and 0 if a secondary
- symbol file (e.g. shared library or dynamically loaded file)
- is being read. */
-
- void (*sym_read) PARAMS ((struct sym_fns *, CORE_ADDR, int));
-
- /* is the accessor for the symbol file being read. */
-
- bfd *sym_bfd;
-
- /* is where information can be shared among sym_init and sym_read.
- It is typically a pointer to malloc'd memory. */
-
- char *sym_private; /* Should be void * */
-
- /* is the "struct objfile" for the object file being read. */
-
- struct objfile *objfile;
-
- /* 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 void
extend_psymbol_list PARAMS ((struct psymbol_allocation_list *,
struct objfile *));
@@ -343,21 +347,6 @@ struct complaint {
extern struct complaint complaint_root[1];
-/* Externally visible variables defined in symfile.c */
-
-/* The object file that the main symbol table was loaded from (e.g. the
- argument to the "symbol-file" or "file" command). */
-
-extern struct objfile *symfile_objfile;
-
-/* Where execution starts in symfile */
-
-extern CORE_ADDR entry_point;
-
-/* Root of object file struct chain. */
-
-extern struct objfile *object_files;
-
/* Functions that handle complaints. (in symfile.c) */
extern void
diff --git a/gdb/target.c b/gdb/target.c
index c78eecb..83fe708 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -18,10 +18,9 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-#include <stdio.h>
+#include "defs.h"
#include <errno.h>
#include <ctype.h>
-#include "defs.h"
#include "target.h"
#include "gdbcmd.h"
#include "symtab.h"
@@ -53,9 +52,6 @@ static int
nosymbol PARAMS ((char *, CORE_ADDR *));
static void
-noprocess PARAMS ((void));
-
-static void
tcomplain PARAMS ((void));
static int
@@ -63,7 +59,6 @@ nomemory PARAMS ((CORE_ADDR, char *, int, int));
static void
ignore PARAMS ((void));
-
static void
target_command PARAMS ((char *, int));
@@ -184,7 +179,7 @@ tcomplain ()
current_target->to_shortname);
}
-static void
+void
noprocess ()
{
error ("You can't do that without a process to debug");
@@ -549,7 +544,7 @@ target_info (args, from_tty)
struct target_ops *t;
int has_all_mem = 0;
- if (symfile_objfile != 0)
+ if (symfile_objfile != NULL)
printf ("Symbols from \"%s\".\n", symfile_objfile->name);
#ifdef FILES_INFO_HOOK
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 302d4d7..09981a7 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -154,9 +154,6 @@ enter_line_range PARAMS ((struct subfile *, unsigned, unsigned,
CORE_ADDR, CORE_ADDR, unsigned *));
static void
-aixcoff_symfile_read PARAMS ((struct sym_fns *, CORE_ADDR, int));
-
-static void
free_debugsection PARAMS ((void));
static int
@@ -166,10 +163,16 @@ static int
init_stringtab PARAMS ((bfd *, long, struct objfile *));
static void
-aixcoff_symfile_init PARAMS ((struct sym_fns *));
+aixcoff_symfile_init PARAMS ((struct objfile *));
+
+static void
+aixcoff_new_init PARAMS ((struct objfile *));
+
+static void
+aixcoff_symfile_read PARAMS ((struct sym_fns *, CORE_ADDR, int));
static void
-aixcoff_new_init PARAMS ((void));
+aixcoff_symfile_finish PARAMS ((struct objfile *));
static int
init_lineno PARAMS ((bfd *, long, int));
@@ -2001,27 +2004,20 @@ build_function_symbol (ind, objfile)
#endif
static void
-aixcoff_new_init ()
+aixcoff_new_init (objfile)
+ struct objfile *objfile;
{
- /* This routine is executed once per executable. We should start with a
- fresh include table per executable. */
-
- if (inclTable) {
- free (inclTable);
- inclTable = NULL;
- }
- inclIndx = inclLength = inclDepth = NULL;
}
static void
-aixcoff_symfile_init (sf)
-struct sym_fns *sf;
+aixcoff_symfile_init (objfile)
+ struct objfile *objfile;
{
- bfd *abfd = sf->sym_bfd;
+ bfd *abfd = objfile->obfd;
/* Allocate struct to keep track of the symfile */
- /* FIXME memory leak */
- sf->sym_private = xmalloc(sizeof (struct coff_symfile_info));
+ objfile -> sym_private = xmmalloc (objfile -> md,
+ sizeof (struct coff_symfile_info));
/*
* Save startup file's range of PC addresses to help
@@ -2037,6 +2033,30 @@ struct sym_fns *sf;
}
}
+/* Perform any local cleanups required when we are done with a particular
+ objfile. I.E, we are in the process of discarding all symbol information
+ for an objfile, freeing up all memory held for it, and unlinking the
+ objfile struct from the global list of known objfiles. */
+
+static void
+aixcoff_symfile_finish (objfile)
+ struct objfile *objfile;
+{
+ if (objfile -> sym_private != NULL)
+ {
+ mfree (objfile -> md, objfile -> sym_private);
+ }
+
+ /* Start with a fresh include table for the next objfile. */
+
+ if (inclTable)
+ {
+ free (inclTable);
+ inclTable = NULL;
+ }
+ inclIndx = inclLength = inclDepth = 0;
+}
+
static int
init_stringtab(abfd, offset, objfile)
@@ -2121,8 +2141,8 @@ free_debugsection()
/* aixcoff version of symbol file read. */
static void
-aixcoff_symfile_read (sf, addr, mainline)
- struct sym_fns *sf;
+aixcoff_symfile_read (objfile, addr, mainline)
+ struct objfile *objfile;
CORE_ADDR addr;
int mainline;
{
@@ -2131,11 +2151,12 @@ aixcoff_symfile_read (sf, addr, mainline)
int stringtab_offset; /* string table file offsets */
int val;
bfd *abfd;
- struct coff_symfile_info *info = (void*) sf->sym_private;
+ struct coff_symfile_info *info;
char *name;
- symfile_bfd = abfd = sf->objfile->obfd;
- name = sf->objfile->name;
+ info = (struct coff_symfile_info *) objfile -> sym_private;
+ symfile_bfd = abfd = objfile->obfd;
+ name = objfile->name;
num_symbols = bfd_get_symcount (abfd); /* # of symbols */
symtab_offset = obj_sym_filepos (abfd); /* symbol table file offset */
@@ -2158,7 +2179,7 @@ aixcoff_symfile_read (sf, addr, mainline)
error("\"%s\": error reading line numbers\n", name);
}
- val = init_stringtab(abfd, stringtab_offset, sf->objfile);
+ val = init_stringtab(abfd, stringtab_offset, objfile);
if (val < 0) {
error ("\"%s\": can't get string table", name);
}
@@ -2186,7 +2207,7 @@ aixcoff_symfile_read (sf, addr, mainline)
/* Now that the executable file is positioned at symbol table,
process it and define symbols accordingly. */
- read_xcoff_symtab(sf->objfile, num_symbols);
+ read_xcoff_symtab(objfile, num_symbols);
make_cleanup (free_debugsection, 0);
@@ -2196,7 +2217,7 @@ aixcoff_symfile_read (sf, addr, mainline)
/* Install any minimal symbols that have been collected as the current
minimal symbols for this objfile. */
- install_minimal_symbols (sf -> objfile);
+ install_minimal_symbols (objfile);
/* Make a default for file to list. */
select_source_symtab (0);
@@ -2206,9 +2227,13 @@ aixcoff_symfile_read (sf, addr, mainline)
static struct sym_fns aixcoff_sym_fns =
{
- "aixcoff-rs6000", 15,
- aixcoff_new_init, aixcoff_symfile_init,
- aixcoff_symfile_read,
+ "aixcoff-rs6000", /* sym_name: name or name prefix of BFD target type */
+ 15, /* sym_namelen: number of significant sym_name chars */
+ aixcoff_new_init, /* sym_new_init: init anything gbl to entire symtab */
+ aixcoff_symfile_init, /* sym_init: read initial info, setup for sym_read() */
+ aixcoff_symfile_read, /* sym_read: read a symbol file into symtab */
+ aixcoff_symfile_finish, /* sym_finish: finished with file, cleanup */
+ NULL /* next: pointer to next struct sym_fns */
};
void