Create private_thread_info hierarchy
[deliverable/binutils-gdb.git] / gdb / aix-thread.c
index b5c9f3b78299a29e782541da0dd3e3f66c6e0dee..1a1d769b5653ba6a7f91e15a641eb7152dd18b48 100644 (file)
@@ -84,11 +84,20 @@ static int debug_aix_thread;
 
 /* Private data attached to each element in GDB's thread list.  */
 
-struct private_thread_info {
+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.  */
+
+static aix_thread_info *
+get_aix_thread_info (thread_info *thread)
+{
+  return static_cast<aix_thread_info *> (thread->priv.get ());
+}
+
 /* Information about a thread of which libpthdebug is aware.  */
 
 struct pd_thread {
@@ -756,10 +765,12 @@ sync_threadlists (void)
        }
       else if (gi == gcount)
        {
-         thread = add_thread (ptid_build (infpid, 0, pbuf[pi].pthid));
-         thread->priv = XNEW (struct private_thread_info);
-         thread->priv->pdtid = pbuf[pi].pdtid;
-         thread->priv->tid = pbuf[pi].tid;
+         aix_thread_info *priv = new aix_thread_info;
+         priv->pdtid = pbuf[pi].pdtid;
+         priv->tid = pbuf[pi].tid;
+
+         thread = add_thread_with_info (ptid_t (infpid, 0, pbuf[pi].pthid), priv);
+
          pi++;
        }
       else
@@ -776,8 +787,10 @@ sync_threadlists (void)
 
          if (cmp_result == 0)
            {
-             gbuf[gi]->priv->pdtid = pdtid;
-             gbuf[gi]->priv->tid = tid;
+             aix_thread_info *priv = get_aix_thread_info (gbuf[gi]);
+
+             priv->pdtid = pdtid;
+             priv->tid = tid;
              pi++;
              gi++;
            }
@@ -789,9 +802,11 @@ sync_threadlists (void)
          else
            {
              thread = add_thread (pptid);
-             thread->priv = XNEW (struct private_thread_info);
-             thread->priv->pdtid = pdtid;
-             thread->priv->tid = tid;
+
+             aix_thread_info *priv = new aix_thread_info;
+             thread->priv.reset (priv);
+             priv->pdtid = pdtid;
+             priv->tid = tid;
              pi++;
            }
        }
@@ -808,8 +823,9 @@ 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 (thread->priv->tid == tid);
+  return priv->tid == tid;
 }
 
 /* Synchronize libpthdebug's state with the inferior and with GDB,
@@ -998,7 +1014,9 @@ aix_thread_resume (struct target_ops *ops,
        error (_("aix-thread resume: unknown pthread %ld"),
               ptid_get_lwp (ptid));
 
-      tid[0] = thread->priv->tid;
+      aix_thread_info *priv = get_aix_thread_info (thread);
+
+      tid[0] = priv->tid;
       if (tid[0] == PTHDB_INVALID_TID)
        error (_("aix-thread resume: no tid for pthread %ld"),
               ptid_get_lwp (ptid));
@@ -1314,10 +1332,11 @@ aix_thread_fetch_registers (struct target_ops *ops,
   else
     {
       thread = find_thread_ptid (regcache_get_ptid (regcache));
-      tid = thread->priv->tid;
+      aix_thread_info *priv = get_aix_thread_info (thread);
+      tid = priv->tid;
 
       if (tid == PTHDB_INVALID_TID)
-       fetch_regs_user_thread (regcache, thread->priv->pdtid);
+       fetch_regs_user_thread (regcache, priv->pdtid);
       else
        fetch_regs_kernel_thread (regcache, regno, tid);
     }
@@ -1668,10 +1687,11 @@ aix_thread_store_registers (struct target_ops *ops,
   else
     {
       thread = find_thread_ptid (regcache_get_ptid (regcache));
-      tid = thread->priv->tid;
+      aix_thread_info *priv = get_aix_thread_info (thread);
+      tid = priv->tid;
 
       if (tid == PTHDB_INVALID_TID)
-       store_regs_user_thread (regcache, thread->priv->pdtid);
+       store_regs_user_thread (regcache, priv->pdtid);
       else
        store_regs_kernel_thread (regcache, regno, tid);
     }
@@ -1759,9 +1779,10 @@ aix_thread_extra_thread_info (struct target_ops *self,
     return NULL;
 
   string_file buf;
+  aix_thread_info *priv = get_aix_thread_info (thread);
 
-  pdtid = thread->priv->pdtid;
-  tid = thread->priv->tid;
+  pdtid = priv->pdtid;
+  tid = priv->tid;
 
   if (tid != PTHDB_INVALID_TID)
     /* i18n: Like "thread-identifier %d, [state] running, suspended" */
This page took 0.026717 seconds and 4 git commands to generate.