static int threaded;
\f
-#ifndef TIDGET
-#define TIDGET(PID) (((PID) & 0x7fffffff) >> 16)
-#define PIDGET0(PID) (((PID) & 0xffff))
-#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID))
-#define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16))
-#endif
-
-#define THREAD_FLAG 0x80000000
-#define is_lwp(pid) (((pid) & THREAD_FLAG) == 0 && TIDGET (pid))
-#define GET_LWP(pid) TIDGET (pid)
-#define GET_PID(pid) PIDGET (pid)
-#define BUILD_LWP(tid, pid) MERGEPID (pid, tid)
+#define GET_LWP(ptid) ptid_get_lwp (ptid)
+#define GET_PID(ptid) ptid_get_pid (ptid)
+#define is_lwp(ptid) (GET_LWP (ptid) != 0)
+#define BUILD_LWP(lwp, pid) ptid_build (pid, lwp, 0)
#define is_cloned(pid) (GET_LWP (pid) != GET_PID (pid))
}
\f
-/* Helper functions. */
-
-static void
-restore_inferior_ptid (void *arg)
-{
- ptid_t *saved_ptid_ptr = arg;
- inferior_ptid = *saved_ptid_ptr;
- xfree (arg);
-}
-
-static struct cleanup *
-save_inferior_ptid (void)
-{
- ptid_t *saved_ptid_ptr;
-
- saved_ptid_ptr = xmalloc (sizeof (ptid_t));
- *saved_ptid_ptr = inferior_ptid;
- return make_cleanup (restore_inferior_ptid, saved_ptid_ptr);
-}
-\f
-
/* Implementation of the PREPARE_TO_PROCEED hook for the Linux LWP
layer.
child_ops.to_attach (args, from_tty);
/* Add the initial process as the first LWP to the list. */
- lp = add_lwp (BUILD_LWP (inferior_ptid, inferior_ptid));
+ lp = add_lwp (BUILD_LWP (PIDGET (inferior_ptid), PIDGET (inferior_ptid)));
/* Make sure the initial process is stopped. The user-level threads
layer might want to poke around in the inferior, and that won't
gdb_assert (lp->status == 0 || WIFSTOPPED (lp->status));
if (debug_lin_lwp && lp->status)
- fprintf_unfiltered (gdb_stdlog, "Pending %s for LWP %d on detach.\n",
+ fprintf_unfiltered (gdb_stdlog, "Pending %s for LWP %ld on detach.\n",
strsignal (WSTOPSIG (lp->status)), GET_LWP (lp->ptid));
while (lp->signalled && lp->stopped)
sigprocmask (SIG_SETMASK, &normal_mask, NULL);
sigemptyset (&blocked_mask);
- inferior_ptid = GET_PID (inferior_ptid);
+ inferior_ptid = pid_to_ptid (GET_PID (inferior_ptid));
child_ops.to_detach (args, from_tty);
}
\f
{
if (debug_lin_lwp)
fprintf_unfiltered (gdb_stdlog,
- "Using pending wait status for LWP %d.\n",
- (int) GET_LWP (lp->ptid));
+ "Using pending wait status for LWP %ld.\n",
+ GET_LWP (lp->ptid));
status = lp->status;
lp->status = 0;
{
if (debug_lin_lwp)
fprintf_unfiltered (gdb_stdlog,
- "Waiting for specific LWP %d.\n",
- (int) GET_LWP (ptid));
+ "Waiting for specific LWP %ld.\n",
+ GET_LWP (ptid));
/* We have a specific LWP to check. */
lp = find_lwp_pid (ptid);
if (debug_lin_lwp)
if (status)
fprintf_unfiltered (gdb_stdlog,
- "Using pending wait status for LWP %d.\n",
+ "Using pending wait status for LWP %ld.\n",
GET_LWP (lp->ptid));
/* If we have to wait, take into account whether PID is a cloned