+2011-11-30 Kevin Buettner <kevinb@redhat.com>
+
+ * thread-db.c (TID_MAY_BE_REUSED): Define.
+ (find_new_threads_callback): Detect thread id reuse.
+
2010-10-14 Kevin Buettner <kevinb@redhat.com>
* lwp-pool.c (hash_find): Initialize `do_step' in the newly allocated
int thread_db_noisy = 0;
#define ALWAYS_UPDATE_THREAD_LIST 0
+#define TID_MAY_BE_REUSED 1
/*
* A tiny local symbol table.
/* Enter the thread into a local list
(unless it is TD_THR_UNKNOWN, which means its defunct). */
- if ((thread = thread_list_lookup_by_tid (ti.ti_tid)) == NULL)
+ if ((thread = thread_list_lookup_by_tid (ti.ti_tid)) == NULL
+#if TID_MAY_BE_REUSED
+ || thread->ti.ti_lid != ti.ti_lid
+#endif
+ )
{
if (ti.ti_state != TD_THR_UNKNOWN)
{
- thread = add_thread_to_list (&ti);
+ if (thread)
+ {
+ /* Thread is being reused. What has happened here is that
+ one thread has died and another was created using the
+ same thread identifier. */
+ if (thread_db_noisy)
+ fprintf (stderr, "(thread deletion / reuse: %s)\n", thread_debug_name (thread));
+ thread->ti = ti;
+ }
+ else
+ thread = add_thread_to_list (&ti);
if (thread_db_noisy)
fprintf (stderr, "(new thread %s)\n", thread_debug_name (thread));