public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Remove the_windows_nat_target global
@ 2022-11-30 15:52 Tom Tromey
  2022-12-01 18:29 ` Simon Marchi
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2022-11-30 15:52 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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<inf_child_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);
-- 
2.34.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Remove the_windows_nat_target global
  2022-11-30 15:52 [PATCH] Remove the_windows_nat_target global Tom Tromey
@ 2022-12-01 18:29 ` Simon Marchi
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Marchi @ 2022-12-01 18:29 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 11/30/22 10:52, Tom Tromey via Gdb-patches wrote:
> 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.

This LGTM:

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-01 18:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-30 15:52 [PATCH] Remove the_windows_nat_target global Tom Tromey
2022-12-01 18:29 ` Simon Marchi

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).