From fb5e7258b364c6dc452e5126dfcf1b010a4cf8f7 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 8 Sep 2008 21:26:36 +0000 Subject: [PATCH] * bsd-uthread.c (bsd_uthread_wait): Decorate the main thread with thread_change_ptid. Check for exited threads. (bsd_uthread_find_new_threads): Check for exited threads. --- gdb/ChangeLog | 6 ++++++ gdb/bsd-uthread.c | 20 +++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 22bd2b284b2..f5f8452b94f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2008-09-08 Pedro Alves + + * bsd-uthread.c (bsd_uthread_wait): Decorate the main thread with + thread_change_ptid. Check for exited threads. + (bsd_uthread_find_new_threads): Check for exited threads. + 2008-09-08 Pedro Alves * inf-ptrace.c: Include "gdbthread.h". diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c index df038e6771e..b6a18f0144f 100644 --- a/gdb/bsd-uthread.c +++ b/gdb/bsd-uthread.c @@ -367,14 +367,16 @@ bsd_uthread_wait (ptid_t ptid, struct target_waitstatus *status) } } - /* HACK: Twiddle INFERIOR_PTID such that the initial thread of a - process isn't recognized as a new thread. */ - if (ptid_get_tid (ptid) != 0 && !in_thread_list (ptid) - && ptid_get_tid (inferior_ptid) == 0) - { - add_thread_silent (ptid); - inferior_ptid = ptid; - } + /* If INFERIOR_PTID doesn't have a tid member yet, and we now have a + ptid with tid set, then ptid is still the initial thread of + the process. Notify GDB core about it. */ + if (ptid_get_tid (inferior_ptid) == 0 + && ptid_get_tid (ptid) != 0 && !in_thread_list (ptid)) + thread_change_ptid (inferior_ptid, ptid); + + /* Don't let the core see a ptid without a corresponding thread. */ + if (!in_thread_list (ptid) || is_exited (ptid)) + add_thread (ptid); return ptid; } @@ -419,7 +421,7 @@ bsd_uthread_find_new_threads (void) { ptid_t ptid = ptid_build (pid, 0, addr); - if (!in_thread_list (ptid)) + if (!in_thread_list (ptid) || is_exited (ptid)) add_thread (ptid); addr = read_memory_typed_address (addr + offset, -- 2.30.2