aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2024-11-07 16:17:56 +0000
committerSimon Marchi <simon.marchi@polymtl.ca>2024-11-08 09:16:23 -0500
commit9618dbfe52fa98e224e53e18626fbe08e9c892a7 (patch)
tree3fe11480aa1b120e5409f41a6d36015f928d32de
parentdceb3cd436e0240857ff914d3f11872a78d0c63c (diff)
downloadgdb-9618dbfe52fa98e224e53e18626fbe08e9c892a7.zip
gdb-9618dbfe52fa98e224e53e18626fbe08e9c892a7.tar.gz
gdb-9618dbfe52fa98e224e53e18626fbe08e9c892a7.tar.bz2
gdbserver: make add_thread a method of process_info
Since thread_info objects are now basically children of process_info objects, I think that makes sense. Change-Id: I7f0a67b921b468e512851cb2f36015d1003412d7 Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
-rw-r--r--gdbserver/gdbthread.h1
-rw-r--r--gdbserver/inferiors.cc13
-rw-r--r--gdbserver/inferiors.h3
-rw-r--r--gdbserver/linux-low.cc2
-rw-r--r--gdbserver/netbsd-low.cc4
-rw-r--r--gdbserver/win32-low.cc2
6 files changed, 11 insertions, 14 deletions
diff --git a/gdbserver/gdbthread.h b/gdbserver/gdbthread.h
index 94333c4..d00dc04 100644
--- a/gdbserver/gdbthread.h
+++ b/gdbserver/gdbthread.h
@@ -91,7 +91,6 @@ private:
};
void remove_thread (struct thread_info *thread);
-struct thread_info *add_thread (ptid_t ptid, void *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 d447808..7d9152d 100644
--- a/gdbserver/inferiors.cc
+++ b/gdbserver/inferiors.cc
@@ -38,16 +38,11 @@ struct thread_info *current_thread;
Empty if not specified. */
static std::string current_inferior_cwd;
-struct thread_info *
-add_thread (ptid_t thread_id, void *target_data)
+thread_info *
+process_info::add_thread (ptid_t id, void *target_data)
{
- process_info *process = find_process_pid (thread_id.pid ());
- gdb_assert (process != nullptr);
-
- auto &new_thread
- = process->thread_list ().emplace_back (thread_id, process, target_data);
- bool inserted
- = process->thread_map ().insert ({thread_id, &new_thread}).second;
+ auto &new_thread = m_thread_list.emplace_back (id, this, target_data);
+ bool inserted = m_ptid_thread_map.insert ({ id, &new_thread }).second;
/* A thread with this ptid should not exist in the map yet. */
gdb_assert (inserted);
diff --git a/gdbserver/inferiors.h b/gdbserver/inferiors.h
index 145737b..fd3ee28 100644
--- a/gdbserver/inferiors.h
+++ b/gdbserver/inferiors.h
@@ -104,6 +104,9 @@ struct process_info : public intrusive_list_node<process_info>
/* Invoke FUNC for each thread. */
void for_each_thread (gdb::function_view<void (thread_info *)> func);
+ /* Add a thread with id ID to this process. */
+ thread_info *add_thread (ptid_t id, void *target_data);
+
private:
/* This processes' thread list, sorted by creation order. */
owning_intrusive_list<thread_info> m_thread_list;
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 39a7180..a21d562 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -925,7 +925,7 @@ linux_process_target::add_lwp (ptid_t ptid)
{
lwp_info *lwp = new lwp_info;
- lwp->thread = add_thread (ptid, lwp);
+ lwp->thread = find_process_pid (ptid.pid ())->add_thread (ptid, lwp);
low_new_thread (lwp);
diff --git a/gdbserver/netbsd-low.cc b/gdbserver/netbsd-low.cc
index 1a3ef16..53cb6fa 100644
--- a/gdbserver/netbsd-low.cc
+++ b/gdbserver/netbsd-low.cc
@@ -321,7 +321,7 @@ netbsd_wait (ptid_t ptid, struct target_waitstatus *ourstatus,
ourstatus->set_spurious ();
else
{
- add_thread (wptid, NULL);
+ find_process_pid (wptid.pid ())->add_thread (wptid, nullptr);
ourstatus->set_thread_created ();
}
return wptid;
@@ -391,7 +391,7 @@ netbsd_process_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
that was not fully initialized during the attach stage. */
if (wptid.lwp () != 0 && !find_thread_ptid (wptid)
&& ourstatus->kind () != TARGET_WAITKIND_THREAD_EXITED)
- add_thread (wptid, nullptr);
+ find_process_pid (wptid.pid ())->add_thread (wptid, nullptr);
switch (ourstatus->kind ())
{
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 41eed20..3236bb9 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -174,7 +174,7 @@ child_add_thread (DWORD pid, DWORD tid, HANDLE h, void *tlb)
#endif
th = new windows_thread_info (tid, h, base);
- add_thread (ptid, th);
+ find_process_pid (pid)->add_thread (ptid, th);
if (the_low_target.thread_added != NULL)
(*the_low_target.thread_added) (th);