From: Tom Tromey <tromey@adacore.com>
To: Tom Tromey <tromey@adacore.com>
Cc: Jon Turney <jon.turney@dronecode.org.uk>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] Implement target async for Windows
Date: Thu, 17 Nov 2022 11:43:55 -0700 [thread overview]
Message-ID: <87pmdls9p0.fsf@tromey.com> (raw)
In-Reply-To: <87tu2xs9y9.fsf@tromey.com> (Tom Tromey's message of "Thu, 17 Nov 2022 11:38:22 -0700")
Tom> I'll check it in shortly. Thanks for trying it.
Here's what I'm checking in.
Tom
commit c2659a9b7bf554ca8dae011031e5003059b8621f
Author: Tom Tromey <tromey@adacore.com>
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<inf_child_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);
next prev parent reply other threads:[~2022-11-17 18:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-03 13:08 [PATCH 0/2] " Tom Tromey
2022-08-03 13:08 ` [PATCH 1/2] Move some Windows operations to worker thread Tom Tromey
2022-08-03 13:33 ` Eli Zaretskii
2022-08-03 18:47 ` Tom Tromey
2022-08-03 19:16 ` Eli Zaretskii
2022-08-03 13:08 ` [PATCH 2/2] Implement target async for Windows Tom Tromey
2022-11-04 14:28 ` Jon Turney
2022-11-08 18:38 ` Tom Tromey
2022-11-13 14:45 ` Jon Turney
2022-11-04 14:59 ` Jon Turney
2022-11-08 18:52 ` Tom Tromey
2022-11-17 14:33 ` Jon Turney
2022-11-17 18:38 ` Tom Tromey
2022-11-17 18:43 ` Tom Tromey [this message]
2022-08-03 13:34 ` [PATCH 0/2] " Eli Zaretskii
2022-08-03 18:54 ` Tom Tromey
2022-08-03 19:17 ` Eli Zaretskii
2022-08-22 18:03 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pmdls9p0.fsf@tromey.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=jon.turney@dronecode.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).