bookkeeping. */
struct thread_db_info *thread_db_list;
-static void thread_db_find_new_threads_1 (ptid_t ptid);
-static void thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new);
+static void thread_db_find_new_threads_1 (thread_info *stopped);
+static void thread_db_find_new_threads_2 (thread_info *stopped,
+ bool until_no_new);
static void check_thread_signals (void);
}
}
-/* Fetch the user-level thread id of PTID. */
+/* Fetch the user-level thread id of PTID. STOPPED is a stopped
+ thread that we can use to access memory. */
static struct thread_info *
-thread_from_lwp (ptid_t ptid)
+thread_from_lwp (thread_info *stopped, ptid_t ptid)
{
td_thrhandle_t th;
td_thrinfo_t ti;
info = get_thread_db_info (ptid_get_pid (ptid));
/* Access an lwp we know is stopped. */
- info->proc_handle.ptid = ptid;
+ info->proc_handle.thread = stopped;
err = info->td_ta_map_lwp2thr_p (info->thread_agent, ptid_get_lwp (ptid),
&th);
if (err != TD_OK)
if (info == NULL)
return 0;
- thread_from_lwp (child);
+ thread_info *stopped = find_thread_ptid (parent);
- /* If we do not know about the main thread yet, this would be a good
- time to find it. */
- thread_from_lwp (parent);
+ thread_from_lwp (stopped, child);
+
+ /* If we do not know about the main thread's pthread info yet, this
+ would be a good time to find it. */
+ thread_from_lwp (stopped, parent);
return 1;
}
otherwise. */
static int
-thread_db_find_new_threads_silently (ptid_t ptid)
+thread_db_find_new_threads_silently (thread_info *stopped)
{
TRY
{
- thread_db_find_new_threads_2 (ptid, 1);
+ thread_db_find_new_threads_2 (stopped, true);
}
CATCH (except, RETURN_MASK_ERROR)
CHK (TDB_VERBOSE_DLSYM (info, td_ta_new));
/* Initialize the structure that identifies the child process. */
- info->proc_handle.ptid = inferior_ptid;
+ info->proc_handle.thread = inferior_thread ();
/* Now attempt to open a connection to the thread library. */
err = info->td_ta_new_p (&info->proc_handle, &info->thread_agent);
{
struct lwp_info *lp;
int pid = ptid_get_pid (inferior_ptid);
+ thread_info *curr_thread = inferior_thread ();
linux_stop_and_wait_all_lwps ();
ALL_LWPS (lp)
if (ptid_get_pid (lp->ptid) == pid)
- thread_from_lwp (lp->ptid);
+ thread_from_lwp (curr_thread, lp->ptid);
linux_unstop_all_lwps ();
}
- else if (thread_db_find_new_threads_silently (inferior_ptid) != 0)
+ else if (thread_db_find_new_threads_silently (inferior_thread ()) != 0)
{
/* Even if libthread_db initializes, if the thread list is
corrupted, we'd not manage to list any threads. Better reject this
}
/* Fill in the thread's user-level thread id and status. */
- thread_from_lwp (ptid);
+ thread_from_lwp (find_thread_ptid (ptid), ptid);
return ptid;
}
{
td_thrinfo_t ti;
td_err_e err;
- ptid_t ptid;
struct thread_info *tp;
struct callback_data *cb_data = (struct callback_data *) data;
struct thread_db_info *info = cb_data->info;
return 0;
}
- ptid = ptid_build (info->pid, ti.ti_lid, 0);
+ ptid_t ptid (info->pid, ti.ti_lid);
tp = find_thread_ptid (ptid);
if (tp == NULL || tp->priv == NULL)
record_thread (info, tp, ptid, th_p, &ti);
searches in a row do not discover any new threads. */
static void
-thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new)
+thread_db_find_new_threads_2 (thread_info *stopped, bool until_no_new)
{
td_err_e err = TD_OK;
struct thread_db_info *info;
int i, loop;
- info = get_thread_db_info (ptid_get_pid (ptid));
+ info = get_thread_db_info (stopped->ptid.pid ());
/* Access an lwp we know is stopped. */
- info->proc_handle.ptid = ptid;
+ info->proc_handle.thread = stopped;
if (until_no_new)
{
}
static void
-thread_db_find_new_threads_1 (ptid_t ptid)
+thread_db_find_new_threads_1 (thread_info *stopped)
{
- thread_db_find_new_threads_2 (ptid, 0);
+ thread_db_find_new_threads_2 (stopped, 0);
}
/* Implement the to_update_thread_list target method for this
if (info == NULL)
continue;
- thread = any_live_thread_of_process (inf->pid);
+ thread = any_live_thread_of_inferior (inf);
if (thread == NULL || thread->executing)
continue;
if (target_has_execution_1 (thread->ptid))
continue;
- thread_db_find_new_threads_1 (thread->ptid);
+ thread_db_find_new_threads_1 (thread);
}
/* Give the beneath target a chance to do extra processing. */
/* We may not have discovered the thread yet. */
if (thread_info != NULL && thread_info->priv == NULL)
- thread_info = thread_from_lwp (ptid);
+ thread_info = thread_from_lwp (thread_info, ptid);
if (thread_info != NULL && thread_info->priv != NULL)
{