summaryrefslogtreecommitdiff
path: root/gdb/coffread.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-12-12 16:22:32 +0000
committerTom Tromey <tromey@redhat.com>2012-12-12 16:22:32 +0000
commitbf9634c4b04ae648d4a5c2a02ac053a477e738fd (patch)
treef0cf32f2e886c3f90fd219454f26fb5057c990f4 /gdb/coffread.c
parent833dd807efacd91c7f6a2938e655e341d7cd06cf (diff)
downloadgdb-bf9634c4b04ae648d4a5c2a02ac053a477e738fd.tar.gz
* coffread.c (coff_objfile_data_key): New global.
(coff_symfile_init): Use set_objfile_data. (coff_symfile_read): Use objfile_data. (coff_symfile_finish): Don't free deprecated_sym_private. (coff_free_info): New function. (_initialize_coffread): Initialize coff_objfile_data_key. * mdebugread.c (pending_list): Update comment. * objfiles.h (struct objfile) <deprecated_sym_private>: Remove. * symfile.c (reread_symbols): Don't mention deprecated_sym_private. * xcoffread.c (xcoff_objfile_data_key): New global. (XCOFF_DATA): New macro. (process_linenos, enter_line_range, xcoff_next_symbol_text) (read_xcoff_symtab, coff_getfilename, read_symbol_lineno): Use XCOFF_DATA. (xcoff_new_init) Use set_objfile_data. (xcoff_symfile_finish): Don't free deprecated_sym_private. (init_stringtab, swap_sym, scan_xcoff_symtab) (xcoff_get_toc_offset, xcoff_initial_scan): Use XCOFF_DATA. (xcoff_free_info): New function. (_initialize_xcoffread): Initialize xcoff_objfile_data_key.
Diffstat (limited to 'gdb/coffread.c')
-rw-r--r--gdb/coffread.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 94d0554dab5..56ed5aea0d1 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -47,6 +47,10 @@
extern void _initialize_coffread (void);
+/* Key for COFF-associated data. */
+
+static const struct objfile_data *coff_objfile_data_key;
+
/* The objfile we are currently reading. */
static struct objfile *coffread_objfile;
@@ -451,17 +455,15 @@ static void
coff_symfile_init (struct objfile *objfile)
{
struct dbx_symfile_info *dbx;
+ struct coff_symfile_info *coff;
/* 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
- = xmalloc (sizeof (struct coff_symfile_info));
-
- memset (objfile->deprecated_sym_private, 0,
- sizeof (struct coff_symfile_info));
+ coff = XCNEW (struct coff_symfile_info);
+ set_objfile_data (objfile, coff_objfile_data_key, coff);
/* COFF objects may be reordered, so set OBJF_REORDERED. If we
find this causes a significant slowdown in gdb then we could
@@ -526,7 +528,7 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags)
struct cleanup *back_to, *cleanup_minimal_symbols;
int stabstrsize;
- info = (struct coff_symfile_info *) objfile->deprecated_sym_private;
+ info = objfile_data (objfile, coff_objfile_data_key);
dbxinfo = DBX_SYMFILE_INFO (objfile);
symfile_bfd = abfd; /* Kludge for swap routines. */
@@ -680,11 +682,6 @@ coff_new_init (struct objfile *ignore)
static void
coff_symfile_finish (struct objfile *objfile)
{
- if (objfile->deprecated_sym_private != NULL)
- {
- xfree (objfile->deprecated_sym_private);
- }
-
/* Let stabs reader clean up. */
stabsread_clear_cache ();
@@ -2199,8 +2196,19 @@ static const struct sym_fns coff_sym_fns =
&psym_functions
};
+/* Free the per-objfile COFF data. */
+
+static void
+coff_free_info (struct objfile *objfile, void *arg)
+{
+ xfree (arg);
+}
+
void
_initialize_coffread (void)
{
add_symtab_fns (&coff_sym_fns);
+
+ coff_objfile_data_key = register_objfile_data_with_cleanup (NULL,
+ coff_free_info);
}