diff options
author | Tom Tromey <tom@tromey.com> | 2023-07-09 18:46:53 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-07-10 15:43:08 -0600 |
commit | 57685738614a0089fba7f79669392b8d66d7c6af (patch) | |
tree | 0a18ff62ea218beea528c373209ddfbdfb12b22f /gdb/solib-svr4.c | |
parent | 9fe01a376b2fb096e4836e985ba316ce9dc02399 (diff) | |
download | fsf-binutils-gdb-57685738614a0089fba7f79669392b8d66d7c6af.zip fsf-binutils-gdb-57685738614a0089fba7f79669392b8d66d7c6af.tar.gz fsf-binutils-gdb-57685738614a0089fba7f79669392b8d66d7c6af.tar.bz2 |
Remove target_close
I noticed that target_close is only called in two places:
solib-svr4.c, and target_ops_ref_policy::decref.
This patch fixes the former by changing target_bfd_reopen to return a
target_ops_up and then fixing the sole caller. Then it removes
target_close by inlining its body into the decref method.
The advantage of this approach is that targets are now automatically
managed.
Regression tested on x86-64 Fedora 38.
Approved-By: Andrew Burgess <aburgess@redhat.com>
Diffstat (limited to 'gdb/solib-svr4.c')
-rw-r--r-- | gdb/solib-svr4.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 0ef8372..f1fa437 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -2425,7 +2425,7 @@ enable_break (struct svr4_info *info, int from_tty) CORE_ADDR load_addr = 0; int load_addr_found = 0; int loader_found_in_list = 0; - struct target_ops *tmp_bfd_target; + target_ops_up tmp_bfd_target; sym_addr = 0; @@ -2482,8 +2482,8 @@ enable_break (struct svr4_info *info, int from_tty) if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)) { CORE_ADDR space_size = (CORE_ADDR) 1 << addr_bit; - CORE_ADDR tmp_entry_point = exec_entry_point (tmp_bfd.get (), - tmp_bfd_target); + CORE_ADDR tmp_entry_point + = exec_entry_point (tmp_bfd.get (), tmp_bfd_target.get ()); gdb_assert (load_addr < space_size); @@ -2512,7 +2512,8 @@ enable_break (struct svr4_info *info, int from_tty) inferior_ptid, target_gdbarch ()); load_addr = (regcache_read_pc (regcache) - - exec_entry_point (tmp_bfd.get (), tmp_bfd_target)); + - exec_entry_point (tmp_bfd.get (), + tmp_bfd_target.get ())); } if (!loader_found_in_list) @@ -2564,12 +2565,7 @@ enable_break (struct svr4_info *info, int from_tty) target, this will always produce an unrelocated value. */ sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (), sym_addr, - tmp_bfd_target); - - /* We're done with both the temporary bfd and target. Closing - the target closes the underlying bfd, because it holds the - only remaining reference. */ - target_close (tmp_bfd_target); + tmp_bfd_target.get ()); if (sym_addr != 0) { |