]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdbserver: make remove_thread a method of process_info
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 7 Nov 2024 16:15:43 +0000 (16:15 +0000)
committerSimon Marchi <simon.marchi@polymtl.ca>
Fri, 8 Nov 2024 14:16:23 +0000 (09:16 -0500)
Same idea as the previous patch, but for `remove_thread`.

Change-Id: I7e227655be5fcf29a3256e8389eb32051f27882d
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
gdbserver/gdbthread.h
gdbserver/inferiors.cc
gdbserver/inferiors.h
gdbserver/linux-low.cc
gdbserver/netbsd-low.cc
gdbserver/win32-low.cc

index d00dc04d5a9f6f13125b9680e83a7de7ebf106a0..b45dc36c28540c9ee25757edf1434e0700706d7f 100644 (file)
@@ -90,8 +90,6 @@ private:
   process_info *m_process;
 };
 
-void remove_thread (struct thread_info *thread);
-
 /* Return a pointer to the first thread, or NULL if there isn't one.  */
 
 struct thread_info *get_first_thread (void);
index 7d9152dae4c6b324548dd43b877b0b21e92acd81..8ca6d6432649235af2a03282ebe74e212f879e6c 100644 (file)
@@ -100,23 +100,22 @@ find_any_thread_of_pid (int pid)
 }
 
 void
-remove_thread (struct thread_info *thread)
+process_info::remove_thread (thread_info *thread)
 {
   if (thread->btrace != NULL)
     target_disable_btrace (thread->btrace);
 
   discard_queued_stop_replies (ptid_of (thread));
-  process_info *process = get_thread_process (thread);
-  gdb_assert (process != nullptr);
 
   if (current_thread == thread)
     switch_to_thread (nullptr);
 
   /* We should not try to remove a thread that was not added.  */
-  int num_erased = process->thread_map ().erase (thread->id);
+  gdb_assert (thread->process () == this);
+  int num_erased = m_ptid_thread_map.erase (thread->id);
   gdb_assert (num_erased > 0);
 
-  process->thread_list ().erase (process->thread_list ().iterator_to (*thread));
+  m_thread_list.erase (m_thread_list.iterator_to (*thread));
 }
 
 void *
index fd3ee28fa52980df62ddcab060c8ad27b5972594..002dd2a4ed6d0f04dc003eb87888caff5a6a0b16 100644 (file)
@@ -107,6 +107,11 @@ struct process_info : public intrusive_list_node<process_info>
   /* Add a thread with id ID to this process.  */
   thread_info *add_thread (ptid_t id, void *target_data);
 
+  /* Remove thread THREAD.
+
+     THREAD must be part of this process' thread list.  */
+  void remove_thread (thread_info *thread);
+
 private:
   /* This processes' thread list, sorted by creation order.  */
   owning_intrusive_list<thread_info> m_thread_list;
index a21d5625b4861143d73a2f686b391101e336c64b..924536c34fa89ff20a417ac4ed9afa495d517d51 100644 (file)
@@ -398,11 +398,11 @@ linux_pid_exe_is_elf_64_file (int pid, unsigned int *machine)
 void
 linux_process_target::delete_lwp (lwp_info *lwp)
 {
-  struct thread_info *thr = get_lwp_thread (lwp);
+  thread_info *thr = get_lwp_thread (lwp);
 
   threads_debug_printf ("deleting %ld", lwpid_of (thr));
 
-  remove_thread (thr);
+  thr->process ()->remove_thread (thr);
 
   low_delete_thread (lwp->arch_private);
 
index 53cb6fa858c57d74aa29702ea280d064a6b30be6..332186ff71831035434b2bd467c772d13c703cde 100644 (file)
@@ -303,7 +303,7 @@ netbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus,
          /* NetBSD does not store an LWP exit status.  */
          ourstatus->set_thread_exited (0);
 
-         remove_thread (thr);
+         thr->process ()->remove_thread (thr);
        }
       return wptid;
     }
index 3236bb9677fd594bc4c2b202f693308251df0486..18bdc12f6b591db6cd88eb7fd8de9a9428d62f6d 100644 (file)
@@ -188,7 +188,7 @@ delete_thread_info (thread_info *thread)
 {
   windows_thread_info *th = (windows_thread_info *) thread_target_data (thread);
 
-  remove_thread (thread);
+  thread->process ()->remove_thread (thread);
   delete th;
 }