public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Use lwp field in ptid for AIX.
@ 2024-06-07 12:52 Aditya Vidyadhar Kamath
  2024-06-25 10:23 ` Aditya Kamath1
  0 siblings, 1 reply; 2+ messages in thread
From: Aditya Vidyadhar Kamath @ 2024-06-07 12:52 UTC (permalink / raw)
  To: tom; +Cc: ulrich.weigand, gdb-patches, Aditya.Kamath1, sangamesh.swamy

From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>

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 | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 327f5607d45..f2c5605963a 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -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);
-- 
2.41.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re:  [PATCH] Use lwp field in ptid for AIX.
  2024-06-07 12:52 [PATCH] Use lwp field in ptid for AIX Aditya Vidyadhar Kamath
@ 2024-06-25 10:23 ` Aditya Kamath1
  0 siblings, 0 replies; 2+ messages in thread
From: Aditya Kamath1 @ 2024-06-25 10:23 UTC (permalink / raw)
  To: Aditya Vidyadhar Kamath, tom
  Cc: Ulrich Weigand, gdb-patches, Sangamesh Mallayya

[-- Attachment #1: Type: text/plain, Size: 4118 bytes --]

Respected community members,

Any feedback on this version of the patch?

Kindly let me know.

Thanks,
Aditya.


From: Aditya Vidyadhar Kamath <akamath996@gmail.com>
Date: Friday, 7 June 2024 at 6:23 PM
To: tom@tromey.com <tom@tromey.com>
Cc: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>, gdb-patches@sourceware.org <gdb-patches@sourceware.org>, Aditya Kamath1 <Aditya.Kamath1@ibm.com>, Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: [EXTERNAL] [PATCH] Use lwp field in ptid for AIX.
From: Aditya Vidyadhar Kamath <Aditya.Kamath1@ibm.com>

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 | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 327f5607d45..f2c5605963a 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -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);
--
2.41.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-25 11:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-07 12:52 [PATCH] Use lwp field in ptid for AIX Aditya Vidyadhar Kamath
2024-06-25 10:23 ` Aditya Kamath1

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).