2004-09-02 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / aix-thread.c
index 76df67a8ebc57218fc8edea5e88c1bf6e1de0049..4e5a41189c9fbe7048d4ce987743a459cef734e1 100644 (file)
@@ -622,6 +622,35 @@ gcmp (const void *t1v, const void *t2v)
   return ptid_cmp (t1->ptid, t2->ptid);
 }
 
+/* Search through the list of all kernel threads for the thread
+   that has stopped on a SIGTRAP signal, and return its TID.
+   Return 0 if none found.  */
+
+static pthdb_tid_t
+get_signaled_thread (void)
+{
+  struct thrdsinfo64 thrinf;
+  pthdb_tid_t ktid = 0;
+  int result = 0;
+
+  /* getthrds(3) isn't prototyped in any AIX 4.3.3 #include file.  */
+  extern int getthrds (pid_t, struct thrdsinfo64 *, 
+                      int, pthdb_tid_t *, int);
+
+  while (1)
+  {
+    if (getthrds (PIDGET (inferior_ptid), &thrinf, 
+                 sizeof (thrinf), &ktid, 1) != 1)
+      break;
+
+    if (thrinf.ti_cursig == SIGTRAP)
+      return thrinf.ti_tid;
+  }
+
+  /* Didn't find any thread stopped on a SIGTRAP signal.  */
+  return 0;
+}
+
 /* Synchronize GDB's thread list with libpthdebug's.
 
    There are some benefits of doing this every time the inferior stops:
@@ -748,28 +777,15 @@ sync_threadlists (void)
   xfree (gbuf);
 }
 
-/* Iterate_over_threads() callback for locating a thread whose kernel
-   thread just received a trap signal.  */
+/* Iterate_over_threads() callback for locating a thread, using
+   the TID of its associated kernel thread.  */
 
 static int
-iter_trap (struct thread_info *thread, void *unused)
+iter_tid (struct thread_info *thread, void *tidp)
 {
-  struct thrdsinfo64 thrinf;
-  pthdb_tid_t tid;
+  const pthdb_tid_t tid = *(pthdb_tid_t *)tidp;
 
-  /* getthrds(3) isn't prototyped in any AIX 4.3.3 #include file.  */
-  extern int getthrds (pid_t, struct thrdsinfo64 *, 
-                      int, pthdb_tid_t *, int);
-
-  tid = thread->private->tid;
-  if (tid == PTHDB_INVALID_TID)
-    return 0;
-
-  if (getthrds (PIDGET (inferior_ptid), &thrinf, 
-               sizeof (thrinf), &tid, 1) != 1)
-    return 0;
-
-  return thrinf.ti_cursig == SIGTRAP;
+  return (thread->private->tid == tid);
 }
 
 /* Synchronize libpthdebug's state with the inferior and with GDB,
@@ -781,7 +797,8 @@ pd_update (int set_infpid)
 {
   int status;
   ptid_t ptid;
-  struct thread_info *thread;
+  pthdb_tid_t tid;
+  struct thread_info *thread = NULL;
 
   if (!pd_active)
     return inferior_ptid;
@@ -794,7 +811,9 @@ pd_update (int set_infpid)
 
   /* Define "current thread" as one that just received a trap signal.  */
 
-  thread = iterate_over_threads (iter_trap, NULL);
+  tid = get_signaled_thread ();
+  if (tid != 0)
+    thread = iterate_over_threads (iter_tid, &tid);
   if (!thread)
     ptid = inferior_ptid;
   else
@@ -854,7 +873,7 @@ pd_enable (void)
     return;
 
   /* Check application word size.  */
-  arch64 = DEPRECATED_REGISTER_RAW_SIZE (0) == 8;
+  arch64 = register_size (current_gdbarch, 0) == 8;
 
   /* Check whether the application is pthreaded.  */
   stub_name = NULL;
