Comment tidy
[deliverable/binutils-gdb.git] / gdb / aix-thread.c
index f3434a6db671009e248b0b9f457d22da662ccb70..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));
@@ -1040,7 +1058,7 @@ aix_thread_wait (struct target_ops *ops,
       && status->value.sig == GDB_SIGNAL_TRAP)
     {
       struct regcache *regcache = get_thread_regcache (ptid);
-      struct gdbarch *gdbarch = get_regcache_arch (regcache);
+      struct gdbarch *gdbarch = regcache->arch ();
 
       if (regcache_read_pc (regcache)
          - gdbarch_decr_pc_after_break (gdbarch) == pd_brk_addr)
@@ -1055,7 +1073,7 @@ aix_thread_wait (struct target_ops *ops,
 static void
 supply_gprs64 (struct regcache *regcache, uint64_t *vals)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_regcache_arch (regcache));
+  struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ());
   int regno;
 
   for (regno = 0; regno < ppc_num_gprs; regno++)
@@ -1076,7 +1094,7 @@ supply_reg32 (struct regcache *regcache, int regno, uint32_t val)
 static void
 supply_fprs (struct regcache *regcache, double *vals)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   int regno;
 
@@ -1117,7 +1135,7 @@ supply_sprs64 (struct regcache *regcache,
               uint64_t lr, uint64_t ctr, uint32_t xer,
               uint32_t fpscr)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   regcache_raw_supply (regcache, gdbarch_pc_regnum (gdbarch),
@@ -1141,7 +1159,7 @@ supply_sprs32 (struct regcache *regcache,
               uint32_t lr, uint32_t ctr, uint32_t xer,
               uint32_t fpscr)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   regcache_raw_supply (regcache, gdbarch_pc_regnum (gdbarch),
@@ -1166,7 +1184,7 @@ supply_sprs32 (struct regcache *regcache,
 static void
 fetch_regs_user_thread (struct regcache *regcache, pthdb_pthread_t pdtid)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   int status, i;
   pthdb_context_t ctx;
@@ -1221,7 +1239,7 @@ static void
 fetch_regs_kernel_thread (struct regcache *regcache, int regno,
                          pthdb_tid_t tid)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   uint64_t gprs64[ppc_num_gprs];
   uint32_t gprs32[ppc_num_gprs];
@@ -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);
     }
@@ -1328,7 +1347,7 @@ aix_thread_fetch_registers (struct target_ops *ops,
 static void
 fill_gprs64 (const struct regcache *regcache, uint64_t *vals)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_regcache_arch (regcache));
+  struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ());
   int regno;
 
   for (regno = 0; regno < ppc_num_gprs; regno++)
@@ -1341,7 +1360,7 @@ fill_gprs64 (const struct regcache *regcache, uint64_t *vals)
 static void 
 fill_gprs32 (const struct regcache *regcache, uint32_t *vals)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_regcache_arch (regcache));
+  struct gdbarch_tdep *tdep = gdbarch_tdep (regcache->arch ());
   int regno;
 
   for (regno = 0; regno < ppc_num_gprs; regno++)
@@ -1355,7 +1374,7 @@ fill_gprs32 (const struct regcache *regcache, uint32_t *vals)
 static void
 fill_fprs (const struct regcache *regcache, double *vals)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   int regno;
 
@@ -1380,7 +1399,7 @@ fill_sprs64 (const struct regcache *regcache,
             uint64_t *lr, uint64_t *ctr, uint32_t *xer,
             uint32_t *fpscr)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   /* Verify that the size of the size of the IAR buffer is the
@@ -1416,7 +1435,7 @@ fill_sprs32 (const struct regcache *regcache,
             uint32_t *lr, uint32_t *ctr, uint32_t *xer,
             uint32_t *fpscr)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
   /* Verify that the size of the size of the IAR buffer is the
@@ -1454,7 +1473,7 @@ fill_sprs32 (const struct regcache *regcache,
 static void
 store_regs_user_thread (const struct regcache *regcache, pthdb_pthread_t pdtid)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   int status, i;
   pthdb_context_t ctx;
@@ -1551,7 +1570,7 @@ static void
 store_regs_kernel_thread (const struct regcache *regcache, int regno,
                          pthdb_tid_t tid)
 {
-  struct gdbarch *gdbarch = get_regcache_arch (regcache);
+  struct gdbarch *gdbarch = regcache->arch ();
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   uint64_t gprs64[ppc_num_gprs];
   uint32_t gprs32[ppc_num_gprs];
@@ -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" */
@@ -1831,8 +1852,6 @@ init_aix_thread_ops (void)
 /* Module startup initialization function, automagically called by
    init.c.  */
 
-void _initialize_aix_thread (void);
-
 void
 _initialize_aix_thread (void)
 {
This page took 0.027764 seconds and 4 git commands to generate.