From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 22D253857C7A for ; Thu, 6 May 2021 14:28:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 22D253857C7A X-ASG-Debug-ID: 1620311291-0c856e6cd51208200001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id CZVQiBcAvS2sr2JF (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 06 May 2021 10:28:11 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) by smtp.ebox.ca (Postfix) with ESMTP id 90410441B21; Thu, 6 May 2021 10:28:11 -0400 (EDT) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.157.6 X-Barracuda-Effective-Source-IP: 192-222-157-6.qc.cable.ebox.net[192.222.157.6] X-Barracuda-Apparent-Source-IP: 192.222.157.6 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/5] gdb: make target_close check that the target isn't pushed in all inferiors Date: Thu, 6 May 2021 10:28:02 -0400 X-ASG-Orig-Subj: [PATCH 1/5] gdb: make target_close check that the target isn't pushed in all inferiors Message-Id: <20210506142806.30363-1-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1620311291 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 1290 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.89756 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-19.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 May 2021 14:28:47 -0000 From: Simon Marchi 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)); When a target is closed, it's normally because its refcount has dropped to 0, because it's not 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/target.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gdb/target.c b/gdb/target.c index 1f0741471d82..00f0acde7586 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.1