diff options
author | Tom Tromey <tromey@adacore.com> | 2022-11-08 12:14:20 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2022-11-17 11:44:30 -0700 |
commit | c83b95d88feed26eb04f7eca97c08e3ace0b7cbb (patch) | |
tree | 6a6fc18e21888feaac051ce5895d0ae2a2ef6a08 /gdb/windows-nat.c | |
parent | 2368c6bf61cc815e124a88f3414c35aff2022b6d (diff) | |
download | gdb-c83b95d88feed26eb04f7eca97c08e3ace0b7cbb.zip gdb-c83b95d88feed26eb04f7eca97c08e3ace0b7cbb.tar.gz gdb-c83b95d88feed26eb04f7eca97c08e3ace0b7cbb.tar.bz2 |
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.
Diffstat (limited to 'gdb/windows-nat.c')
-rw-r--r-- | gdb/windows-nat.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 6250cbc..5d50650 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -384,7 +384,9 @@ private: 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); |