static void thread_db_find_new_threads_silently (ptid_t ptid) { volatile struct gdb_exception except; TRY_CATCH (except, RETURN_MASK_ERROR) { thread_db_find_new_threads_1 (ptid); }
/* Attach to lwp PTID, doing whatever else is required to have this LWP under the debugger's control --- e.g., enabling event reporting. Returns true on success. */ int thread_db_attach_lwp (ptid_t ptid) { td_thrhandle_t th; td_thrinfo_t ti; td_err_e err; struct thread_db_info *info; info = get_thread_db_info (GET_PID (ptid)); if (info == NULL) return 0; /* This ptid comes from linux-nat.c, which should always fill in the LWP. */ gdb_assert (GET_LWP (ptid) != 0); /* Access an lwp we know is stopped. */ info->proc_handle.ptid = ptid; /* If we have only looked at the first thread before libpthread was initialized, we may not know its thread ID yet. Make sure we do before we add another thread to the list. */ if (!have_threads (ptid)) thread_db_find_new_threads_1 (ptid); err = info->td_ta_map_lwp2thr_p (info->thread_agent, GET_LWP (ptid), &th); if (err != TD_OK) /* Cannot find user-level thread. */ return 0; err = info->td_thr_get_info_p (&th, &ti); if (err != TD_OK) { warning (_("Cannot get thread info: %s"), thread_db_err_str (err)); return 0; } attach_thread (ptid, &th, &ti); return 1; }
static int thread_get_info_callback (const td_thrhandle_t *thp, void *argp) { td_thrinfo_t ti; td_err_e err; ptid_t thread_ptid; struct thread_get_info_inout *inout; struct thread_db_info *info; inout = argp; info = inout->thread_db_info; err = info->td_thr_get_info_p (thp, &ti); if (err != TD_OK) error (_("thread_get_info_callback: cannot get thread info: %s"), thread_db_err_str (err)); /* Fill the cache. */ thread_ptid = ptid_build (info->pid, ti.ti_lid, 0); inout->thread_info = find_thread_ptid (thread_ptid); /* In the case of a zombie thread, don't continue. We don't want to attach to it thinking it is a new thread. */ if (ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE) return TD_THR_ZOMBIE; if (inout->thread_info == NULL) { /* New thread. Attach to it now (why wait?). */ if (!have_threads (thread_ptid)) thread_db_find_new_threads_1 (thread_ptid); else attach_thread (thread_ptid, thp, &ti); inout->thread_info = find_thread_ptid (thread_ptid); gdb_assert (inout->thread_info != NULL); } return 0; }