aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-12-12 15:57:01 +0000
committerTom Tromey <tromey@redhat.com>2012-12-12 15:57:01 +0000
commitd2f4b8feb92563f328897af142d05e796cde26bd (patch)
treeb3fb6822baded1c0640c974c34536d975fdeb256
parent6f112b1867d994eb26ba56c5a47400fb715f0214 (diff)
downloadgdb-d2f4b8feb92563f328897af142d05e796cde26bd.zip
gdb-d2f4b8feb92563f328897af142d05e796cde26bd.tar.gz
gdb-d2f4b8feb92563f328897af142d05e796cde26bd.tar.bz2
* 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.
-rw-r--r--gdb/ChangeLog23
-rw-r--r--gdb/coffread.c11
-rw-r--r--gdb/dbxread.c57
-rw-r--r--gdb/elfread.c28
-rw-r--r--gdb/gdb-stabs.h11
-rw-r--r--gdb/objfiles.h12
-rw-r--r--gdb/somread.c4
7 files changed, 81 insertions, 65 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 671aa09..8ead705 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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>
* gdbarch.sh (software_single_step): Remove trailing space in
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 3789995..94d0554 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -450,12 +450,11 @@ record_minimal_symbol (struct coff_symbol *cs, CORE_ADDR address,
static void
coff_symfile_init (struct objfile *objfile)
{
- /* Allocate struct to keep track of stab reading. */
- objfile->deprecated_sym_stab_info = (struct dbx_symfile_info *)
- xmalloc (sizeof (struct dbx_symfile_info));
+ struct dbx_symfile_info *dbx;
- memset (objfile->deprecated_sym_stab_info, 0,
- sizeof (struct dbx_symfile_info));
+ /* Allocate struct to keep track of stab reading. */
+ dbx = XCNEW (struct dbx_symfile_info);
+ set_objfile_data (objfile, dbx_objfile_data_key, dbx);
/* Allocate struct to keep track of the symfile. */
objfile->deprecated_sym_private
@@ -528,7 +527,7 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags)
int stabstrsize;
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. */
/* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 9d0e624..0a92764 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -64,6 +64,10 @@
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
of the psymtab. */
@@ -624,12 +628,11 @@ dbx_symfile_init (struct objfile *objfile)
char *name = bfd_get_filename (sym_bfd);
asection *text_sect;
unsigned char size_temp[DBX_STRINGTAB_SIZE_SIZE];
+ struct dbx_symfile_info *dbx;
/* Allocate struct to keep track of the symfile. */
- objfile->deprecated_sym_stab_info = (struct dbx_symfile_info *)
- xmalloc (sizeof (struct dbx_symfile_info));
- memset (objfile->deprecated_sym_stab_info, 0,
- sizeof (struct dbx_symfile_info));
+ dbx = XCNEW (struct dbx_symfile_info);
+ set_objfile_data (objfile, dbx_objfile_data_key, dbx);
DBX_TEXT_SECTION (objfile) = bfd_get_section_by_name (sym_bfd, ".text");
DBX_DATA_SECTION (objfile) = bfd_get_section_by_name (sym_bfd, ".data");
@@ -737,24 +740,30 @@ dbx_symfile_init (struct objfile *objfile)
static void
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)
+{
+ struct dbx_symfile_info *dbx = arg;
+
+ if (dbx->header_files != NULL)
{
- if (HEADER_FILES (objfile) != NULL)
- {
- int i = N_HEADER_FILES (objfile);
- struct header_file *hfiles = HEADER_FILES (objfile);
+ int i = dbx->n_header_files;
+ struct header_file *hfiles = dbx->header_files;
- while (--i >= 0)
- {
- xfree (hfiles[i].name);
- xfree (hfiles[i].vector);
- }
- xfree (hfiles);
+ while (--i >= 0)
+ {
+ xfree (hfiles[i].name);
+ xfree (hfiles[i].vector);
}
- xfree (objfile->deprecated_sym_stab_info);
+ xfree (hfiles);
}
- free_header_files ();
+
+ xfree (dbx);
}
+
/* 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.
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_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.
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
want this. */
@@ -3515,6 +3524,7 @@ stabsect_build_psymtabs (struct objfile *objfile, char *stab_name,
asection *stabsect;
asection *stabstrsect;
asection *text_sect;
+ struct dbx_symfile_info *dbx;
stabsect = bfd_get_section_by_name (sym_bfd, stab_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)"),
stab_name, stabstr_name);
- objfile->deprecated_sym_stab_info = (struct dbx_symfile_info *)
- xmalloc (sizeof (struct dbx_symfile_info));
- memset (objfile->deprecated_sym_stab_info, 0,
- sizeof (struct dbx_symfile_info));
+ dbx = XCNEW (struct dbx_symfile_info);
+ set_objfile_data (objfile, dbx_objfile_data_key, dbx);
text_sect = bfd_get_section_by_name (sym_bfd, text_name);
if (!text_sect)
@@ -3597,4 +3605,7 @@ void
_initialize_dbxread (void)
{
add_symtab_fns (&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 84efc59..29d5836 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -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
the objfile's filename cache. */
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);
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;
asymbol **symbol_table = NULL, **dyn_symbol_table = NULL;
asymbol *synthsyms;
+ struct dbx_symfile_info *dbx;
if (symtab_create_debug)
{
@@ -1265,16 +1266,13 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
memset ((char *) &ei, 0, sizeof (ei));
/* Allocate struct to keep track of the symfile. */
- objfile->deprecated_sym_stab_info = (struct dbx_symfile_info *)
- xmalloc (sizeof (struct dbx_symfile_info));
- memset ((char *) objfile->deprecated_sym_stab_info,
- 0, sizeof (struct dbx_symfile_info));
+ dbx = XCNEW (struct dbx_symfile_info);
+ set_objfile_data (objfile, dbx_objfile_data_key, dbx);
make_cleanup (free_elfinfo, (void *) objfile);
/* Process the normal ELF symbol table first. This may write some
- chain of info into the dbx_symfile_info in
- objfile->deprecated_sym_stab_info, which can later be used by
- elfstab_offset_sections. */
+ chain of info into the dbx_symfile_info of the objfile, which can
+ later be used by elfstab_offset_sections. */
storage_needed = bfd_get_symtab_upper_bound (objfile->obfd);
if (storage_needed < 0)
@@ -1467,15 +1465,14 @@ read_psyms (struct objfile *objfile)
dwarf2_build_psymtabs (objfile);
}
-/* This cleans up the objfile's deprecated_sym_stab_info pointer, and
- the chain of stab_section_info's, that might be dangling from
- it. */
+/* This cleans up the objfile's dbx symfile info, and the chain of
+ stab_section_info's, that might be dangling from it. */
static void
free_elfinfo (void *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;
ssi = dbxinfo->stab_section_info;
@@ -1512,11 +1509,6 @@ elf_new_init (struct objfile *ignore)
static void
elf_symfile_finish (struct objfile *objfile)
{
- if (objfile->deprecated_sym_stab_info != NULL)
- {
- xfree (objfile->deprecated_sym_stab_info);
- }
-
dwarf2_free_objfile (objfile);
}
@@ -1550,7 +1542,7 @@ void
elfstab_offset_sections (struct objfile *objfile, struct partial_symtab *pst)
{
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 *questionable = 0;
int i;
diff --git a/gdb/gdb-stabs.h b/gdb/gdb-stabs.h
index 402cc16..a136406 100644
--- a/gdb/gdb-stabs.h
+++ b/gdb/gdb-stabs.h
@@ -27,6 +27,10 @@
#if !defined (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,
while psymtabs are being built for the other symbol tables in the
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
- symbol files. A pointer to this structure is kept in the
- deprecated_sym_stab_info field of the objfile struct. */
+ symbol files. A pointer to this structure is kept in the objfile,
+ using the dbx_objfile_data_key. */
struct dbx_symfile_info
{
@@ -73,7 +77,8 @@ struct dbx_symfile_info
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_SIZE(o) (DBX_SYMFILE_INFO(o)->text_size)
#define DBX_SYMCOUNT(o) (DBX_SYMFILE_INFO(o)->symcount)
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 304f935..65162a1 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -322,15 +322,6 @@ struct objfile
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
for information shared by sym_init and sym_read). It is
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. */
/* FIXME: kettenis/20030711: This mechanism could replace
- deprecated_sym_stab_info and deprecated_sym_private
- entirely. */
+ deprecated_sym_private entirely. */
REGISTRY_FIELDS;
diff --git a/gdb/somread.c b/gdb/somread.c
index aeeb992..f603162 100644
--- a/gdb/somread.c
+++ b/gdb/somread.c
@@ -351,10 +351,6 @@ som_new_init (struct objfile *ignore)
static void
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. */