From 80d68b1d49a92b6ea0b5b79d9be413f0002ae200 Mon Sep 17 00:00:00 2001 From: Fred Fish Date: Thu, 19 Mar 1992 21:57:15 +0000 Subject: * 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(). --- gdb/xcoffread.c | 85 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 30 deletions(-) (limited to 'gdb/xcoffread.c') 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 -- cgit v1.1