From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by sourceware.org (Postfix) with ESMTPS id DB2D03853D45 for ; Thu, 17 Nov 2022 18:43:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DB2D03853D45 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x12e.google.com with SMTP id l6so1367719ilq.3 for ; Thu, 17 Nov 2022 10:43:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=sipj4v9pBU7MXw2jSkGGkeIUi1pyn4zfDYtJOy43fYs=; b=hOEgcT0pB1gL5wZaMxZa2VgPJJEl3dGNbq33NLLjeVfJYdmhtw+KVec5SsHUM4enqG LRpVusjPemLn8vlZpG7sjZ3wDNN3Rs+cbBvh91y2mqJ9vSiQIE6Fr3+Evf1ecl0DHg53 WftPrWDxlLmXjBl5yy2f6F8bCafUdIR+75iOwzSIH/YaI0LwbVX+bvyWn2qXC919eBId qC2rvoa/XTAHz0H7lXlZL8m6mYNvYdt/GM+xpU6y/hZdYvWbJkVeXPnbElhuc8JZRHjV AQLkyl9zoGC4RU6iHA223r4eS7I0RtwJqUchGYcT09Cx9Ermr8HcJxj/68xVROOuZ5sP M1BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=sipj4v9pBU7MXw2jSkGGkeIUi1pyn4zfDYtJOy43fYs=; b=77sK+C58I3Ka4soeOpbuX/XbNucMK0d9C3QIfaJ0w6Tsa8nYj9VitdrAaASQAzK6L6 JFjvxTujg+pxdgGHSg1lr5awcH3SrY+FUNLvyWgFyJXSBPZ5ORuLV/K/0VSf8b7Pn1J/ scFOUPHee6JLnZy1YgTzNou0TKQtQo/Ib0JK6tQpqJjHwgtcsoUEsrpqnGGd8WNasM0F efsRhPW4rn+wTWw8hS4IDaxQR+i15En6S3jabq4MKf31UXpiakGlOpjdkM/DxIGsDNAR 417XAnf+ITRg9qQ39JBYa2+C+JQBru7GGt/b2L7IJRFVZmBjy2UbMoEGbr5WsS7wN2Wj g26w== X-Gm-Message-State: ANoB5pntzZfBv7PN2fQqNSBNIdZcCHBGXunNP+yecasZb88meM43cwDn NrYbqaPM1L7kyXC2Br8xjLMRpQ== X-Google-Smtp-Source: AA0mqf7DFgIJupRg6Knt+1kIqz2XCTaj3mncgeMW2rHiH1fZB+UG6oxmfw7WPAC0nxvGGNDvoazS6w== X-Received: by 2002:a05:6e02:d92:b0:302:74a8:c234 with SMTP id i18-20020a056e020d9200b0030274a8c234mr1718636ilj.55.1668710637202; Thu, 17 Nov 2022 10:43:57 -0800 (PST) Received: from murgatroyd (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id k4-20020a6b7e44000000b006bb57cfcb88sm571037ioq.44.2022.11.17.10.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 10:43:56 -0800 (PST) From: Tom Tromey To: Tom Tromey Cc: Jon Turney , gdb-patches@sourceware.org Subject: Re: [PATCH 2/2] Implement target async for Windows References: <20220803130822.735057-1-tromey@adacore.com> <20220803130822.735057-3-tromey@adacore.com> <87bkph46uf.fsf@tromey.com> <87tu2xs9y9.fsf@tromey.com> X-Attribution: Tom Date: Thu, 17 Nov 2022 11:43:55 -0700 In-Reply-To: <87tu2xs9y9.fsf@tromey.com> (Tom Tromey's message of "Thu, 17 Nov 2022 11:38:22 -0700") Message-ID: <87pmdls9p0.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-11.0 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 List-Id: Tom> I'll check it in shortly. Thanks for trying it. Here's what I'm checking in. Tom commit c2659a9b7bf554ca8dae011031e5003059b8621f Author: Tom Tromey Date: Tue Nov 8 12:14:20 2022 -0700 Fix static initialization order problem in windows-nat.c This patch fixes a static initialization order problem in windows-nat.c that was pointed out by Jon Turney. The underlying problem is that the windows_nat_target constructor relies on serial_logfile already being constructed, but this is not enforced by C++ rules. This patch fixes the problem by initializing the global windows_nat_target later. diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 6250cbc27a5..5d506507b6d 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -384,7 +384,9 @@ struct windows_nat_target final : public x86_nat_target bool m_is_async = false; }; -static windows_nat_target the_windows_nat_target; +/* 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) @@ -620,7 +622,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 (the_windows_nat_target, ptid)); auto iter = std::find_if (windows_process.thread_list.begin (), windows_process.thread_list.end (), @@ -3118,7 +3120,8 @@ _initialize_windows_nat () calling x86_set_debug_register_length function in processor windows specific native file. */ - add_inf_child_target (&the_windows_nat_target); + the_windows_nat_target = new windows_nat_target; + add_inf_child_target (the_windows_nat_target); #ifdef __CYGWIN__ cygwin_internal (CW_SET_DOS_FILE_WARNING, 0);