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);
{
struct thread_db_info *info = XCNEW (struct thread_db_info);
- info->pid = ptid_get_pid (inferior_ptid);
+ info->pid = inferior_ptid.pid ();
info->handle = handle;
/* The workaround works by reading from /proc/pid/status, so it is
}
}
-/* 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;
/* This ptid comes from linux-nat.c, which should always fill in the
LWP. */
- gdb_assert (ptid_get_lwp (ptid) != 0);
+ gdb_assert (ptid.lwp () != 0);
- info = get_thread_db_info (ptid_get_pid (ptid));
+ info = get_thread_db_info (ptid.pid ());
/* Access an lwp we know is stopped. */
- info->proc_handle.ptid = ptid;
- err = info->td_ta_map_lwp2thr_p (info->thread_agent, ptid_get_lwp (ptid),
+ info->proc_handle.thread = stopped;
+ err = info->td_ta_map_lwp2thr_p (info->thread_agent, ptid.lwp (),
&th);
if (err != TD_OK)
error (_("Cannot find user-level thread for LWP %ld: %s"),
- ptid_get_lwp (ptid), thread_db_err_str (err));
+ ptid.lwp (), thread_db_err_str (err));
err = info->td_thr_get_info_p (&th, &ti);
if (err != TD_OK)
{
struct thread_db_info *info;
- info = get_thread_db_info (ptid_get_pid (child));
+ info = get_thread_db_info (child.pid ());
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)
calls are made, we just assume they were; future changes
to how GDB accesses TLS could result in this passing
without exercising the calls it's supposed to. */
- ptid_t ptid = ptid_build (tdb_testinfo->info->pid, ti.ti_lid, 0);
+ ptid_t ptid = ptid_t (tdb_testinfo->info->pid, ti.ti_lid, 0);
struct thread_info *thread_info = find_thread_ptid (ptid);
if (thread_info != NULL && thread_info->priv != NULL)
{
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);
td_ta_map_lwp2thr uses ps_get_thread_area, but we can't use that
currently on core targets, as it uses ptrace directly. */
if (target_has_execution
- && linux_proc_task_list_dir_exists (ptid_get_pid (inferior_ptid)))
+ && linux_proc_task_list_dir_exists (inferior_ptid.pid ()))
info->td_ta_thr_iter_p = NULL;
else
CHK (TDB_VERBOSE_DLSYM (info, td_ta_thr_iter));
if (info->td_ta_thr_iter_p == NULL)
{
struct lwp_info *lp;
- int pid = ptid_get_pid (inferior_ptid);
+ int pid = inferior_ptid.pid ();
+ 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);
+ if (lp->ptid.pid () == pid)
+ 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
return 1;
/* This library "refused" to work on current inferior. */
- delete_thread_db_info (ptid_get_pid (inferior_ptid));
+ delete_thread_db_info (inferior_ptid.pid ());
return 0;
}
{
struct thread_db_info *info;
- info = get_thread_db_info (ptid_get_pid (inferior_ptid));
+ info = get_thread_db_info (inferior_ptid.pid ());
if (info != NULL)
return 1;
child's thread list, we'll mistakenly think it has no threads
since the thread PID fields won't match the PID we give to
libthread_db. */
- if (!linux_ns_same (ptid_get_pid (inferior_ptid), LINUX_NS_PID))
+ if (!linux_ns_same (inferior_ptid.pid (), LINUX_NS_PID))
{
warning (_ ("Target and debugger are in different PID "
"namespaces; thread lists and other data are "
return ptid;
}
- info = get_thread_db_info (ptid_get_pid (ptid));
+ info = get_thread_db_info (ptid.pid ());
/* If this process isn't using thread_db, we're done. */
if (info == NULL)
{
/* New image, it may or may not end up using thread_db. Assume
not unless we find otherwise. */
- delete_thread_db_info (ptid_get_pid (ptid));
+ delete_thread_db_info (ptid.pid ());
if (!thread_db_list)
unpush_target (&the_thread_db_target);
}
/* 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;
}
void
thread_db_target::mourn_inferior ()
{
- delete_thread_db_info (ptid_get_pid (inferior_ptid));
+ delete_thread_db_info (inferior_ptid.pid ());
beneath ()->mourn_inferior ();
{
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. */
thread_db_thread_info *priv = get_thread_db_thread_info (thread_info);
snprintf (buf, sizeof (buf), "Thread 0x%lx (LWP %ld)",
- (unsigned long) priv->tid, ptid_get_lwp (ptid));
+ (unsigned long) priv->tid, ptid.lwp ());
return buf;
}
/* 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)
{
td_err_e err;
psaddr_t address;
- thread_db_info *info = get_thread_db_info (ptid_get_pid (ptid));
+ thread_db_info *info = get_thread_db_info (ptid.pid ());
thread_db_thread_info *priv = get_thread_db_thread_info (thread_info);
/* Finally, get the address of the variable. */
thread_db_target::get_ada_task_ptid (long lwp, long thread)
{
/* NPTL uses a 1:1 model, so the LWP id suffices. */
- return ptid_build (ptid_get_pid (inferior_ptid), lwp, 0);
+ return ptid_t (inferior_ptid.pid (), lwp, 0);
}
void
{
struct thread_db_info *info;
- if (ptid_equal (ptid, minus_one_ptid))
- info = get_thread_db_info (ptid_get_pid (inferior_ptid));
+ if (ptid == minus_one_ptid)
+ info = get_thread_db_info (inferior_ptid.pid ());
else
- info = get_thread_db_info (ptid_get_pid (ptid));
+ info = get_thread_db_info (ptid.pid ());
/* This workaround is only needed for child fork lwps stopped in a
PTRACE_O_TRACEFORK event. When the inferior is resumed, the
static void
maintenance_check_libthread_db (const char *args, int from_tty)
{
- int inferior_pid = ptid_get_pid (inferior_ptid);
+ int inferior_pid = inferior_ptid.pid ();
struct thread_db_info *info;
if (inferior_pid == 0)