aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2024-11-06 15:03:06 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2024-11-08 09:16:23 -0500
commit592e13ac900339405f1f7f639cb5fcad028958fb (patch)
tree3e7bcbbd27ef17cb7e61cb3bc7e1f048e805eb14
parent65b7d4502b20a5a3130310e9039bf4525862d78c (diff)
downloadgdb-592e13ac900339405f1f7f639cb5fcad028958fb.zip
gdb-592e13ac900339405f1f7f639cb5fcad028958fb.tar.gz
gdb-592e13ac900339405f1f7f639cb5fcad028958fb.tar.bz2
gdbserver: remove pidof(process)
This function doesn't seem so useful, use `process_info::pid` directly instead. Change-Id: I55d592f38b32a197957ed4c569993cd23a818cb4 Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
-rw-r--r--gdbserver/inferiors.h8
-rw-r--r--gdbserver/linux-low.cc2
-rw-r--r--gdbserver/remote-utils.cc11
-rw-r--r--gdbserver/thread-db.cc4
4 files changed, 10 insertions, 15 deletions
diff --git a/gdbserver/inferiors.h b/gdbserver/inferiors.h
index c282a7b..5372a3c 100644
--- a/gdbserver/inferiors.h
+++ b/gdbserver/inferiors.h
@@ -121,14 +121,6 @@ private:
std::unordered_map<ptid_t, thread_info *> m_ptid_thread_map;
};
-/* Get the pid of PROC. */
-
-static inline int
-pid_of (const process_info *proc)
-{
- return proc->pid;
-}
-
/* Return a pointer to the current process. Note that the current
process may be non-null while the current thread (current_thread)
is null. */
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index fa8aaf8..7b1ec61 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -1794,7 +1794,7 @@ linux_process_target::check_zombie_leaders ()
for_each_process ([&] (process_info *proc)
{
- pid_t leader_pid = pid_of (proc);
+ pid_t leader_pid = proc->pid;
lwp_info *leader_lp = find_lwp_pid (ptid_t (leader_pid));
threads_debug_printf ("leader_pid=%d, leader_lp!=NULL=%d, "
diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc
index 98c34e9..42252ba 100644
--- a/gdbserver/remote-utils.cc
+++ b/gdbserver/remote-utils.cc
@@ -564,10 +564,11 @@ read_ptid (const char *buf, const char **obuf)
{
const char *p = buf;
const char *pp;
- ULONGEST pid = 0, tid = 0;
if (*p == 'p')
{
+ ULONGEST pid;
+
/* Multi-process ptid. */
pp = unpack_varlen_hex (p + 1, &pid);
if (*pp != '.')
@@ -575,23 +576,25 @@ read_ptid (const char *buf, const char **obuf)
p = pp + 1;
- tid = hex_or_minus_one (p, &pp);
+ ULONGEST tid = hex_or_minus_one (p, &pp);
if (obuf)
*obuf = pp;
+
return ptid_t (pid, tid);
}
/* No multi-process. Just a tid. */
- tid = hex_or_minus_one (p, &pp);
+ ULONGEST tid = hex_or_minus_one (p, &pp);
/* Since GDB is not sending a process id (multi-process extensions
are off), then there's only one process. Default to the first in
the list. */
- pid = pid_of (get_first_process ());
+ int pid = get_first_process ()->pid;
if (obuf)
*obuf = pp;
+
return ptid_t (pid, tid);
}
diff --git a/gdbserver/thread-db.cc b/gdbserver/thread-db.cc
index 0c01483..a4512a2 100644
--- a/gdbserver/thread-db.cc
+++ b/gdbserver/thread-db.cc
@@ -216,7 +216,7 @@ static int
attach_thread (const td_thrhandle_t *th_p, td_thrinfo_t *ti_p)
{
struct process_info *proc = current_process ();
- int pid = pid_of (proc);
+ int pid = proc->pid;
ptid_t ptid = ptid_t (pid, ti_p->ti_lid);
struct lwp_info *lwp;
int err;
@@ -748,7 +748,7 @@ thread_db_init (void)
find_one_thread then. That uses thread_db entry points that
do not walk libpthread's thread list, so should be safe, as
well as more efficient. */
- if (!linux_proc_task_list_dir_exists (pid_of (proc)))
+ if (!linux_proc_task_list_dir_exists (proc->pid))
thread_db_find_new_threads ();
thread_db_look_up_symbols ();
return 1;