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>
This commit is contained in:
Simon Marchi
2024-11-06 15:03:06 -05:00
parent 65b7d4502b
commit 592e13ac90
4 changed files with 10 additions and 15 deletions

View File

@@ -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. */

View File

@@ -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, "

View File

@@ -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);
}

View File

@@ -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;