]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add backpointer from windows_thread_info to windows_process_info
authorPedro Alves <pedro@palves.net>
Fri, 30 Aug 2024 15:02:21 +0000 (16:02 +0100)
committerPedro Alves <pedro@palves.net>
Mon, 9 Jun 2025 17:09:15 +0000 (18:09 +0100)
The next patch will move some duplicated code in gdb and gdbserver to
gdb/nat/windows-nat.c, where it would be convenient to get at the
Windows process info of a given Windows thread info, from within a
windows_thread_info method.

I first thought of passing down the windows_process_info pointer as
argument to the windows_thread_info method, but that looked a bit odd.
I think it looks better to just add a back pointer, so that's what
this patch does.  The following patch will then add a use of it.

I suspect this will help moving more duplicated code to
gdb/nat/windows-nat.c in the future, too.

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: I47fc0d3323be5b6f6fcfe912b768051a41910666

gdb/nat/windows-nat.h
gdb/windows-nat.c
gdbserver/win32-low.cc

index 8da9ca6e78fdfc38137b65a15ec40394eae5aef2..cba8098fb391a05d9ace9f112f17581759118541 100644 (file)
@@ -48,13 +48,16 @@ struct pending_stop
   target_waitstatus status;
 };
 
+struct windows_process_info;
 
 /* Thread information structure used to track extra information about
    each thread.  */
 struct windows_thread_info
 {
-  windows_thread_info (DWORD tid_, HANDLE h_, CORE_ADDR tlb)
-    : tid (tid_),
+  windows_thread_info (windows_process_info *proc_,
+                      DWORD tid_, HANDLE h_, CORE_ADDR tlb)
+    : proc (proc_),
+      tid (tid_),
       h (h_),
       thread_local_base (tlb)
   {
@@ -73,6 +76,9 @@ struct windows_thread_info
      the next call.  */
   const char *thread_name ();
 
+  /* The process this thread belongs to.  */
+  windows_process_info *const proc;
+
   /* The Win32 thread identifier.  */
   DWORD tid;
 
index fdcb340e550923b78ce0d0e92e1e516f873f06b0..2eabf222861cac7deda0d96be3c1f0d521b1bd31 100644 (file)
@@ -611,7 +611,7 @@ windows_nat_target::add_thread (ptid_t ptid, HANDLE h, void *tlb,
   if (windows_process.wow64_process)
     base += 0x2000;
 #endif
-  th = new windows_thread_info (ptid.lwp (), h, base);
+  th = new windows_thread_info (&windows_process, ptid.lwp (), h, base);
   windows_process.thread_list.emplace_back (th);
 
   /* Add this new thread to the list of threads.
index c95ec112bf71b83f43867a96079d038d74ed9639..4e2d95bd059e6851a83b3ff84acf7baa2e4f3285 100644 (file)
@@ -149,7 +149,7 @@ child_add_thread (DWORD pid, DWORD tid, HANDLE h, void *tlb)
   if (windows_process.wow64_process)
     base += 2 * 4096; /* page size = 4096 */
 #endif
-  th = new windows_thread_info (tid, h, base);
+  th = new windows_thread_info (&windows_process, tid, h, base);
 
   find_process_pid (pid)->add_thread (ptid, th);