]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use lwp field in ptid for AIX.
authorAditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>
Fri, 7 Jun 2024 12:52:40 +0000 (18:22 +0530)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Tue, 2 Jul 2024 15:27:31 +0000 (17:27 +0200)
Currently in AIX, the private data is used to maintain the kernel thread ID.

This is a patch to trim the need to have another field in the private data of a thread in AIX.

We want to use the lwp field to represent the kernel thread ID to match or
make things similar to the Linux targets.

gdb/aix-thread.c

index 327f5607d4598659e8ca8ee0c13ead8da4b21def..f2c5605963a7327426384805d351271d22d054fb 100644 (file)
@@ -78,7 +78,6 @@ static bool debug_aix_thread;
 struct aix_thread_info : public private_thread_info
 {
   pthdb_pthread_t pdtid;        /* thread's libpthdebug id */
-  pthdb_tid_t tid;                     /* kernel thread id */
 };
 
 /* Return the aix_thread_info attached to THREAD.  */
@@ -805,7 +804,9 @@ sync_threadlists (pid_t pid)
       if (status != PTHDB_SUCCESS || pthid == PTHDB_INVALID_PTID)
        continue;
 
-      ptid_t ptid (pid, 0, pthid);
+      status = pthdb_pthread_tid (data->pd_session, pdtid, &tid);
+      ptid_t ptid (pid, tid, pthid);
+
       status = pthdb_pthread_state (data->pd_session, pdtid, &state);
       in_queue_threads.insert (pdtid);
 
@@ -822,8 +823,6 @@ sync_threadlists (pid_t pid)
          aix_thread_info *priv = new aix_thread_info;
          /* init priv */
          priv->pdtid = pdtid;
-         status = pthdb_pthread_tid (data->pd_session, pdtid, &tid);
-         priv->tid = tid;
          /* Check if this is the main thread.  If it is, then change
             its ptid and add its private data.  */
          if (in_thread_list (proc_target, ptid_t (pid)))
@@ -875,9 +874,7 @@ static int
 iter_tid (struct thread_info *thread, void *tidp)
 {
   const pthdb_tid_t tid = *(pthdb_tid_t *)tidp;
-  aix_thread_info *priv = get_aix_thread_info (thread);
-
-  return priv->tid == tid;
+  return thread->ptid.lwp () == tid;
 }
 
 /* Synchronize libpthdebug's state with the inferior and with GDB,
@@ -1079,7 +1076,7 @@ aix_thread_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
 
       aix_thread_info *priv = get_aix_thread_info (thread);
 
-      tid[0] = priv->tid;
+      tid[0] = ptid.lwp ();
       if (tid[0] == PTHDB_INVALID_TID)
        error (_("aix-thread resume: no tid for pthread %ld"),
               ptid.lwp ());
@@ -1468,7 +1465,7 @@ aix_thread_target::fetch_registers (struct regcache *regcache, int regno)
     {
       thread = current_inferior ()->find_thread (regcache->ptid ());
       aix_thread_info *priv = get_aix_thread_info (thread);
-      tid = priv->tid;
+      tid = regcache->ptid().lwp ();
 
       if (tid == PTHDB_INVALID_TID)
        fetch_regs_user_thread (regcache, priv->pdtid);
@@ -1933,7 +1930,7 @@ aix_thread_target::store_registers (struct regcache *regcache, int regno)
     {
       thread = current_inferior ()->find_thread (regcache->ptid ());
       aix_thread_info *priv = get_aix_thread_info (thread);
-      tid = priv->tid;
+      tid = regcache->ptid ().lwp ();
 
       if (tid == PTHDB_INVALID_TID)
        store_regs_user_thread (regcache, priv->pdtid);
@@ -1997,7 +1994,7 @@ aix_thread_target::pid_to_str (ptid_t ptid)
       aix_thread_info *priv = get_aix_thread_info (thread_info);
 
       return string_printf (_("Thread %s (tid %s)"), pulongest (ptid.tid ()),
-               pulongest (priv->tid));
+               pulongest (ptid.lwp ()));
     }
 
   return beneath ()->pid_to_str (ptid);