summaryrefslogtreecommitdiff
path: root/gdb/aix-thread.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2004-08-06 16:33:17 +0000
committerJoel Brobecker <brobecker@gnat.com>2004-08-06 16:33:17 +0000
commitba0f0d0bccf4207e00c7263669aaf70774235c65 (patch)
tree62e8f60617985eee6d08776f665241852071e7ce /gdb/aix-thread.c
parent4a35d23741f564130c1c8133d78f02a4ce3d8386 (diff)
downloadgdb-ba0f0d0bccf4207e00c7263669aaf70774235c65.tar.gz
* 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.
Diffstat (limited to 'gdb/aix-thread.c')
-rw-r--r--gdb/aix-thread.c59
1 files changed, 39 insertions, 20 deletions
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 07599c73861..4e5a41189c9 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -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