gdb: make target_close check that the target isn't pushed in all inferiors
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 7 May 2021 15:51:19 +0000 (11:51 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Fri, 7 May 2021 15:51:39 +0000 (11:51 -0400)
The target_close function currently checks that the target to be closed
isn't pushed in the current inferior:

    gdb_assert (!current_inferior ()->target_is_pushed (targ));

Normally, a target is closed when its refcount has dropped to 0, due to
not being used in any inferior anymore.  I think it would make sense to
change that assert to not only check in the current inferior, but to
check in all inferiors.  It would be quite bad (and a bug) to close a
target while it's still pushed in one of the non-current inferiors.

gdb/ChangeLog:

* target.c (target_close): Check in all inferiors that the
target is not pushed.

Change-Id: I6e37fc3f3476a0593da1e476604642b2de90f1d5

gdb/ChangeLog
gdb/target.c

index 50e87fb6538c4fa0dbe5bd6571c4189b0d4b1d53..b93a1dda8dd3b4c0f25c983318e6ea74a0f8086a 100644 (file)
@@ -1,3 +1,8 @@
+2021-05-07  Simon Marchi  <simon.marchi@efficios.com>
+
+       * target.c (target_close): Check in all inferiors that the
+       target is not pushed.
+
 2021-05-07  Aaron Merey  <amerey@redhat.com>
 
        * debuginfod-support.c (debuginfod_init): Remove.
index 1f0741471d829294ddbbca17c55ac564908b305e..00f0acde7586ee15e89c3774b0e44596c328d286 100644 (file)
@@ -3734,7 +3734,8 @@ debug_target::info () const
 void
 target_close (struct target_ops *targ)
 {
-  gdb_assert (!current_inferior ()->target_is_pushed (targ));
+  for (inferior *inf : all_inferiors ())
+    gdb_assert (!inf->target_is_pushed (targ));
 
   fileio_handles_invalidate_target (targ);
 
This page took 0.030419 seconds and 4 git commands to generate.