From 27f0a4314aa5f81329e52dfbb4d06756415a4c53 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 7 May 2021 11:51:19 -0400 Subject: [PATCH] gdb: make target_close check that the target isn't pushed in all inferiors 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 | 5 +++++ gdb/target.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 50e87fb6538..b93a1dda8dd 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-05-07 Simon Marchi + + * target.c (target_close): Check in all inferiors that the + target is not pushed. + 2021-05-07 Aaron Merey * debuginfod-support.c (debuginfod_init): Remove. diff --git a/gdb/target.c b/gdb/target.c index 1f0741471d8..00f0acde758 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -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); -- 2.30.2