From patchwork Fri Nov 18 16:42:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 55311 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 40FEF384F4AE for ; Fri, 18 Nov 2022 16:45:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 40FEF384F4AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668789904; bh=tF0Ig/vASunKaJG+/k0MHkEvFA5+xSxFho9YtiBU+v8=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Ibzw/N3+iVquVCTMq+FBPXCUEgAy1VOjjnaMOTAmRQ7tKVg6rT3FY6r9paMjR+ynq 3L1YRiSupfWQel5xhjC3VJgWJ67gb0NdRln8GjHBTbTTUqWSRUB60KhFk4sMRhgoqZ qOUP0UalU1nmxzZh12upt6bLJLRgNU0FevzaJS60= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 7368F384F6E3 for ; Fri, 18 Nov 2022 16:43:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7368F384F6E3 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-344-lVbBmkJcPMKJaAr6BioohQ-1; Fri, 18 Nov 2022 11:43:02 -0500 X-MC-Unique: lVbBmkJcPMKJaAr6BioohQ-1 Received: by mail-wm1-f69.google.com with SMTP id c126-20020a1c3584000000b003cfffcf7c1aso2463585wma.0 for ; Fri, 18 Nov 2022 08:43:02 -0800 (PST) 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:message-id:reply-to; bh=tF0Ig/vASunKaJG+/k0MHkEvFA5+xSxFho9YtiBU+v8=; b=g450/fOvFsy/izYtDkMiXxIUEe4l+1svOd5Pc5vCsLgyJ4IhkJpZfdkD9AL2I91OoL PZbemuTizVaSAocOkQvRtK5ca4tp9sgjgHOACmuuM3DOfQOVShK6ROoUSfyHYwVDHzGE xhBRDZlOBtiZ4CofcRrZ1L5cVt6aSJLsHyQSZffshIvym7OJ2mv9cVak3tBmOdir3G5H xaoKqytTxwTXHdO7+GZR3iz75b6akFAX2wVhB7LIOXmPrex4JMgoMajtnUiGYZAkl/aS SaNqi6CrKMUeciCli5MDhyFlaRdx3AZ6BKJu2X8p7gRl1KwJ3QeodwwZIJRzOYdJvxCa XdsA== X-Gm-Message-State: ANoB5pk1cc/c29nBxwXfpQjd33zeixwaQGaACGAUh00bFQFhnDnxL+dL oQUCJ1eduufisls7U/fBjIdWoUu0rlN45TAceM1JLFO1wpSJv6QcnFQJaIqwze+9wLkbNEFxef1 cGoDcKsY1xuVnpgTu94zRzNGfa3Da75hPp4piq7bMWQ+ROgM1yLfxjjO2JUod82mgVfIGc0U1AQ == X-Received: by 2002:a7b:c456:0:b0:3a5:f600:502e with SMTP id l22-20020a7bc456000000b003a5f600502emr5551748wmi.39.1668789781524; Fri, 18 Nov 2022 08:43:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf4DsLGruNabP2hhJS9o6Q7QOwP1AKgVCrwB3Xit03Uo57fSieqVS6DnDJf/mKukAtdQmJ0ASg== X-Received: by 2002:a7b:c456:0:b0:3a5:f600:502e with SMTP id l22-20020a7bc456000000b003a5f600502emr5551733wmi.39.1668789781182; Fri, 18 Nov 2022 08:43:01 -0800 (PST) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id l10-20020adff48a000000b002366ded5864sm3941335wro.116.2022.11.18.08.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 08:43:00 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv3 0/7] gdb: fix target_ops reference count for some cases Date: Fri, 18 Nov 2022 16:42:51 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham 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" Changes in v3: - Rebase onto current upstream/master, resolve merge conflicts. - Updated the test in patch 7 to fix a failure when using the native-extended-gdbserver board. Changes in v2: 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. 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 | 70 +++++++ gdb/inferior.h | 26 ++- gdb/progspace.c | 18 +- gdb/remote.c | 40 ++-- gdb/scoped-mock-context.h | 2 +- gdb/target.c | 99 ++++------ 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 | 172 ++++++++++++++++++ .../gdb.python/py-connection-removed.exp | 92 ++++++++++ gdb/top.c | 3 +- 16 files changed, 578 insertions(+), 109 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 base-commit: f9f88aede3bb84efd088a59a5f6bccb3a6bb6516