summaryrefslogtreecommitdiff
path: root/gdb/thread.c
diff options
context:
space:
mode:
authorPedro Alves <pedro@codesourcery.com>2009-03-31 15:23:54 +0000
committerPedro Alves <pedro@codesourcery.com>2009-03-31 15:23:54 +0000
commit6f72e3aabb5003b122630ba710030e0724b753e9 (patch)
tree8047b63ae25b29f33d36cac9f4bb3d2aa3657425 /gdb/thread.c
parent23d4c598a61989a7cb8a617e41d1649a82e41c69 (diff)
downloadgdb-6f72e3aabb5003b122630ba710030e0724b753e9.tar.gz
* remote.c (remote_notice_new_inferior): Use ptid_is_pid. Check
if the thread's ptid without a thread id field is in the list before calling thread_change_ptid. (extended_remote_attach_1): In non-stop mode, do not rely on querying the current thread, instead, query the thread list, and select the first thread of the process. * gdbthread.h (first_thread_of_process): Declare. * thread.c (first_thread_of_process): Define.
Diffstat (limited to 'gdb/thread.c')
-rw-r--r--gdb/thread.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gdb/thread.c b/gdb/thread.c
index a1617f2390b..0ce24c64a9e 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -401,6 +401,22 @@ in_thread_list (ptid_t ptid)
return 0; /* Never heard of 'im */
}
+/* Finds the first thread of the inferior given by PID. If PID is -1,
+ return the first thread in the list. */
+
+struct thread_info *
+first_thread_of_process (int pid)
+{
+ struct thread_info *tp, *ret = NULL;
+
+ for (tp = thread_list; tp; tp = tp->next)
+ if (pid == -1 || ptid_get_pid (tp->ptid) == pid)
+ if (ret == NULL || tp->num < ret->num)
+ ret = tp;
+
+ return ret;
+}
+
/* Print a list of thread ids currently known, and the total number of
threads. To be used from within catch_errors. */
static int