The attached patch handles a problem I have run into while working on threaded watchpoints. What happens is that a thread may die and we have other events occurring at the same time (e.g. watchpoints). If the thread_alive() function gets run by a gdb interface in the meantime, the thread will be removed on the thread list. What later happens is that we get the death event to handle and we see a tid that is not found on the thread list. We think we have discovered a new thread and add it. This causes all kinds of problems in the future if we attempt to get registers or switch to the dead thread, etc. My patch attempts to recognize the situation and avoid any processing of the dead thread event. I have tested this with the testsuite on i686 to verify there are no regressions. Daniel, I cc'd you in case this fixes some of the occasional random thread errors you were seeing and couldn't explain. Ok to commit? -- Jeff J. 2004-06-04 Jeff Johnston * infrun.c (handle_inferior_event): Don't treat an invalid ptid as a new thread event. * thread_db.c (thread_get_info_callback): If the thread is a zombie, return TD_THR_ZOMBIE. * (thread_from_lwp): If thread_get_info_callback returns TD_THR_ZOMBIE, check if the thread is still on the thread list and return a -1 ptid if not found. (thread_db_wait): If thread_from_lwp returns a -1 ptid, then change the status to TARGET_WAITKIND_SPURIOUS.