]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdbserver: remove pidof(process)
authorSimon Marchi <simon.marchi@polymtl.ca>
Wed, 6 Nov 2024 20:03:06 +0000 (15:03 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Fri, 8 Nov 2024 14:16:23 +0000 (09:16 -0500)
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>
gdbserver/inferiors.h
gdbserver/linux-low.cc
gdbserver/remote-utils.cc
gdbserver/thread-db.cc

index c282a7bf188acff3ea5c29592e68e003f169d27c..5372a3cd5b78a5a00343e404a4146e3fccbff584 100644 (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.  */
index fa8aaf81f93c8d68fb24122786d1577d27a1cb5b..7b1ec61212db8aedd45ddb38a197be9588ee527d 100644 (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, "
index 98c34e91220cb3e3cca0531dba90a50475ffc720..42252bad78f0dec91f887102d8a3baebb952c5ae 100644 (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);
 }
 
index 0c014835472d275c90cbe31602c5b6d9aa707892..a4512a2c64dbb11b141254c6b7895685b993d098 100644 (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;