+2004-08-06 Joel Brobecker <brobecker@gnat.com>
+
+ * aix-thread.c (get_signaled_thread): New function.
+ (iter_trap): Delete, no longer used.
+ (iter_tid): New function.
+ (pd_update): Find the thread that received the SIGTRAP signal
+ by first locating the kernel thread, and then finding its
+ associated thread.
+
2004-08-06 Ulrich Weigand <uweigand@de.ibm.com>
* lin-lwp.c (child_wait): Continue inferior after processing
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:
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,
{
int status;
ptid_t ptid;
- struct thread_info *thread;
+ pthdb_tid_t tid;
+ struct thread_info *thread = NULL;
if (!pd_active)
return inferior_ptid;
/* 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