[4/4] gdbserver: make thread_target_data a method of thread_info

Message ID 20241204163101.2294833-5-simark@simark.ca
State New
Headers
Series Some (hopefully) harmless cleanups |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_check--master-arm fail Patch failed to apply

Commit Message

Simon Marchi Dec. 4, 2024, 4:30 p.m. UTC
  From: Simon Marchi <simon.marchi@polymtl.ca>

Make the field private, change the free function to be a method.

Change-Id: I05010e7d1bd58ce3895802eb263c029528427758
---
 gdbserver/gdbthread.h       | 8 +++++---
 gdbserver/inferiors.cc      | 6 ------
 gdbserver/inferiors.h       | 2 --
 gdbserver/linux-low.h       | 2 +-
 gdbserver/win32-i386-low.cc | 6 +++---
 gdbserver/win32-low.cc      | 8 ++++----
 6 files changed, 13 insertions(+), 19 deletions(-)
  

Patch

diff --git a/gdbserver/gdbthread.h b/gdbserver/gdbthread.h
index 2f06be9101da..2ff023119a32 100644
--- a/gdbserver/gdbthread.h
+++ b/gdbserver/gdbthread.h
@@ -28,7 +28,7 @@  struct regcache;
 struct thread_info : public intrusive_list_node<thread_info>
 {
   thread_info (ptid_t id, process_info *process, void *target_data)
-    : id (id), target_data (target_data), m_process (process)
+    : id (id), m_process (process), m_target_data (target_data)
   {}
 
   ~thread_info ()
@@ -46,11 +46,12 @@  struct thread_info : public intrusive_list_node<thread_info>
   void set_regcache (struct regcache *regcache)
   { m_regcache = regcache; }
 
+  void *target_data ()
+  { return m_target_data; }
+
   /* The id of this thread.  */
   ptid_t id;
 
-  void *target_data;
-
   /* The last resume GDB requested on this thread.  */
   enum resume_kind last_resume_kind = resume_continue;
 
@@ -94,6 +95,7 @@  struct thread_info : public intrusive_list_node<thread_info>
 private:
   process_info *m_process;
   struct regcache *m_regcache = nullptr;
+  void *m_target_data;
 };
 
 /* Return a pointer to the first thread, or NULL if there isn't one.  */
diff --git a/gdbserver/inferiors.cc b/gdbserver/inferiors.cc
index 96fb7530ebc6..b0610d6d07d1 100644
--- a/gdbserver/inferiors.cc
+++ b/gdbserver/inferiors.cc
@@ -118,12 +118,6 @@  process_info::remove_thread (thread_info *thread)
   m_thread_list.erase (m_thread_list.iterator_to (*thread));
 }
 
-void *
-thread_target_data (struct thread_info *thread)
-{
-  return thread->target_data;
-}
-
 void
 clear_inferiors (void)
 {
diff --git a/gdbserver/inferiors.h b/gdbserver/inferiors.h
index cdf1006a091a..f6eb3dfa488a 100644
--- a/gdbserver/inferiors.h
+++ b/gdbserver/inferiors.h
@@ -154,8 +154,6 @@  void switch_to_process (process_info *proc);
 
 void clear_inferiors (void);
 
-void *thread_target_data (struct thread_info *);
-
 /* Set the inferior current working directory.  If CWD is empty, unset
    the directory.  */
 void set_inferior_cwd (std::string cwd);
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 9a25697a90bc..80825f63e4dd 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -715,7 +715,7 @@  extern linux_process_target *the_linux_target;
 static inline lwp_info *
 get_thread_lwp (thread_info *thr)
 {
-  return static_cast<lwp_info *> (thread_target_data (thr));
+  return static_cast<lwp_info *> (thr->target_data ());
 }
 
 /* Information about a signal that is to be delivered to a thread.  */
diff --git a/gdbserver/win32-i386-low.cc b/gdbserver/win32-i386-low.cc
index 7898ac12bcf9..4d031d4ab571 100644
--- a/gdbserver/win32-i386-low.cc
+++ b/gdbserver/win32-i386-low.cc
@@ -50,7 +50,7 @@  static struct x86_debug_reg_state debug_reg_state;
 static void
 update_debug_registers (thread_info *thread)
 {
-  windows_thread_info *th = (windows_thread_info *) thread_target_data (thread);
+  auto th = static_cast<windows_thread_info *> (thread->target_data ());
 
   /* The actual update is done later just before resuming the lwp,
      we just mark that the registers need updating.  */
@@ -83,8 +83,8 @@  x86_dr_low_set_control (unsigned long control)
 static DWORD64
 win32_get_current_dr (int dr)
 {
-  windows_thread_info *th
-    = (windows_thread_info *) thread_target_data (current_thread);
+  auto th
+    = static_cast<windows_thread_info *> (current_thread->target_data ());
 
   win32_require_context (th);
 
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 0174a32e5d19..d19e89152ec0 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -141,7 +141,7 @@  gdbserver_windows_process::thread_rec
   if (thread == NULL)
     return NULL;
 
-  windows_thread_info *th = (windows_thread_info *) thread_target_data (thread);
+  auto th = static_cast<windows_thread_info *> (thread->target_data ());
   if (disposition != DONT_INVALIDATE_CONTEXT)
     win32_require_context (th);
   return th;
@@ -178,7 +178,7 @@  child_add_thread (DWORD pid, DWORD tid, HANDLE h, void *tlb)
 static void
 delete_thread_info (thread_info *thread)
 {
-  windows_thread_info *th = (windows_thread_info *) thread_target_data (thread);
+  auto th = static_cast<windows_thread_info *> (thread->target_data ());
 
   thread->process ()->remove_thread (thread);
   delete th;
@@ -394,7 +394,7 @@  do_initial_child_stuff (HANDLE proch, DWORD pid, int attached)
 static void
 continue_one_thread (thread_info *thread, int thread_id)
 {
-  windows_thread_info *th = (windows_thread_info *) thread_target_data (thread);
+  auto th = static_cast<windows_thread_info *> (thread->target_data ());
 
   if (thread_id == -1 || thread_id == th->tid)
     {
@@ -923,7 +923,7 @@  gdbserver_windows_process::handle_unload_dll ()
 static void
 suspend_one_thread (thread_info *thread)
 {
-  windows_thread_info *th = (windows_thread_info *) thread_target_data (thread);
+  auto th = static_cast<windows_thread_info *> (thread->target_data ());
 
   th->suspend ();
 }