aboutsummaryrefslogtreecommitdiff
path: root/gdb/objfiles.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2008-05-02 20:38:16 +0000
committerDaniel Jacobowitz <drow@false.org>2008-05-02 20:38:16 +0000
commit60c5725ca96c0d9c347f04d37f0e1f6d0f263f41 (patch)
tree387933a649a79c50e3a372850696b04dbe644995 /gdb/objfiles.c
parent574dffa2b953e04f57a359f0e19b2ba42fbcf2a6 (diff)
downloadgdb-60c5725ca96c0d9c347f04d37f0e1f6d0f263f41.zip
gdb-60c5725ca96c0d9c347f04d37f0e1f6d0f263f41.tar.gz
gdb-60c5725ca96c0d9c347f04d37f0e1f6d0f263f41.tar.bz2
* Makefile.in (arm-tdep.o): Update.
* arm-tdep.c (arm_objfile_data_key, struct arm_mapping_symbol) (struct arm_per_objfile, arm_compare_mapping_symbols): New. (arm_pc_is_thumb): Use mapping symbols. (arm_objfile_data_cleanup, arm_record_special_symbol): New. (arm_gdbarch_init): Call set_gdbarch_record_special_symbol. (_initialize_arm_tdep): Initialize arm_objfile_data_key. * elfread.c (elf_symtab_read): Use gdbarch_record_special_symbol. * gdbarch.sh: Add record_special_symbol. * gdbarch.c, gdbarch.h: Regenerated. * objfiles.c (struct objfile_data): Add cleanup member. (register_objfile_data_with_cleanup): New function, from register_objfile_data. (register_objfile_data): Use it. (objfile_free_data): Call clear_objfile_data. (clear_objfile_data): Call cleanup functions. * objfiles.h (register_objfile_data_with_cleanup): Declare.
Diffstat (limited to 'gdb/objfiles.c')
-rw-r--r--gdb/objfiles.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 0234dce..38768cc 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -821,6 +821,7 @@ in_plt_section (CORE_ADDR pc, char *name)
struct objfile_data
{
unsigned index;
+ void (*cleanup) (struct objfile *, void *);
};
struct objfile_data_registration
@@ -838,7 +839,7 @@ struct objfile_data_registry
static struct objfile_data_registry objfile_data_registry = { NULL, 0 };
const struct objfile_data *
-register_objfile_data (void)
+register_objfile_data_with_cleanup (void (*cleanup) (struct objfile *, void *))
{
struct objfile_data_registration **curr;
@@ -850,10 +851,17 @@ register_objfile_data (void)
(*curr)->next = NULL;
(*curr)->data = XMALLOC (struct objfile_data);
(*curr)->data->index = objfile_data_registry.num_registrations++;
+ (*curr)->data->cleanup = cleanup;
return (*curr)->data;
}
+const struct objfile_data *
+register_objfile_data (void)
+{
+ return register_objfile_data_with_cleanup (NULL);
+}
+
static void
objfile_alloc_data (struct objfile *objfile)
{
@@ -866,6 +874,7 @@ static void
objfile_free_data (struct objfile *objfile)
{
gdb_assert (objfile->data != NULL);
+ clear_objfile_data (objfile);
xfree (objfile->data);
objfile->data = NULL;
}
@@ -873,7 +882,17 @@ objfile_free_data (struct objfile *objfile)
void
clear_objfile_data (struct objfile *objfile)
{
+ struct objfile_data_registration *registration;
+ int i;
+
gdb_assert (objfile->data != NULL);
+
+ for (registration = objfile_data_registry.registrations, i = 0;
+ i < objfile->num_data;
+ registration = registration->next, i++)
+ if (objfile->data[i] != NULL && registration->data->cleanup)
+ registration->data->cleanup (objfile, objfile->data[i]);
+
memset (objfile->data, 0, objfile->num_data * sizeof (void *));
}