aboutsummaryrefslogtreecommitdiff
path: root/gdb/target.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2023-07-09 18:46:53 -0600
committerTom Tromey <tom@tromey.com>2023-07-10 15:43:08 -0600
commit57685738614a0089fba7f79669392b8d66d7c6af (patch)
tree0a18ff62ea218beea528c373209ddfbdfb12b22f /gdb/target.c
parent9fe01a376b2fb096e4836e985ba316ce9dc02399 (diff)
downloadgdb-57685738614a0089fba7f79669392b8d66d7c6af.zip
gdb-57685738614a0089fba7f79669392b8d66d7c6af.tar.gz
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/target.c')
-rw-r--r--gdb/target.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/gdb/target.c b/gdb/target.c
index fecbc89..16f43d0 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1173,7 +1173,16 @@ target_ops_ref_policy::decref (target_ops *t)
{
if (t->stratum () == process_stratum)
connection_list_remove (as_process_stratum_target (t));
- target_close (t);
+
+ for (inferior *inf : all_inferiors ())
+ gdb_assert (!inf->target_is_pushed (t));
+
+ fileio_handles_invalidate_target (t);
+
+ t->close ();
+
+ if (targetdebug)
+ gdb_printf (gdb_stdlog, "closing target\n");
}
}
@@ -3752,20 +3761,6 @@ debug_target::info () const
-void
-target_close (struct target_ops *targ)
-{
- for (inferior *inf : all_inferiors ())
- gdb_assert (!inf->target_is_pushed (targ));
-
- fileio_handles_invalidate_target (targ);
-
- targ->close ();
-
- if (targetdebug)
- gdb_printf (gdb_stdlog, "target_close ()\n");
-}
-
int
target_thread_alive (ptid_t ptid)
{