@@ -1266,7 +1285,8 @@ fill_gprs64 (uint64_t *vals)
 
   for (regno = 0; regno < ppc_num_gprs; regno++)
     if (register_cached (tdep->ppc_gp0_regnum + regno))
-      regcache_collect (tdep->ppc_gp0_regnum + regno, vals + regno);
+      regcache_raw_collect (current_regcache, tdep->ppc_gp0_regnum + regno,
+                           vals + regno);
 }
 
 static void 
@@ -1277,7 +1297,8 @@ fill_gprs32 (uint32_t *vals)
 
   for (regno = 0; regno < ppc_num_gprs; regno++)
     if (register_cached (tdep->ppc_gp0_regnum + regno))
-      regcache_collect (tdep->ppc_gp0_regnum + regno, vals + regno);
+      regcache_raw_collect (current_regcache, tdep->ppc_gp0_regnum + regno,
+                           vals + regno);
 }
 
 /* Store the floating point registers into a double array.  */
@@ -1295,7 +1316,7 @@ fill_fprs (double *vals)
        regno < tdep->ppc_fp0_regnum + ppc_num_fprs;
        regno++)
     if (register_cached (regno))
-      regcache_collect (regno, vals + regno);
+      regcache_raw_collect (current_regcache, regno, vals + regno);
 }
 
 /* Store the special registers into the specified 64-bit and 32-bit
@@ -1313,23 +1334,23 @@ fill_sprs64 (uint64_t *iar, uint64_t *msr, uint32_t *cr,
      they're not, then either GDB has been built incorrectly, or
      there's some other kind of internal error.  To be really safe,
      we should check all of the sizes.   */
-  gdb_assert (sizeof (*iar) == DEPRECATED_REGISTER_RAW_SIZE (PC_REGNUM));
+  gdb_assert (sizeof (*iar) == register_size (current_gdbarch, PC_REGNUM));
 
   if (register_cached (PC_REGNUM))
-    regcache_collect (PC_REGNUM, iar);
+    regcache_raw_collect (current_regcache, PC_REGNUM, iar);
   if (register_cached (tdep->ppc_ps_regnum))
-    regcache_collect (tdep->ppc_ps_regnum, msr);
+    regcache_raw_collect (current_regcache, tdep->ppc_ps_regnum, msr);
   if (register_cached (tdep->ppc_cr_regnum))
-    regcache_collect (tdep->ppc_cr_regnum, cr);
+    regcache_raw_collect (current_regcache, tdep->ppc_cr_regnum, cr);
   if (register_cached (tdep->ppc_lr_regnum))
-    regcache_collect (tdep->ppc_lr_regnum, lr);
+    regcache_raw_collect (current_regcache, tdep->ppc_lr_regnum, lr);
   if (register_cached (tdep->ppc_ctr_regnum))
-    regcache_collect (tdep->ppc_ctr_regnum, ctr);
+    regcache_raw_collect (current_regcache, tdep->ppc_ctr_regnum, ctr);
   if (register_cached (tdep->ppc_xer_regnum))
-    regcache_collect (tdep->ppc_xer_regnum, xer);
+    regcache_raw_collect (current_regcache, tdep->ppc_xer_regnum, xer);
   if (tdep->ppc_fpscr_regnum >= 0
       && register_cached (tdep->ppc_fpscr_regnum))
-    regcache_collect (tdep->ppc_fpscr_regnum, fpscr);
+    regcache_raw_collect (current_regcache, tdep->ppc_fpscr_regnum, fpscr);
 }
 
 static void
@@ -1349,23 +1370,23 @@ fill_sprs32 (unsigned long *iar, unsigned long *msr, unsigned long *cr,
      built incorrectly.  In order to make use of many of the header
      files in /usr/include/sys, GDB needs to be configured so that
      sizeof (long) == 4).  */
-  gdb_assert (sizeof (*iar) == DEPRECATED_REGISTER_RAW_SIZE (PC_REGNUM));
+  gdb_assert (sizeof (*iar) == register_size (current_gdbarch, PC_REGNUM));
 
   if (register_cached (PC_REGNUM))
