From: Simon Marchi Date: Wed, 6 Nov 2024 20:03:06 +0000 (-0500) Subject: gdbserver: remove pidof(process) X-Git-Tag: gdb-16-branchpoint~492 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=592e13ac900339405f1f7f639cb5fcad028958fb;p=thirdparty%2Fbinutils-gdb.git 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 --- diff --git a/gdbserver/inferiors.h b/gdbserver/inferiors.h index c282a7bf188..5372a3cd5b7 100644 --- a/gdbserver/inferiors.h +++ b/gdbserver/inferiors.h @@ -121,14 +121,6 @@ private: std::unordered_map 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 fa8aaf81f93..7b1ec61212d 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 98c34e91220..42252bad78f 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 0c014835472..a4512a2c64d 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;