Index: linux-thread-db.c =================================================================== RCS file: /cvs/src/src/gdb/linux-thread-db.c,v retrieving revision 1.16 diff -u -p -r1.16 linux-thread-db.c --- linux-thread-db.c 5 May 2006 22:42:43 -0000 1.16 +++ linux-thread-db.c 20 Jun 2006 17:51:01 -0000 @@ -1006,6 +1006,9 @@ thread_db_fetch_registers (int regno) } thread_info = find_thread_pid (inferior_ptid); + if (!thread_info) + error (_("Stopped at dead thread %ld; should not happen."), + (long) GET_THREAD (inferior_ptid)); thread_db_map_id2thr (thread_info, 1); err = td_thr_getgregs_p (&thread_info->private->th, gregset); @@ -1127,6 +1130,8 @@ thread_db_thread_alive (ptid_t ptid) struct thread_info *thread_info; thread_info = find_thread_pid (ptid); + if (!thread_info) + return 0; thread_db_map_id2thr (thread_info, 0); if (!thread_info->private->th_valid) return 0; @@ -1145,9 +1150,9 @@ thread_db_thread_alive (ptid_t ptid) thread_info->private->ti_valid = 1; } - if (thread_info->private->ti.ti_state == TD_THR_UNKNOWN - || thread_info->private->ti.ti_state == TD_THR_ZOMBIE) - return 0; /* A zombie thread. */ + /* Never 0 on TD_THR_ZOMBIE to be able to trace pthread_exit(3). */ + if (thread_info->private->ti.ti_state == TD_THR_UNKNOWN) + return 0; /* A disappeared thread. */ return 1; }