* coffread.c (coff_symfile_init): Use set_objfile_data.

(coff_symfile_read): Use DBX_SYMFILE_INFO.
	* dbxread.c (dbx_objfile_data_key): New global.
	(dbx_symfile_init): Use set_objfile_data.
	(dbx_symfile_finish): Don't free deprecated_sym_stab_info.
	(dbx_free_symfile_info): New function.
	(coffstab_build_psymtabs, elfstab_build_psymtabs): Use
	DBX_SYMFILE_INFO.
	(stabsect_build_psymtabs): Use set_objfile_data.
	(_initialize_dbxreadb): Initialize dbx_objfile_data_key.
	* elfread.c (elf_symtab_read): Use DBX_SYMFILE_INFO,
	set_objfile_data.
	(free_elfinfo): Use DBX_SYMFILE_INFO.
	(elf_symfile_finish): Don't free deprecated_sym_stab_info.
	(elfstab_offset_sections): Use DBX_SYMFILE_INFO.
	* gdb-stabs.h (dbx_objfile_data_key): Declare.
	(DBX_SYMFILE_INFO): Rewrite to use objfile_data.
	* objfiles.h (struct objfile) <deprecated_sym_stab_info>: Remove.
	* somread.c (som_symfile_finish): Don't free
	deprecated_sym_stab_info.
This commit is contained in:
Tom Tromey 2012-12-12 15:57:01 +00:00
parent 6f112b1867
commit d2f4b8feb9
7 changed files with 84 additions and 68 deletions

View file

@ -1,3 +1,26 @@
2012-12-12 Tom Tromey <tromey@redhat.com>
* coffread.c (coff_symfile_init): Use set_objfile_data.
(coff_symfile_read): Use DBX_SYMFILE_INFO.
* dbxread.c (dbx_objfile_data_key): New global.
(dbx_symfile_init): Use set_objfile_data.
(dbx_symfile_finish): Don't free deprecated_sym_stab_info.
(dbx_free_symfile_info): New function.
(coffstab_build_psymtabs, elfstab_build_psymtabs): Use
DBX_SYMFILE_INFO.
(stabsect_build_psymtabs): Use set_objfile_data.
(_initialize_dbxreadb): Initialize dbx_objfile_data_key.
* elfread.c (elf_symtab_read): Use DBX_SYMFILE_INFO,
set_objfile_data.
(free_elfinfo): Use DBX_SYMFILE_INFO.
(elf_symfile_finish): Don't free deprecated_sym_stab_info.
(elfstab_offset_sections): Use DBX_SYMFILE_INFO.
* gdb-stabs.h (dbx_objfile_data_key): Declare.
(DBX_SYMFILE_INFO): Rewrite to use objfile_data.
* objfiles.h (struct objfile) <deprecated_sym_stab_info>: Remove.
* somread.c (som_symfile_finish): Don't free
deprecated_sym_stab_info.
2012-12-12 Joel Brobecker <brobecker@adacore.com> 2012-12-12 Joel Brobecker <brobecker@adacore.com>
* gdbarch.sh (software_single_step): Remove trailing space in * gdbarch.sh (software_single_step): Remove trailing space in

View file

