From patchwork Sun Oct 2 17:04:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 55166 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F1E943854160 for ; Sun, 2 Oct 2022 17:06:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F1E943854160 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664730380; bh=5co8DjQf68hbEUueU+FA/GJR6hvVoptt/qXpGzQTXg4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=yi/Fyjy0dczg7XWgP5H4pYKCJv5vuPtE4KqKEDu5mJUBX6f2UAJX9ubSR4uBwqfMv knoia4ioW9Ows2yR3GQkzANrOHcnPSEjYD0bHk3rDU7drdkba/4cOPC9JvqX3AVt5/ n6oyCaXMVY4nzDlq9Aj0sl7fwUW4H2wIi2Ech3LY= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id C16F13858D32 for ; Sun, 2 Oct 2022 17:04:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C16F13858D32 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-311-SbZRyzQ5PO25uXMAqXCU3w-1; Sun, 02 Oct 2022 13:04:53 -0400 X-MC-Unique: SbZRyzQ5PO25uXMAqXCU3w-1 Received: by mail-wm1-f72.google.com with SMTP id b5-20020a05600c4e0500b003b499f99aceso7837009wmq.1 for ; Sun, 02 Oct 2022 10:04:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=5co8DjQf68hbEUueU+FA/GJR6hvVoptt/qXpGzQTXg4=; b=YS9Cyev1PAmMHEBos1YA0g4Ist6MP92UDmtJX0BBo1RVfg1XgiTFCFnrV+nbD1Go5i mGZo5JxX40y9MEnx8BuoCyzQW3N/DnxuoRt9gmjhGX3BYXlKg8IJksjea1cBmTckA04/ 3mUJSTzXO86WTN32ezWIyRdlusHeJcUafrMMkmePbOjoFofUWasN8ncPHNECTQNqVcl1 9rTUIo6jFr+Wtwyc3MdemcBGBkLOFCi3m+PCNE4ehHe1dfRl8qXcY/51q+Ev3cFy2i35 gKLS+rj+tceAUzkPaXrELD4HPPbj9bP1DgkRZsVMktBxKoVPbTHcklo8w1Prw6L0CcdF hwXQ== X-Gm-Message-State: ACrzQf3drl2VBq1/4XWixsW3mmdzeTK3rFPGL8pXppaIevWuA7WYZVAi jbjhiaozhqqlwhzWb5XR5oCClf0Xn1eZmaUGaXznMxWFD3QaS8nazG1SY3Bq14q+HgPyXGjGA/m oWfXkJsQoG8HU9k6DnxFofPU0RYC4AegMQQiTps+ME9LTTM2FC6aB8XJ8/o3P1//4qZ5SrK4+Aw == X-Received: by 2002:a5d:5224:0:b0:22e:397:d4da with SMTP id i4-20020a5d5224000000b0022e0397d4damr6284506wra.364.1664730291788; Sun, 02 Oct 2022 10:04:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM58bg8hQ+5qXnjYa64GrF9LE53VJf6mL11Qs+zLMxCSlv+MvWOmKWQ1wRNPv60EOgkWcX4zhA== X-Received: by 2002:a5d:5224:0:b0:22e:397:d4da with SMTP id i4-20020a5d5224000000b0022e0397d4damr6284494wra.364.1664730291504; Sun, 02 Oct 2022 10:04:51 -0700 (PDT) Received: from localhost (52.72.115.87.dyn.plus.net. [87.115.72.52]) by smtp.gmail.com with ESMTPSA id x5-20020a5d54c5000000b0022e32f4c06asm3697437wrv.11.2022.10.02.10.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Oct 2022 10:04:50 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCHv2 0/7] gdb: fix target_ops reference count for some cases Date: Sun, 2 Oct 2022 18:04:41 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: <20220921131200.3983844-1-aburgess@redhat.com> References: <20220921131200.3983844-1-aburgess@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" A complete rewrite (and expansion) of this patch after Simon's feedback. The original idea (from v1) is really covered by patches #3 and #5. There's still (maybe) an open question about the use of scoped_restore_pspace_and_thread vs scoped_restore_thread, but I hope I've addressed this question in the v1 thread. Do let me know if there's still any questions on this though. Patches #1 and #2 are target_ops ref-count related cleanups that I spotted while working on this updated series. Patch #4 is also a cleanup, moving some global functions to become member functions on the inferior class. Patch #6 is a completely random addition to add some extra maintenance output, I ended up using this while debugging patch #7, but this change isn't actually required at all. Patch #7 does relate to target_ops, and target_ops sharing, which is kind-of related to reference counting... maybe? I can easily drop this patch from the series if it turns out the idea in here is not taking GDB in the right direction. Thoughts, Thanks, Andrew --- Andrew Burgess (7): gdb/remote: remove some manual reference count handling gdb: remove decref_target gdb: have target_stack automate reference count handling gdb: remove the pop_all_targets (and friends) global functions gdb: ensure all targets are popped before an inferior is destructed gdb/maint: add core file name to 'maint info program-spaces' output gdb: some process_stratum_target should not be shared gdb/NEWS | 11 ++ gdb/corelow.c | 5 + gdb/doc/gdb.texinfo | 45 ++++- gdb/event-top.c | 3 +- gdb/inferior.c | 71 ++++++++ gdb/inferior.h | 26 ++- gdb/progspace.c | 18 +- gdb/remote.c | 40 +++-- gdb/scoped-mock-context.h | 2 +- gdb/target.c | 100 +++++------ gdb/target.h | 33 ++-- gdb/testsuite/gdb.multi/multi-core-files-1.c | 37 +++++ gdb/testsuite/gdb.multi/multi-core-files-2.c | 31 ++++ gdb/testsuite/gdb.multi/multi-core-files.exp | 156 ++++++++++++++++++ .../gdb.python/py-connection-removed.exp | 92 +++++++++++ gdb/top.c | 3 +- 16 files changed, 563 insertions(+), 110 deletions(-) create mode 100644 gdb/testsuite/gdb.multi/multi-core-files-1.c create mode 100644 gdb/testsuite/gdb.multi/multi-core-files-2.c create mode 100644 gdb/testsuite/gdb.multi/multi-core-files.exp create mode 100644 gdb/testsuite/gdb.python/py-connection-removed.exp