From patchwork Wed Nov 30 15:52:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 61266 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 D0A0A385B505 for ; Wed, 30 Nov 2022 15:52:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D0A0A385B505 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669823560; bh=Ac0vfudDt+gEp8JQ1SfqxKUP1CuhakA5LaEX7ql9qOA=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=PEx+uiUT6MEVHrf301JvBs4PSk0tKOksIMNfyzTBnfOl5jAZHOF2ZqYmnK5CRZp8X Dmd/dnFEJzEvSNnf6fT9dsVxQ1JwVIe2la1RA4LXsCl22t8HvXCEaGDKeUq5J5MP1x bXk46E9CLncQALWfUp5zplkIwZXLS2w2QeIe+YzE= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by sourceware.org (Postfix) with ESMTPS id 10C03385B51E for ; Wed, 30 Nov 2022 15:52:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 10C03385B51E Received: by mail-io1-xd30.google.com with SMTP id n188so12562944iof.8 for ; Wed, 30 Nov 2022 07:52:18 -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:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ac0vfudDt+gEp8JQ1SfqxKUP1CuhakA5LaEX7ql9qOA=; b=xS0J7kphGwu7YPzzbxSP/z5S3zi/cdPQZQ975tpdkdm4NT7NZBb40pq8XCBRaVouBC Ko1KDIctuv/qan300jlHEHniRo0bYCXaFoSyjCHe7tuUU0atWA6b7gh9PPZzh7fuEup1 2HQCR3ogi01KN0xG8pBbM8eHLKH7yYRRSMv+tNT2HjvVEzwvI/RQqsYJhOR32F0Or5oq END9QQvkX/xHVjxr5vPx9w5kTHyFtYEo2o+bqF+fNHXpPrevxKdmooX3F6ONhqdVyYbI Vq7+Web/+eVy97ot7ux0VN5hrl3XQXKsGb5M70PEqOoc3mL6aTU46nzQH3L2MK20O7qn jIzg== X-Gm-Message-State: ANoB5plBskf+G+APai9siTR3USHU2x71b4ELtaMEFZ3D9oX+9gImu2YU lsmRO4CSEpNGIahJ6sYdKa5fMpE0AxC2PA== X-Google-Smtp-Source: AA0mqf4eFhBeFYTqaTF187fltV7jFrv48zKQQENzzrRLuYFcwcG5UuNMWfe5HVLJ19uZHeVRkPrDIw== X-Received: by 2002:a6b:f418:0:b0:6ce:8185:ad0 with SMTP id i24-20020a6bf418000000b006ce81850ad0mr20557404iog.213.1669823537344; Wed, 30 Nov 2022 07:52:17 -0800 (PST) Received: from localhost.localdomain (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id r3-20020a92ce83000000b002fa9a1fc421sm633590ilo.45.2022.11.30.07.52.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 07:52:16 -0800 (PST) To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Remove the_windows_nat_target global Date: Wed, 30 Nov 2022 08:52:07 -0700 Message-Id: <20221130155207.2444224-1-tromey@adacore.com> X-Mailer: git-send-email 2.34.3 MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I belatedly realized that the "the_windows_nat_target" global isn't really necessary. It's only used in one place, where 'this' would be simpler and clearer. This patch removes the global entirely. --- gdb/windows-nat.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 17422e15f80..900d8c3d3c4 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -387,10 +387,6 @@ struct windows_nat_target final : public x86_nat_target bool m_is_async = false; }; -/* This is a pointer and not a global specifically to avoid a C++ - "static initializer fiasco" situation. */ -static windows_nat_target *the_windows_nat_target; - static void check (BOOL ok, const char *file, int line) { @@ -629,7 +625,7 @@ windows_nat_target::delete_thread (ptid_t ptid, DWORD exit_code, target_pid_to_str (ptid).c_str (), (unsigned) exit_code); - ::delete_thread (find_thread_ptid (the_windows_nat_target, ptid)); + ::delete_thread (find_thread_ptid (this, ptid)); auto iter = std::find_if (windows_process.thread_list.begin (), windows_process.thread_list.end (), @@ -3126,8 +3122,9 @@ _initialize_windows_nat () calling x86_set_debug_register_length function in processor windows specific native file. */ - the_windows_nat_target = new windows_nat_target; - add_inf_child_target (the_windows_nat_target); + /* The target is not a global specifically to avoid a C++ "static + initializer fiasco" situation. */ + add_inf_child_target (new windows_nat_target); #ifdef __CYGWIN__ cygwin_internal (CW_SET_DOS_FILE_WARNING, 0);