diff options
author | Tom Tromey <tom@tromey.com> | 2019-04-30 21:58:50 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-05-08 16:01:50 -0600 |
commit | 092324387247f92c66f25a3e1927cf8821bb4943 (patch) | |
tree | 800e218886f19f9c389d580997926977a492592b /gdb | |
parent | 7b4a314f8b9b50c2289ca6b5d21513052c48730b (diff) | |
download | gdb-092324387247f92c66f25a3e1927cf8821bb4943.zip gdb-092324387247f92c66f25a3e1927cf8821bb4943.tar.gz gdb-092324387247f92c66f25a3e1927cf8821bb4943.tar.bz2 |
Convert solib-svr4.c to type-safe registry API
This changes solib-svr4y.c to use the type-safe registry API.
gdb/ChangeLog
2019-05-08 Tom Tromey <tom@tromey.com>
* solib-svr4.c (struct svr4_info): Add initializers and
destructor.
<probes_table>: Now an htab_up.
(solib_svr4_pspace_data): Change type.
(free_probes_table): Simplify.
(~svr4_info): Rename from svr4_pspace_data_cleanup.
(get_svr4_info, probes_table_htab_remove_objfile_probes)
(probes_table_remove_objfile_probes, register_solib_event_probe)
(solib_event_probe_at, svr4_update_solib_event_breakpoint)
(_initialize_svr4_solib): Update.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 13 | ||||
-rw-r--r-- | gdb/solib-svr4.c | 76 |
2 files changed, 45 insertions, 44 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f93c27c..49bc5b7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,18 @@ 2019-05-08 Tom Tromey <tom@tromey.com> + * solib-svr4.c (struct svr4_info): Add initializers and + destructor. + <probes_table>: Now an htab_up. + (solib_svr4_pspace_data): Change type. + (free_probes_table): Simplify. + (~svr4_info): Rename from svr4_pspace_data_cleanup. + (get_svr4_info, probes_table_htab_remove_objfile_probes) + (probes_table_remove_objfile_probes, register_solib_event_probe) + (solib_event_probe_at, svr4_update_solib_event_breakpoint) + (_initialize_svr4_solib): Update. + +2019-05-08 Tom Tromey <tom@tromey.com> + * remote.c (remote_pspace_data): Change type. (remote_pspace_data_cleanup): Remove. (get_remote_exec_file, set_pspace_remote_exec_file) diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 2aa7b95..2828c96 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -322,53 +322,53 @@ lm_addr_check (const struct so_list *so, bfd *abfd) struct svr4_info { - CORE_ADDR debug_base; /* Base of dynamic linker structures. */ + svr4_info () = default; + ~svr4_info (); + + /* Base of dynamic linker structures. */ + CORE_ADDR debug_base = 0; /* Validity flag for debug_loader_offset. */ - int debug_loader_offset_p; + int debug_loader_offset_p = 0; /* Load address for the dynamic linker, inferred. */ - CORE_ADDR debug_loader_offset; + CORE_ADDR debug_loader_offset = 0; /* Name of the dynamic linker, valid if debug_loader_offset_p. */ - char *debug_loader_name; + char *debug_loader_name = nullptr; /* Load map address for the main executable. */ - 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; /* Nonzero if the list of objects was last obtained from the target via qXfer:libraries-svr4:read. */ - int using_xfer; + int using_xfer = 0; /* Table of struct probe_and_action instances, used by the probes-based interface to map breakpoint addresses to probes and their associated actions. Lookup is performed using probe_and_action->prob->address. */ - htab_t probes_table; + htab_up probes_table; /* List of objects loaded into the inferior, used by the probes- based interface. */ - struct so_list *solib_list; + struct so_list *solib_list = nullptr; }; /* Per-program-space data key. */ -static const struct program_space_data *solib_svr4_pspace_data; +static const struct program_space_key<svr4_info> solib_svr4_pspace_data; /* Free the probes table. */ static void free_probes_table (struct svr4_info *info) { - if (info->probes_table == NULL) - return; - - htab_delete (info->probes_table); - info->probes_table = NULL; + info->probes_table.reset (nullptr); } /* Free the solib list. */ @@ -380,15 +380,9 @@ free_solib_list (struct svr4_info *info) info->solib_list = NULL; } -static void -svr4_pspace_data_cleanup (struct program_space *pspace, void *arg) +svr4_info::~svr4_info () { - struct svr4_info *info = (struct svr4_info *) arg; - - free_probes_table (info); - free_solib_list (info); - - xfree (info); + free_solib_list (this); } /* Get the svr4 data for program space PSPACE. If none is found yet, add it now. @@ -397,15 +391,11 @@ svr4_pspace_data_cleanup (struct program_space *pspace, void *arg) static struct svr4_info * get_svr4_info (program_space *pspace) { - struct svr4_info *info; + struct svr4_info *info = solib_svr4_pspace_data.get (pspace); - info = (struct svr4_info *) program_space_data (pspace, - solib_svr4_pspace_data); - if (info != NULL) - return info; + if (info == NULL) + info = solib_svr4_pspace_data.emplace (pspace); - info = XCNEW (struct svr4_info); - set_program_space_data (pspace, solib_svr4_pspace_data, info); return info; } @@ -1677,7 +1667,8 @@ probes_table_htab_remove_objfile_probes (void **slot, void *info) struct objfile *objfile = (struct objfile *) info; if (pa->objfile == objfile) - htab_clear_slot (get_svr4_info (objfile->pspace)->probes_table, slot); + htab_clear_slot (get_svr4_info (objfile->pspace)->probes_table.get (), + slot); return 1; } @@ -1689,7 +1680,7 @@ probes_table_remove_objfile_probes (struct objfile *objfile) { svr4_info *info = get_svr4_info (objfile->pspace); if (info->probes_table != nullptr) - htab_traverse_noresize (info->probes_table, + htab_traverse_noresize (info->probes_table.get (), probes_table_htab_remove_objfile_probes, objfile); } @@ -1706,12 +1697,12 @@ register_solib_event_probe (svr4_info *info, struct objfile *objfile, /* Create the probes table, if necessary. */ if (info->probes_table == NULL) - info->probes_table = htab_create_alloc (1, hash_probe_and_action, - equal_probe_and_action, - xfree, xcalloc, xfree); + info->probes_table.reset (htab_create_alloc (1, hash_probe_and_action, + equal_probe_and_action, + xfree, xcalloc, xfree)); lookup.address = address; - slot = htab_find_slot (info->probes_table, &lookup, INSERT); + slot = htab_find_slot (info->probes_table.get (), &lookup, INSERT); gdb_assert (*slot == HTAB_EMPTY_ENTRY); pa = XCNEW (struct probe_and_action); @@ -1734,7 +1725,7 @@ solib_event_probe_at (struct svr4_info *info, CORE_ADDR address) void **slot; lookup.address = address; - slot = htab_find_slot (info->probes_table, &lookup, NO_INSERT); + slot = htab_find_slot (info->probes_table.get (), &lookup, NO_INSERT); if (slot == NULL) return NULL; @@ -2012,8 +2003,7 @@ svr4_update_solib_event_breakpoint (struct breakpoint *b, void *arg) struct svr4_info *info; struct probe_and_action *pa; - info = ((struct svr4_info *) - program_space_data (loc->pspace, solib_svr4_pspace_data)); + info = solib_svr4_pspace_data.get (loc->pspace); if (info == NULL || info->probes_table == NULL) continue; @@ -3243,8 +3233,6 @@ void _initialize_svr4_solib (void) { solib_svr4_data = gdbarch_data_register_pre_init (solib_svr4_init); - solib_svr4_pspace_data - = register_program_space_data_with_cleanup (NULL, svr4_pspace_data_cleanup); svr4_so_ops.relocate_section_addresses = svr4_relocate_section_addresses; svr4_so_ops.free_so = svr4_free_so; |