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.
+2009-09-11 Doug Evans <dje@google.com>
+
+ * 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.
+
2009-09-11 Tom Tromey <tromey@redhat.com>
* dwarf2loc.c (struct piece_closure) <arch>: New field.
}
static void
-arm_objfile_data_cleanup (struct objfile *objfile, void *arg)
+arm_objfile_data_free (struct objfile *objfile, void *arg)
{
struct arm_per_objfile *data = arg;
unsigned int i;
gdbarch_register (bfd_arch_arm, arm_gdbarch_init, arm_dump_tdep);
arm_objfile_data_key
- = register_objfile_data_with_cleanup (arm_objfile_data_cleanup);
+ = register_objfile_data_with_cleanup (NULL, arm_objfile_data_free);
/* Register an ELF OS ABI sniffer for ARM binaries. */
gdbarch_register_osabi_sniffer (bfd_arch_arm,
/* munmap debug sections for OBJFILE, if necessary. */
static void
-dwarf2_per_objfile_cleanup (struct objfile *objfile, void *d)
+dwarf2_per_objfile_free (struct objfile *objfile, void *d)
{
struct dwarf2_per_objfile *data = d;
munmap_section_buffer (&data->info);
_initialize_dwarf2_read (void)
{
dwarf2_objfile_data_key
- = register_objfile_data_with_cleanup (dwarf2_per_objfile_cleanup);
+ = register_objfile_data_with_cleanup (NULL, dwarf2_per_objfile_free);
add_prefix_cmd ("dwarf2", class_maintenance, set_dwarf2_cmd, _("\
Set DWARF 2 specific variables.\n\
struct objfile_data
{
unsigned index;
- void (*cleanup) (struct objfile *, void *);
+ void (*save) (struct objfile *, void *);
+ void (*free) (struct objfile *, void *);
};
struct objfile_data_registration
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;
(*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;
}
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
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 *));
}
/* Keep a registry of per-objfile data-pointers required by other GDB
modules. */
+/* Allocate an entry in the per-objfile registry. */
extern const struct objfile_data *register_objfile_data (void);
+
+/* Allocate an entry in the per-objfile registry.
+ SAVE and FREE are called when clearing objfile data.
+ First all registered SAVE functions are called.
+ Then all registered FREE functions are called.
+ Either or both of SAVE, FREE may be NULL. */
extern const struct objfile_data *register_objfile_data_with_cleanup
- (void (*cleanup) (struct objfile *, void *));
+ (void (*save) (struct objfile *, void *),
+ void (*free) (struct objfile *, void *));
+
extern void clear_objfile_data (struct objfile *objfile);
extern void set_objfile_data (struct objfile *objfile,
const struct objfile_data *data, void *value);
/* Clear the OBJFILE pointer in an Objfile object and remove the
reference. */
static void
-clean_up_objfile (struct objfile *objfile, void *datum)
+py_free_objfile (struct objfile *objfile, void *datum)
{
struct cleanup *cleanup;
objfile_object *object = datum;
gdbpy_initialize_objfile (void)
{
objfpy_objfile_data_key
- = register_objfile_data_with_cleanup (clean_up_objfile);
+ = register_objfile_data_with_cleanup (NULL, py_free_objfile);
if (PyType_Ready (&objfile_object_type) < 0)
return;
static const struct objfile_data *typy_objfile_data_key;
static void
-clean_up_objfile_types (struct objfile *objfile, void *datum)
+save_objfile_types (struct objfile *objfile, void *datum)
{
type_object *obj = datum;
htab_t copied_types;
int i;
typy_objfile_data_key
- = register_objfile_data_with_cleanup (clean_up_objfile_types);
+ = register_objfile_data_with_cleanup (save_objfile_types, NULL);
if (PyType_Ready (&type_object_type) < 0)
return;