aboutsummaryrefslogtreecommitdiff
path: root/gdb/objfiles.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2009-09-11 18:51:31 +0000
committerDoug Evans <dje@google.com>2009-09-11 18:51:31 +0000
commitc1bd65d04220ff6e4a7356d4c2b8a16f9f3e3218 (patch)
tree13e03f6769634d4306d4fb64831747c90fe60428 /gdb/objfiles.c
parentcec03d703f8c80f4a3f98fe0e3e35dde7e9b1835 (diff)
downloadgdb-c1bd65d04220ff6e4a7356d4c2b8a16f9f3e3218.zip
gdb-c1bd65d04220ff6e4a7356d4c2b8a16f9f3e3218.tar.gz
gdb-c1bd65d04220ff6e4a7356d4c2b8a16f9f3e3218.tar.bz2
* objfiles.c (struct objfile_data): Delete member cleanup and replace
with save, free. (register_objfile_data_with_cleanup): Delete arg cleanup and replace with save, free. All callers updated. (clear_objfile_data): Replace cleanup loop with separate save and free loops. * objfiles.h (register_objfile_data_with_cleanup): Update. * arm-tdep.c (arm_objfile_data_free): Renamed from arm_objfile_data_cleanup, all callers updated. * dwarf2read.c (dwarf2_per_objfile_free): Renamed from dwarf2_per_objfile_cleanup, all callers updated. * python/py-objfile.c (py_free_objfile): Renamed from clean_up_objfile, all callers updated. * python/py-type.c (save_objfile_types): Renamed from clean_up_objfile_types, all callers updated.
Diffstat (limited to 'gdb/objfiles.c')
-rw-r--r--gdb/objfiles.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 3fa68f6..2c9da3d 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -975,7 +975,8 @@ in_plt_section (CORE_ADDR pc, char *name)
struct objfile_data
{
unsigned index;
- void (*cleanup) (struct objfile *, void *);
+ void (*save) (struct objfile *, void *);
+ void (*free) (struct objfile *, void *);
};
struct objfile_data_registration
@@ -993,7 +994,8 @@ struct objfile_data_registry
static struct objfile_data_registry objfile_data_registry = { NULL, 0 };
const struct objfile_data *
-register_objfile_data_with_cleanup (void (*cleanup) (struct objfile *, void *))
+register_objfile_data_with_cleanup (void (*save) (struct objfile *, void *),
+ void (*free) (struct objfile *, void *))
{
struct objfile_data_registration **curr;
@@ -1005,7 +1007,8 @@ register_objfile_data_with_cleanup (void (*cleanup) (struct objfile *, void *))
(*curr)->next = NULL;
(*curr)->data = XMALLOC (struct objfile_data);
(*curr)->data->index = objfile_data_registry.num_registrations++;
- (*curr)->data->cleanup = cleanup;
+ (*curr)->data->save = save;
+ (*curr)->data->free = free;
return (*curr)->data;
}
@@ -1013,7 +1016,7 @@ register_objfile_data_with_cleanup (void (*cleanup) (struct objfile *, void *))
const struct objfile_data *
register_objfile_data (void)
{
- return register_objfile_data_with_cleanup (NULL);
+ return register_objfile_data_with_cleanup (NULL, NULL);
}
static void
@@ -1041,11 +1044,21 @@ clear_objfile_data (struct objfile *objfile)
gdb_assert (objfile->data != NULL);
+ /* Process all the save handlers. */
+
+ for (registration = objfile_data_registry.registrations, i = 0;
+ i < objfile->num_data;
+ registration = registration->next, i++)
+ if (objfile->data[i] != NULL && registration->data->save != NULL)
+ registration->data->save (objfile, objfile->data[i]);
+
+ /* Now process all the free handlers. */
+
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]);
+ if (objfile->data[i] != NULL && registration->data->free != NULL)
+ registration->data->free (objfile, objfile->data[i]);
memset (objfile->data, 0, objfile->num_data * sizeof (void *));
}