diff options
author | Tom Tromey <tromey@adacore.com> | 2019-06-26 11:41:00 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2019-06-27 08:01:18 -0600 |
commit | 1b7f24cd6b4e96c64bf82eba06be2c48942699fa (patch) | |
tree | 41b71d28305194c18e82616d98c091128dc840d4 /gdb/arm-tdep.c | |
parent | 3d507ff23b724ecb2b9a5a61cebd0fba275cfbc3 (diff) | |
download | gdb-1b7f24cd6b4e96c64bf82eba06be2c48942699fa.zip gdb-1b7f24cd6b4e96c64bf82eba06be2c48942699fa.tar.gz gdb-1b7f24cd6b4e96c64bf82eba06be2c48942699fa.tar.bz2 |
Change arm_objfile_data_key to use type-safe registry
After seeing Simon's patch to change arm_per_objfile to use new and
delete, I realized it is now simple to change arm_objfile_data_key to
use the type-safe registry.
gdb/ChangeLog
2019-06-27 Tom Tromey <tromey@adacore.com>
* arm-tdep.c (arm_objfile_data_key): Move lower. Change type to
objfile_key.
(arm_find_mapping_symbol, arm_record_special_symbol)
(_initialize_arm_tdep): Update.
(arm_objfile_data_free): Remove.
Diffstat (limited to 'gdb/arm-tdep.c')
-rw-r--r-- | gdb/arm-tdep.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 039b2f0..d244707 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -88,9 +88,6 @@ static int arm_debug; #define MSYMBOL_IS_SPECIAL(msym) \ MSYMBOL_TARGET_FLAG_1 (msym) -/* Per-objfile data used for mapping symbols. */ -static const struct objfile_data *arm_objfile_data_key; - struct arm_mapping_symbol { bfd_vma value; @@ -126,6 +123,9 @@ struct arm_per_objfile std::unique_ptr<bool[]> section_maps_sorted; }; +/* Per-objfile data used for mapping symbols. */ +static objfile_key<arm_per_objfile> arm_objfile_data_key; + /* The list of available "set arm ..." and "show arm ..." commands. */ static struct cmd_list_element *setarmcmdlist = NULL; static struct cmd_list_element *showarmcmdlist = NULL; @@ -356,9 +356,7 @@ arm_find_mapping_symbol (CORE_ADDR memaddr, CORE_ADDR *start) sec = find_pc_section (memaddr); if (sec != NULL) { - arm_per_objfile *data - = (struct arm_per_objfile *) objfile_data (sec->objfile, - arm_objfile_data_key); + arm_per_objfile *data = arm_objfile_data_key.get (sec->objfile); if (data != NULL) { unsigned int section_idx = sec->the_bfd_section->index; @@ -8529,14 +8527,6 @@ arm_coff_make_msymbol_special(int val, struct minimal_symbol *msym) } static void -arm_objfile_data_free (struct objfile *objfile, void *arg) -{ - struct arm_per_objfile *data = (struct arm_per_objfile *) arg; - - delete data; -} - -static void arm_record_special_symbol (struct gdbarch *gdbarch, struct objfile *objfile, asymbol *sym) { @@ -8548,13 +8538,10 @@ arm_record_special_symbol (struct gdbarch *gdbarch, struct objfile *objfile, if (name[1] != 'a' && name[1] != 't' && name[1] != 'd') return; - data = (struct arm_per_objfile *) objfile_data (objfile, - arm_objfile_data_key); + data = arm_objfile_data_key.get (objfile); if (data == NULL) - { - data = new arm_per_objfile (objfile->obfd->section_count); - set_objfile_data (objfile, arm_objfile_data_key, data); - } + data = arm_objfile_data_key.emplace (objfile, + objfile->obfd->section_count); arm_mapping_symbol_vec &map = data->section_maps[bfd_get_section (sym)->index]; @@ -9477,9 +9464,6 @@ _initialize_arm_tdep (void) gdbarch_register (bfd_arch_arm, arm_gdbarch_init, arm_dump_tdep); - arm_objfile_data_key - = register_objfile_data_with_cleanup (NULL, arm_objfile_data_free); - /* Add ourselves to objfile event chain. */ gdb::observers::new_objfile.attach (arm_exidx_new_objfile); arm_exidx_data_key |