-    regcache_collect (PC_REGNUM, iar);
+    regcache_raw_collect (current_regcache, PC_REGNUM, iar);
   if (register_cached (tdep->ppc_ps_regnum))
-    regcache_collect (tdep->ppc_ps_regnum, msr);
+    regcache_raw_collect (current_regcache, tdep->ppc_ps_regnum, msr);
   if (register_cached (tdep->ppc_cr_regnum))
-    regcache_collect (tdep->ppc_cr_regnum, cr);
+    regcache_raw_collect (current_regcache, tdep->ppc_cr_regnum, cr);
   if (register_cached (tdep->ppc_lr_regnum))
-    regcache_collect (tdep->ppc_lr_regnum, lr);
+    regcache_raw_collect (current_regcache, tdep->ppc_lr_regnum, lr);
   if (register_cached (tdep->ppc_ctr_regnum))
-    regcache_collect (tdep->ppc_ctr_regnum, ctr);
+    regcache_raw_collect (current_regcache, tdep->ppc_ctr_regnum, ctr);
   if (register_cached (tdep->ppc_xer_regnum))
-    regcache_collect (tdep->ppc_xer_regnum, xer);
+    regcache_raw_collect (current_regcache, tdep->ppc_xer_regnum, xer);
   if (tdep->ppc_fpscr_regnum >= 0
       && register_cached (tdep->ppc_fpscr_regnum))
-    regcache_collect (tdep->ppc_fpscr_regnum, fpscr);
+    regcache_raw_collect (current_regcache, tdep->ppc_fpscr_regnum, fpscr);
 }
 
 /* Store all registers into pthread PDTID, which doesn't have a kernel
@@ -1402,12 +1423,14 @@ store_regs_user_thread (pthdb_pthread_t pdtid)
       {
        if (arch64)
          {
-           regcache_collect (tdep->ppc_gp0_regnum + i, (void *) &int64);
+           regcache_raw_collect (current_regcache, tdep->ppc_gp0_regnum + i,
+                                 (void *) &int64);
            ctx.gpr[i] = int64;
          }
        else
          {
-           regcache_collect (tdep->ppc_gp0_regnum + i, (void *) &int32);
+           regcache_raw_collect (current_regcache, tdep->ppc_gp0_regnum + i,
+                                 (void *) &int32);
            ctx.gpr[i] = int32;
          }
       }
@@ -1539,7 +1562,8 @@ store_regs_kernel_thread (int regno, pthdb_tid_t tid)
 
          if (tdep->ppc_mq_regnum >= 0)
            if (register_cached (tdep->ppc_mq_regnum))
-             regcache_collect (tdep->ppc_mq_regnum, &sprs32.pt_mq);
+             regcache_raw_collect (current_regcache, tdep->ppc_mq_regnum,
+                                   &sprs32.pt_mq);
 
          ptrace32 (PTT_WRITE_SPRS, tid, (int *) &sprs32, 0, NULL);
        }
@@ -1738,10 +1762,11 @@ _initialize_aix_thread (void)
   target_new_objfile_chain = deprecated_target_new_objfile_hook;
   deprecated_target_new_objfile_hook = new_objfile;
 
-  add_show_from_set (add_set_cmd ("aix-thread", no_class, var_zinteger,
-                                 (char *) &debug_aix_thread, 
-                                 "Set debugging of AIX thread module.\n"
-                                  "Enables printf debugging output.\n",
-                                 &setdebuglist),
-                                 &showdebuglist);
+  deprecated_add_show_from_set
+    (add_set_cmd ("aix-thread", no_class, var_zinteger,
+                 (char *) &debug_aix_thread, 
+                 "Set debugging of AIX thread module.\n"
+                 "Enables printf debugging output.\n",
+                 &setdebuglist),
+     &showdebuglist);
 }
This page took 0.051413 seconds and 4 git commands to generate.