diff options
author | Doug Evans <dje@google.com> | 2009-09-11 18:51:31 +0000 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2009-09-11 18:51:31 +0000 |
commit | c1bd65d04220ff6e4a7356d4c2b8a16f9f3e3218 (patch) | |
tree | 13e03f6769634d4306d4fb64831747c90fe60428 | |
parent | cec03d703f8c80f4a3f98fe0e3e35dde7e9b1835 (diff) | |
download | gdb-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.
-rw-r--r-- | gdb/ChangeLog | 18 | ||||
-rw-r--r-- | gdb/arm-tdep.c | 4 | ||||
-rw-r--r-- | gdb/dwarf2read.c | 4 | ||||
-rw-r--r-- | gdb/objfiles.c | 25 | ||||
-rw-r--r-- | gdb/objfiles.h | 11 | ||||
-rw-r--r-- | gdb/python/py-objfile.c | 4 | ||||
-rw-r--r-- | gdb/python/py-type.c | 4 |
7 files changed, 55 insertions, 15 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index bc93f25..4bf160a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,21 @@ +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. diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 6e98469..9cf688c 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -5240,7 +5240,7 @@ arm_coff_make_msymbol_special(int val, struct minimal_symbol *msym) } 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; @@ -6032,7 +6032,7 @@ _initialize_arm_tdep (void) 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, diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 7f04427..9be9356 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -11837,7 +11837,7 @@ munmap_section_buffer (struct dwarf2_section_info *info) /* 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); @@ -11857,7 +11857,7 @@ void _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\ 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 *)); } diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 6abcb0f..62fa498 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -500,9 +500,18 @@ extern int in_plt_section (CORE_ADDR, char *); /* 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); diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index a483d33..a06a865 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -118,7 +118,7 @@ objfpy_set_printers (PyObject *o, PyObject *value, void *ignore) /* 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; @@ -166,7 +166,7 @@ void 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; diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index f23248c..590d90a 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -527,7 +527,7 @@ typy_str (PyObject *self) 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; @@ -643,7 +643,7 @@ gdbpy_initialize_types (void) 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; |