From: Tom Tromey Date: Wed, 26 Jun 2019 19:16:18 +0000 (-0600) Subject: Change solib-dsbt.c to use type-safe registry X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c294730c54f15ea69b18025025c0f191e5876301;p=binutils-gdb.git Change solib-dsbt.c to use type-safe registry This changes solib-dsbt.c to use the type-safe registry. 2019-07-10 Tom Tromey * solib-dsbt.c (struct dsbt_info): Add initializers. (solib_dsbt_pspace_data): Change type. (dsbt_pspace_data_cleanup): Remove. (get_dsbt_info, _initialize_dsbt_solib): Update. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1c759655561..1a957506d61 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2019-07-10 Tom Tromey + + * solib-dsbt.c (struct dsbt_info): Add initializers. + (solib_dsbt_pspace_data): Change type. + (dsbt_pspace_data_cleanup): Remove. + (get_dsbt_info, _initialize_dsbt_solib): Update. + 2019-07-10 Tom Tromey * spu-tdep.c (spu_overlay_data): Change type. diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index 3053c189802..59b195f491e 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -142,35 +142,29 @@ struct dsbt_info of loaded shared objects. ``main_executable_lm_info'' provides a way to get at this information so that it doesn't need to be frequently recomputed. Initialized by dsbt_relocate_main_executable. */ - struct lm_info_dsbt *main_executable_lm_info; + struct lm_info_dsbt *main_executable_lm_info = nullptr; /* Load maps for the main executable and the interpreter. These are obtained from ptrace. They are the starting point for getting into the program, and are required to find the solib list with the individual load maps for each module. */ - struct int_elf32_dsbt_loadmap *exec_loadmap; - struct int_elf32_dsbt_loadmap *interp_loadmap; + struct int_elf32_dsbt_loadmap *exec_loadmap = nullptr; + struct int_elf32_dsbt_loadmap *interp_loadmap = nullptr; /* Cached value for lm_base, below. */ - CORE_ADDR lm_base_cache; + CORE_ADDR lm_base_cache = 0; /* Link map address for main module. */ - CORE_ADDR main_lm_addr; + CORE_ADDR main_lm_addr = 0; - CORE_ADDR interp_text_sect_low; - CORE_ADDR interp_text_sect_high; - CORE_ADDR interp_plt_sect_low; - CORE_ADDR interp_plt_sect_high; + CORE_ADDR interp_text_sect_low = 0; + CORE_ADDR interp_text_sect_high = 0; + CORE_ADDR interp_plt_sect_low = 0; + CORE_ADDR interp_plt_sect_high = 0; }; /* Per-program-space data key. */ -static const struct program_space_data *solib_dsbt_pspace_data; - -static void -dsbt_pspace_data_cleanup (struct program_space *pspace, void *arg) -{ - xfree (arg); -} +static program_space_key solib_dsbt_pspace_data; /* Get the current dsbt data. If none is found yet, add it now. This function always returns a valid object. */ @@ -180,18 +174,11 @@ get_dsbt_info (void) { struct dsbt_info *info; - info = (struct dsbt_info *) program_space_data (current_program_space, - solib_dsbt_pspace_data); + info = solib_dsbt_pspace_data.get (current_program_space); if (info != NULL) return info; - info = XCNEW (struct dsbt_info); - set_program_space_data (current_program_space, solib_dsbt_pspace_data, info); - - info->lm_base_cache = 0; - info->main_lm_addr = 0; - - return info; + return solib_dsbt_pspace_data.emplace (current_program_space); } @@ -1043,9 +1030,6 @@ struct target_so_ops dsbt_so_ops; void _initialize_dsbt_solib (void) { - solib_dsbt_pspace_data - = register_program_space_data_with_cleanup (NULL, dsbt_pspace_data_cleanup); - dsbt_so_ops.relocate_section_addresses = dsbt_relocate_section_addresses; dsbt_so_ops.free_so = dsbt_free_so; dsbt_so_ops.clear_solib = dsbt_clear_solib;