@ -450,12 +450,11 @@ record_minimal_symbol (struct coff_symbol *cs, CORE_ADDR address,
static void static void
coff_symfile_init (struct objfile *objfile) coff_symfile_init (struct objfile *objfile)
{ {
/* Allocate struct to keep track of stab reading. */ struct dbx_symfile_info *dbx;
objfile->deprecated_sym_stab_info = (struct dbx_symfile_info *)
xmalloc (sizeof (struct dbx_symfile_info));
memset (objfile->deprecated_sym_stab_info, 0, /* Allocate struct to keep track of stab reading. */
sizeof (struct dbx_symfile_info)); dbx = XCNEW (struct dbx_symfile_info);
set_objfile_data (objfile, dbx_objfile_data_key, dbx);
/* Allocate struct to keep track of the symfile. */ /* Allocate struct to keep track of the symfile. */
objfile->deprecated_sym_private objfile->deprecated_sym_private
@ -528,7 +527,7 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags)
int stabstrsize; int stabstrsize;
info = (struct coff_symfile_info *) objfile->deprecated_sym_private; info = (struct coff_symfile_info *) objfile->deprecated_sym_private;
dbxinfo = objfile->deprecated_sym_stab_info; dbxinfo = DBX_SYMFILE_INFO (objfile);
symfile_bfd = abfd; /* Kludge for swap routines. */ symfile_bfd = abfd; /* Kludge for swap routines. */
/* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */ /* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */

View file

@ -64,6 +64,10 @@
native, now. */ native, now. */
/* Key for dbx-associated data. */
const struct objfile_data *dbx_objfile_data_key;
/* We put a pointer to this structure in the read_symtab_private field /* We put a pointer to this structure in the read_symtab_private field
of the psymtab. */ of the psymtab. */
@ -624,12 +628,11 @@ dbx_symfile_init (struct objfile *objfile)
char *name = bfd_get_filename (sym_bfd); char *name = bfd_get_filename (sym_bfd);
asection *text_sect; asection *text_sect;
unsigned char size_temp[DBX_STRINGTAB_SIZE_SIZE]; unsigned char size_temp[DBX_STRINGTAB_SIZE_SIZE];
struct dbx_symfile_info *dbx;
/* Allocate struct to keep track of the symfile. */ /* Allocate struct to keep track of the symfile. */
objfile->deprecated_sym_stab_info = (struct dbx_symfile_info *) dbx = XCNEW (struct dbx_symfile_info);
xmalloc (sizeof (struct dbx_symfile_info)); set_objfile_data (objfile, dbx_objfile_data_key, dbx);
memset (objfile->deprecated_sym_stab_info, 0,
sizeof (struct dbx_symfile_info));
DBX_TEXT_SECTION (objfile) = bfd_get_section_by_name (sym_bfd, ".text"); DBX_TEXT_SECTION (objfile) = bfd_get_section_by_name (sym_bfd, ".text");
DBX_DATA_SECTION (objfile) = bfd_get_section_by_name (sym_bfd, ".data"); DBX_DATA_SECTION (objfile) = bfd_get_section_by_name (sym_bfd, ".data");
@ -737,12 +740,18 @@ dbx_symfile_init (struct objfile *objfile)
static void static void
dbx_symfile_finish (struct objfile *objfile) dbx_symfile_finish (struct objfile *objfile)
{ {
if (objfile->deprecated_sym_stab_info != NULL) free_header_files ();
}
static void
dbx_free_symfile_info (struct objfile *objfile, void *arg)
{ {
if (HEADER_FILES (objfile) != NULL) struct dbx_symfile_info *dbx = arg;
if (dbx->header_files != NULL)
{ {
int i = N_HEADER_FILES (objfile); int i = dbx->n_header_files;
struct header_file *hfiles = HEADER_FILES (objfile); struct header_file *hfiles = dbx->header_files;
while (--i >= 0) while (--i >= 0)
{ {
@ -751,10 +760,10 @@ dbx_symfile_finish (struct objfile *objfile)
} }
xfree (hfiles); xfree (hfiles);
} }
xfree (objfile->deprecated_sym_stab_info);
} xfree (dbx);
free_header_files ();
} }
/* Buffer for reading the symbol table entries. */ /* Buffer for reading the symbol table entries. */
@ -3347,7 +3356,7 @@ coffstab_build_psymtabs (struct objfile *objfile,
/* There is already a dbx_symfile_info allocated by our caller. /* There is already a dbx_symfile_info allocated by our caller.
It might even contain some info from the coff symtab to help us. */ It might even contain some info from the coff symtab to help us. */
info = objfile->deprecated_sym_stab_info; info = DBX_SYMFILE_INFO (objfile);
DBX_TEXT_ADDR (objfile) = textaddr; DBX_TEXT_ADDR (objfile) = textaddr;
DBX_TEXT_SIZE (objfile) = textsize; DBX_TEXT_SIZE (objfile) = textsize;
@ -3436,7 +3445,7 @@ elfstab_build_psymtabs (struct objfile *objfile, asection *stabsect,
/* There is already a dbx_symfile_info allocated by our caller. /* There is already a dbx_symfile_info allocated by our caller.
It might even contain some info from the ELF symtab to help us. */ It might even contain some info from the ELF symtab to help us. */
info = objfile->deprecated_sym_stab_info; info = DBX_SYMFILE_INFO (objfile);
/* Find the first and last text address. dbx_symfile_read seems to /* Find the first and last text address. dbx_symfile_read seems to
want this. */ want this. */
@ -3515,6 +3524,7 @@ stabsect_build_psymtabs (struct objfile *objfile, char *stab_name,
asection *stabsect; asection *stabsect;
asection *stabstrsect; asection *stabstrsect;
asection *text_sect; asection *text_sect;
struct dbx_symfile_info *dbx;
stabsect = bfd_get_section_by_name (sym_bfd, stab_name); stabsect = bfd_get_section_by_name (sym_bfd, stab_name);
stabstrsect = bfd_get_section_by_name (sym_bfd, stabstr_name); stabstrsect = bfd_get_section_by_name (sym_bfd, stabstr_name);
@ -3527,10 +3537,8 @@ stabsect_build_psymtabs (struct objfile *objfile, char *stab_name,
"but not string section (%s)"), "but not string section (%s)"),
stab_name, stabstr_name); stab_name, stabstr_name);
objfile->deprecated_sym_stab_info = (struct dbx_symfile_info *) dbx = XCNEW (struct dbx_symfile_info);
xmalloc (sizeof (struct dbx_symfile_info)); set_objfile_data (objfile, dbx_objfile_data_key, dbx);
memset (objfile->deprecated_sym_stab_info, 0,
sizeof (struct dbx_symfile_info));
text_sect = bfd_get_section_by_name (sym_bfd, text_name); text_sect = bfd_get_section_by_name (sym_bfd, text_name);
if (!text_sect) if (!text_sect)
@ -3597,4 +3605,7 @@ void
_initialize_dbxread (void) _initialize_dbxread (void)
{ {
add_symtab_fns (&aout_sym_fns); add_symtab_fns (&aout_sym_fns);
dbx_objfile_data_key
= register_objfile_data_with_cleanup (NULL, dbx_free_symfile_info);
} }

View file

@ -248,7 +248,7 @@ elf_symtab_read (struct objfile *objfile, int type,
/* Name of filesym. This is either a constant string or is saved on /* Name of filesym. This is either a constant string or is saved on
the objfile's filename cache. */ the objfile's filename cache. */
const char *filesymname = ""; const char *filesymname = "";
struct dbx_symfile_info *dbx = objfile->deprecated_sym_stab_info; struct dbx_symfile_info *dbx = DBX_SYMFILE_INFO (objfile);
int stripped = (bfd_get_symcount (objfile->obfd) == 0); int stripped = (bfd_get_symcount (objfile->obfd) == 0);
for (i = 0; i < number_of_symbols; i++) for (i = 0; i < number_of_symbols; i++)
@ -1251,6 +1251,7 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
long symcount = 0, dynsymcount = 0, synthcount, storage_needed; long symcount = 0, dynsymcount = 0, synthcount, storage_needed;
asymbol **symbol_table = NULL, **dyn_symbol_table = NULL; asymbol **symbol_table = NULL, **dyn_symbol_table = NULL;
asymbol *synthsyms; asymbol *synthsyms;
struct dbx_symfile_info *dbx;
if (symtab_create_debug) if (symtab_create_debug)
{ {
@ -1265,16 +1266,13 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
memset ((char *) &ei, 0, sizeof (ei)); memset ((char *) &ei, 0, sizeof (ei));
/* Allocate struct to keep track of the symfile. */ /* Allocate struct to keep track of the symfile. */
objfile->deprecated_sym_stab_info = (struct dbx_symfile_info *) dbx = XCNEW (struct dbx_symfile_info);
xmalloc (sizeof (struct dbx_symfile_info)); set_objfile_data (objfile, dbx_objfile_data_key, dbx);
memset ((char *) objfile->deprecated_sym_stab_info,
0, sizeof (struct dbx_symfile_info));
make_cleanup (free_elfinfo, (void *) objfile); make_cleanup (free_elfinfo, (void *) objfile);
/* Process the normal ELF symbol table first. This may write some /* Process the normal ELF symbol table first. This may write some
chain of info into the dbx_symfile_info in chain of info into the dbx_symfile_info of the objfile, which can
objfile->deprecated_sym_stab_info, which can later be used by later be used by elfstab_offset_sections. */
elfstab_offset_sections. */
storage_needed = bfd_get_symtab_upper_bound (objfile->obfd); storage_needed = bfd_get_symtab_upper_bound (objfile->obfd);
if (storage_needed < 0) if (storage_needed < 0)
@ -1467,15 +1465,14 @@ read_psyms (struct objfile *objfile)
dwarf2_build_psymtabs (objfile); dwarf2_build_psymtabs (objfile);
} }
/* This cleans up the objfile's deprecated_sym_stab_info pointer, and /* This cleans up the objfile's dbx symfile info, and the chain of
the chain of stab_section_info's, that might be dangling from stab_section_info's, that might be dangling from it. */
it. */
static void static void
free_elfinfo (void *objp) free_elfinfo (void *objp)
{ {
struct objfile *objfile = (struct objfile *) objp; struct objfile *objfile = (struct objfile *) objp;
struct dbx_symfile_info *dbxinfo = objfile->deprecated_sym_stab_info; struct dbx_symfile_info *dbxinfo = DBX_SYMFILE_INFO (objfile);
struct stab_section_info *ssi, *nssi; struct stab_section_info *ssi, *nssi;
ssi = dbxinfo->stab_section_info; ssi = dbxinfo->stab_section_info;
@ -1512,11 +1509,6 @@ elf_new_init (struct objfile *ignore)
static void static void
elf_symfile_finish (struct objfile *objfile) elf_symfile_finish (struct objfile *objfile)
{ {
if (objfile->deprecated_sym_stab_info != NULL)
{
xfree (objfile->deprecated_sym_stab_info);
}
dwarf2_free_objfile (objfile); dwarf2_free_objfile (objfile);
} }
@ -1550,7 +1542,7 @@ void
elfstab_offset_sections (struct objfile *objfile, struct partial_symtab *pst) elfstab_offset_sections (struct objfile *objfile, struct partial_symtab *pst)
{ {
const char *filename = pst->filename; const char *filename = pst->filename;
struct dbx_symfile_info *dbx = objfile->deprecated_sym_stab_info; struct dbx_symfile_info *dbx = DBX_SYMFILE_INFO (objfile);
struct stab_section_info *maybe = dbx->stab_section_info; struct stab_section_info *maybe = dbx->stab_section_info;
struct stab_section_info *questionable = 0; struct stab_section_info *questionable = 0;
int i; int i;

View file

@ -27,6 +27,10 @@
#if !defined (GDBSTABS_H) #if !defined (GDBSTABS_H)
#define GDBSTABS_H #define GDBSTABS_H
/* The tag used to find the DBX info attached to an objfile. This is
global because it is referenced by several modules. */
extern const struct objfile_data *dbx_objfile_data_key;
/* The stab_section_info chain remembers info from the ELF symbol table, /* The stab_section_info chain remembers info from the ELF symbol table,
while psymtabs are being built for the other symbol tables in the while psymtabs are being built for the other symbol tables in the
objfile. It is destroyed at the complation of psymtab-reading. objfile. It is destroyed at the complation of psymtab-reading.
@ -42,8 +46,8 @@ struct stab_section_info
}; };
/* Information is passed among various dbxread routines for accessing /* Information is passed among various dbxread routines for accessing
symbol files. A pointer to this structure is kept in the symbol files. A pointer to this structure is kept in the objfile,
deprecated_sym_stab_info field of the objfile struct. */ using the dbx_objfile_data_key. */
struct dbx_symfile_info struct dbx_symfile_info
{ {
@ -73,7 +77,8 @@ struct dbx_symfile_info
asection *stab_section; asection *stab_section;
}; };
#define DBX_SYMFILE_INFO(o) ((o)->deprecated_sym_stab_info) #define DBX_SYMFILE_INFO(o) \
((struct dbx_symfile_info *) objfile_data ((o), dbx_objfile_data_key))
#define DBX_TEXT_ADDR(o) (DBX_SYMFILE_INFO(o)->text_addr) #define DBX_TEXT_ADDR(o) (DBX_SYMFILE_INFO(o)->text_addr)
#define DBX_TEXT_SIZE(o) (DBX_SYMFILE_INFO(o)->text_size) #define DBX_TEXT_SIZE(o) (DBX_SYMFILE_INFO(o)->text_size)
#define DBX_SYMCOUNT(o) (DBX_SYMFILE_INFO(o)->symcount) #define DBX_SYMCOUNT(o) (DBX_SYMFILE_INFO(o)->symcount)

View file

@ -322,15 +322,6 @@ struct objfile
struct entry_info ei; struct entry_info ei;
/* Information about stabs. Will be filled in with a dbx_symfile_info
struct by those readers that need it. */
/* NOTE: cagney/2004-10-23: This has been replaced by per-objfile
data points implemented using "data" and "num_data" below. For
an example of how to use this replacement, see "objfile_data"
in "mips-tdep.c". */
struct dbx_symfile_info *deprecated_sym_stab_info;
/* Hook for information for use by the symbol reader (currently used /* Hook for information for use by the symbol reader (currently used
for information shared by sym_init and sym_read). It is for information shared by sym_init and sym_read). It is
typically a pointer to malloc'd memory. The symbol reader's finish typically a pointer to malloc'd memory. The symbol reader's finish
@ -344,8 +335,7 @@ struct objfile
/* Per objfile data-pointers required by other GDB modules. */ /* Per objfile data-pointers required by other GDB modules. */
/* FIXME: kettenis/20030711: This mechanism could replace /* FIXME: kettenis/20030711: This mechanism could replace
deprecated_sym_stab_info and deprecated_sym_private deprecated_sym_private entirely. */
entirely. */
REGISTRY_FIELDS; REGISTRY_FIELDS;

View file

@ -351,10 +351,6 @@ som_new_init (struct objfile *ignore)
static void static void
som_symfile_finish (struct objfile *objfile) som_symfile_finish (struct objfile *objfile)
{ {
if (objfile->deprecated_sym_stab_info != NULL)
{
xfree (objfile->deprecated_sym_stab_info);
}
} }
/* SOM specific initialization routine for reading symbols. */ /* SOM specific initialization routine for reading symbols. */