Replace TIDGET with ptid_get_lwp.
Replace GET_LWP with ptid_get_lwp.
* aix-thread.c (BUILD_THREAD, BUILD_LWP): Remove.
Replace BUILD_THREAD with ptid_build.
Replace BUILD_LWP with ptid_build.
Replace PIDGET with ptid_get_pid.
Replace TIDGET with ptid_get_lwp.
* alphabsd-nat.c: Replace PIDGET with ptid_get_pid.
* amd64-linux-nat.c: Replace PIDGET with ptid_get_pid.
Replace TIDGET with ptid_get_lwp.
* amd64bsd-nat.c: Replace PIDGET with ptid_get_pid.
* arm-linux-nat.c: Replace PIDGET with ptid_get_pid.
Replace TIDGET with ptid_get_lwp.
Replace GET_LWP with ptid_get_lwp.
* armnbsd-nat.c: Replace PIDGET with ptid_get_pid.
* auxv.c: Likewise.
* breakpoint.c: Likewise.
* common/ptid.c (ptid_is_pid): Condense check for
null_ptid and minus_one_ptid.
(ptid_lwp_p): New function.
(ptid_tid_p): New function.
* common/ptid.h: Update comments for accessors.
(ptid_lwp_p): New prototype.
(ptid_tid_p): New prototype.
* defs.h (PIDGET, TIDGET, MERGEPID): Do not define.
* gcore.c: Replace PIDGET with ptid_get_pid.
* gdbthread.h: Likewise.
* gnu-nat.c: Likewise.
* hppa-linux-nat.c: Replace PIDGET with ptid_get_pid.
Replace TIDGET with ptid_get_lwp.
* hppabsd-nat.c: Replace PIDGET with ptid_get_pid.
* hppanbsd-nat.c: Likewise.
* i386-linux-nat.c: Replace PIDGET with ptid_get_pid.
Replace TIDGET with ptid_get_lwp.
* i386bsd-nat.c: Replace PIDGET with ptid_get_pid.
* ia64-linux-nat.c: Replace PIDGET with ptid_get_pid.
* infcmd.c: Likewise.
* inferior.h: Likewise.
* inflow.c: Likewise.
* infrun.c: Likewise.
* linux-fork.c: Likewise.
* linux-nat.c: Replace PIDGET with ptid_get_pid.
Replace GET_PID with ptid_get_pid.
Replace is_lwp with ptid_lwp_p.
Replace GET_LWP with ptid_get_lwp.
Replace BUILD_LWP with ptid_build.
+2013-09-30 Luis Machado <lgustavo@codesourcery.com>
+
+ * aarch64-linux-nat.c: Replace PIDGET with ptid_get_pid.
+ Replace TIDGET with ptid_get_lwp.
+ Replace GET_LWP with ptid_get_lwp.
+ * aix-thread.c (BUILD_THREAD, BUILD_LWP): Remove.
+ Replace BUILD_THREAD with ptid_build.
+ Replace BUILD_LWP with ptid_build.
+ Replace PIDGET with ptid_get_pid.
+ Replace TIDGET with ptid_get_lwp.
+ * alphabsd-nat.c: Replace PIDGET with ptid_get_pid.
+ * amd64-linux-nat.c: Replace PIDGET with ptid_get_pid.
+ Replace TIDGET with ptid_get_lwp.
+ * amd64bsd-nat.c: Replace PIDGET with ptid_get_pid.
+ * arm-linux-nat.c: Replace PIDGET with ptid_get_pid.
+ Replace TIDGET with ptid_get_lwp.
+ Replace GET_LWP with ptid_get_lwp.
+ * armnbsd-nat.c: Replace PIDGET with ptid_get_pid.
+ * auxv.c: Likewise.
+ * breakpoint.c: Likewise.
+ * common/ptid.c (ptid_is_pid): Condense check for
+ null_ptid and minus_one_ptid.
+ (ptid_lwp_p): New function.
+ (ptid_tid_p): New function.
+ * common/ptid.h: Update comments for accessors.
+ (ptid_lwp_p): New prototype.
+ (ptid_tid_p): New prototype.
+ * defs.h (PIDGET, TIDGET, MERGEPID): Do not define.
+ * gcore.c: Replace PIDGET with ptid_get_pid.
+ * gdbthread.h: Likewise.
+ * gnu-nat.c: Likewise.
+ * hppa-linux-nat.c: Replace PIDGET with ptid_get_pid.
+ Replace TIDGET with ptid_get_lwp.
+ * hppabsd-nat.c: Replace PIDGET with ptid_get_pid.
+ * hppanbsd-nat.c: Likewise.
+ * i386-linux-nat.c: Replace PIDGET with ptid_get_pid.
+ Replace TIDGET with ptid_get_lwp.
+ * i386bsd-nat.c: Replace PIDGET with ptid_get_pid.
+ * ia64-linux-nat.c: Replace PIDGET with ptid_get_pid.
+ * infcmd.c: Likewise.
+ * inferior.h: Likewise.
+ * inflow.c: Likewise.
+ * infrun.c: Likewise.
+ * linux-fork.c: Likewise.
+ * linux-nat.c: Replace PIDGET with ptid_get_pid.
+ Replace GET_PID with ptid_get_pid.
+ Replace is_lwp with ptid_lwp_p.
+ Replace GET_LWP with ptid_get_lwp.
+ Replace BUILD_LWP with ptid_build.
+
2013-09-28 Mike Frysinger <vapier@gentoo.org>
* common/linux-btrace.c: Move sys/syscall.h out of the
static int
get_thread_id (ptid_t ptid)
{
- int tid = TIDGET (ptid);
+ int tid = ptid_get_lwp (ptid);
if (0 == tid)
- tid = PIDGET (ptid);
+ tid = ptid_get_pid (ptid);
return tid;
}
if (DR_HAS_CHANGED (info->dr_changed_bp)
|| DR_HAS_CHANGED (info->dr_changed_wp))
{
- int tid = GET_LWP (lwp->ptid);
+ int tid = ptid_get_lwp (lwp->ptid);
struct aarch64_debug_reg_state *state
= aarch64_get_debug_reg_state (ptid_get_pid (lwp->ptid));
#define PD_TID(ptid) (pd_active && ptid_get_tid (ptid) != 0)
-/* Build a thread ptid. */
-#define BUILD_THREAD(TID, PID) ptid_build (PID, 0, TID)
-
-/* Build and lwp ptid. */
-#define BUILD_LWP(LWP, PID) MERGEPID (PID, LWP)
-
/* pthdb_user_t value that we pass to pthdb functions. 0 causes
PTHDB_BAD_USER errors, so use 1. */
ptid = *ptidp;
if (PD_TID (ptid))
- *ptidp = pid_to_ptid (PIDGET (ptid));
+ *ptidp = pid_to_ptid (ptid_get_pid (ptid));
}
/* pthdb callback: for <i> from 0 to COUNT, set SYMBOLS[<i>].addr to
while (1)
{
- if (getthrds (PIDGET (inferior_ptid), &thrinf,
+ if (getthrds (ptid_get_pid (inferior_ptid), &thrinf,
sizeof (thrinf), &ktid, 1) != 1)
break;
/* Apply differences between the two arrays to GDB's thread list. */
- infpid = PIDGET (inferior_ptid);
+ infpid = ptid_get_pid (inferior_ptid);
for (pi = gi = 0; pi < pcount || gi < gcount;)
{
if (pi == pcount)
}
else if (gi == gcount)
{
- thread = add_thread (BUILD_THREAD (pbuf[pi].pthid, infpid));
+ thread = add_thread (ptid_build (infpid, 0, pbuf[pi].pthid);
thread->private = xmalloc (sizeof (struct private_thread_info));
thread->private->pdtid = pbuf[pi].pdtid;
thread->private->tid = pbuf[pi].tid;
ptid_t pptid, gptid;
int cmp_result;
- pptid = BUILD_THREAD (pbuf[pi].pthid, infpid);
+ pptid = ptid_build (infpid, 0, pbuf[pi].pthid);
gptid = gbuf[gi]->ptid;
pdtid = pbuf[pi].pdtid;
tid = pbuf[pi].tid;
struct cleanup *cleanup = save_inferior_ptid ();
struct target_ops *beneath = find_target_beneath (ops);
- inferior_ptid = pid_to_ptid (PIDGET (inferior_ptid));
+ inferior_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
beneath->to_resume (beneath, ptid, step, sig);
do_cleanups (cleanup);
}
thread = find_thread_ptid (ptid);
if (!thread)
error (_("aix-thread resume: unknown pthread %ld"),
- TIDGET (ptid));
+ ptid_get_lwp (ptid));
tid[0] = thread->private->tid;
if (tid[0] == PTHDB_INVALID_TID)
error (_("aix-thread resume: no tid for pthread %ld"),
- TIDGET (ptid));
+ ptid_get_lwp (ptid));
tid[1] = 0;
if (arch64)
pid_to_prc (&ptid);
- inferior_ptid = pid_to_ptid (PIDGET (inferior_ptid));
+ inferior_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
ptid = beneath->to_wait (beneath, ptid, status, options);
do_cleanups (cleanup);
- if (PIDGET (ptid) == -1)
+ if (ptid_get_pid (ptid) == -1)
return pid_to_ptid (-1);
/* Check whether libpthdebug might be ready to be initialized. */
LONGEST xfer;
struct target_ops *beneath = find_target_beneath (ops);
- inferior_ptid = pid_to_ptid (PIDGET (inferior_ptid));
+ inferior_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
xfer = beneath->to_xfer_partial (beneath, object, annex,
readbuf, writebuf, offset, len);
{
struct reg gregs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &gregs, 0) == -1)
perror_with_name (_("Couldn't get registers"));
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
if (regno == -1 || getregs_supplies (regno))
{
struct reg gregs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &gregs, 0) == -1)
perror_with_name (_("Couldn't get registers"));
alphabsd_fill_reg (regcache, (char *) &gregs, regno);
- if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &gregs, 0) == -1)
perror_with_name (_("Couldn't write registers"));
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
alphabsd_fill_fpreg (regcache, (char *) &fpregs, regno);
- if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
int tid;
/* GNU/Linux LWP ID's are process ID's. */
- tid = TIDGET (inferior_ptid);
+ tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum))
{
int tid;
/* GNU/Linux LWP ID's are process ID's. */
- tid = TIDGET (inferior_ptid);
+ tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
if (regnum == -1 || amd64_native_gregset_supplies_p (gdbarch, regnum))
{
int tid;
unsigned long value;
- tid = TIDGET (ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = PIDGET (ptid);
+ tid = ptid_get_pid (ptid);
errno = 0;
value = ptrace (PTRACE_PEEKUSER, tid,
{
int tid;
- tid = TIDGET (ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = PIDGET (ptid);
+ tid = ptid_get_pid (ptid);
errno = 0;
ptrace (PTRACE_POKEUSER, tid,
static uint64_t xcr0;
/* GNU/Linux LWP ID's are process ID's. */
- tid = TIDGET (inferior_ptid);
+ tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
/* Get CS register. */
errno = 0;
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
amd64_collect_native_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
amd64_collect_fxsave (regcache, regnum, &fpregs);
- if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
{
struct dbreg dbregs;
- if (ptrace (PT_GETDBREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETDBREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
perror_with_name (_("Couldn't read debug registers"));
{
struct dbreg dbregs;
- if (ptrace (PT_GETDBREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETDBREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
perror_with_name (_("Couldn't get debug registers"));
DBREG_DRX ((&dbregs), regnum) = value;
- if (ptrace (PT_SETDBREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETDBREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
perror_with_name (_("Couldn't write debug registers"));
}
static int
get_thread_id (ptid_t ptid)
{
- int tid = TIDGET (ptid);
+ int tid = ptid_get_lwp (ptid);
if (0 == tid)
- tid = PIDGET (ptid);
+ tid = ptid_get_pid (ptid);
return tid;
}
/* Now make sure that the kernel supports reading these
registers. Support was added in 2.6.30. */
- pid = GET_LWP (inferior_ptid);
+ pid = ptid_get_lwp (inferior_ptid);
errno = 0;
buf = alloca (VFP_REGS_SIZE);
if (ptrace (PTRACE_GETVFPREGS, pid, 0, buf) < 0
arm_linux_hw_breakpoint_initialize (gdbarch, bp_tgt, &p);
ALL_LWPS (lp)
- arm_linux_insert_hw_breakpoint1 (&p, TIDGET (lp->ptid), 0);
+ arm_linux_insert_hw_breakpoint1 (&p, ptid_get_lwp (lp->ptid), 0);
return 0;
}
arm_linux_hw_breakpoint_initialize (gdbarch, bp_tgt, &p);
ALL_LWPS (lp)
- arm_linux_remove_hw_breakpoint1 (&p, TIDGET (lp->ptid), 0);
+ arm_linux_remove_hw_breakpoint1 (&p, ptid_get_lwp (lp->ptid), 0);
return 0;
}
arm_linux_hw_watchpoint_initialize (addr, len, rw, &p);
ALL_LWPS (lp)
- arm_linux_insert_hw_breakpoint1 (&p, TIDGET (lp->ptid), 1);
+ arm_linux_insert_hw_breakpoint1 (&p, ptid_get_lwp (lp->ptid), 1);
return 0;
}
arm_linux_hw_watchpoint_initialize (addr, len, rw, &p);
ALL_LWPS (lp)
- arm_linux_remove_hw_breakpoint1 (&p, TIDGET (lp->ptid), 1);
+ arm_linux_remove_hw_breakpoint1 (&p, ptid_get_lwp (lp->ptid), 1);
return 0;
}
static void
arm_linux_new_thread (struct lwp_info *lp)
{
- int tid = TIDGET (lp->ptid);
+ int tid = ptid_get_lwp (lp->ptid);
const struct arm_linux_hwbp_cap *info = arm_linux_get_hwbp_cap ();
if (info != NULL)
if (info != NULL)
{
int i;
- int tid = TIDGET (tp->ptid);
+ int tid = ptid_get_lwp (tp->ptid);
struct arm_linux_thread_points *t = NULL, *p;
for (i = 0;
struct reg inferior_registers;
int ret;
- ret = ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &inferior_registers, 0);
if (ret < 0)
int ret;
int regno;
- ret = ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &inferior_registers, 0);
if (ret < 0)
struct fpreg inferior_fp_registers;
int ret;
- ret = ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
if (ret < 0)
int ret;
int regno;
- ret = ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
if (ret < 0)
struct reg inferior_registers;
int ret;
- ret = ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ ret = ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &inferior_registers, 0);
if (ret < 0)
break;
}
- ret = ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ ret = ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &inferior_registers, 0);
if (ret < 0)
inferior_registers.r_pc = pc_val | psr_val;
}
- ret = ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ ret = ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &inferior_registers, 0);
if (ret < 0)
struct fpreg inferior_fp_registers;
int ret;
- ret = ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ ret = ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
if (ret < 0)
break;
}
- ret = ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
+ ret = ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
if (ret < 0)
regcache_raw_collect (regcache, ARM_FPS_REGNUM,
(char *) &inferior_fp_registers.fpr_fpsr);
- ret = ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
+ ret = ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &inferior_fp_registers, 0);
if (ret < 0)
int fd;
LONGEST n;
- pathname = xstrprintf ("/proc/%d/auxv", PIDGET (inferior_ptid));
+ pathname = xstrprintf ("/proc/%d/auxv", ptid_get_pid (inferior_ptid));
fd = gdb_open_cloexec (pathname, writebuf != NULL ? O_WRONLY : O_RDONLY, 0);
xfree (pathname);
if (fd < 0)
struct cleanup *old_chain = save_inferior_ptid ();
struct inferior *inf = current_inferior ();
- if (PIDGET (ptid) == PIDGET (inferior_ptid))
+ if (ptid_get_pid (ptid) == ptid_get_pid (inferior_ptid))
error (_("Cannot detach breakpoints of inferior_ptid"));
/* Set inferior_ptid; remove_breakpoint_1 uses this global. */
static int
insert_catch_fork (struct bp_location *bl)
{
- return target_insert_fork_catchpoint (PIDGET (inferior_ptid));
+ return target_insert_fork_catchpoint (ptid_get_pid (inferior_ptid));
}
/* Implement the "remove" breakpoint_ops method for fork
static int
remove_catch_fork (struct bp_location *bl)
{
- return target_remove_fork_catchpoint (PIDGET (inferior_ptid));
+ return target_remove_fork_catchpoint (ptid_get_pid (inferior_ptid));
}
/* Implement the "breakpoint_hit" breakpoint_ops method for fork
static int
insert_catch_vfork (struct bp_location *bl)
{
- return target_insert_vfork_catchpoint (PIDGET (inferior_ptid));
+ return target_insert_vfork_catchpoint (ptid_get_pid (inferior_ptid));
}
/* Implement the "remove" breakpoint_ops method for vfork
static int
remove_catch_vfork (struct bp_location *bl)
{
- return target_remove_vfork_catchpoint (PIDGET (inferior_ptid));
+ return target_remove_vfork_catchpoint (ptid_get_pid (inferior_ptid));
}
/* Implement the "breakpoint_hit" breakpoint_ops method for vfork
}
}
- return target_set_syscall_catchpoint (PIDGET (inferior_ptid),
+ return target_set_syscall_catchpoint (ptid_get_pid (inferior_ptid),
inf_data->total_syscalls_count != 0,
inf_data->any_syscall_count,
VEC_length (int,
}
}
- return target_set_syscall_catchpoint (PIDGET (inferior_ptid),
+ return target_set_syscall_catchpoint (ptid_get_pid (inferior_ptid),
inf_data->total_syscalls_count != 0,
inf_data->any_syscall_count,
VEC_length (int,
static int
insert_catch_exec (struct bp_location *bl)
{
- return target_insert_exec_catchpoint (PIDGET (inferior_ptid));
+ return target_insert_exec_catchpoint (ptid_get_pid (inferior_ptid));
}
static int
remove_catch_exec (struct bp_location *bl)
{
- return target_remove_exec_catchpoint (PIDGET (inferior_ptid));
+ return target_remove_exec_catchpoint (ptid_get_pid (inferior_ptid));
}
static int
int
ptid_is_pid (ptid_t ptid)
{
- if (ptid_equal (minus_one_ptid, ptid))
- return 0;
- if (ptid_equal (null_ptid, ptid))
+ if (ptid_equal (minus_one_ptid, ptid)
+ || ptid_equal (null_ptid, ptid))
return 0;
return (ptid_get_lwp (ptid) == 0 && ptid_get_tid (ptid) == 0);
}
+
+/* Returns true if PTID represents a lwp. */
+
+int
+ptid_lwp_p (ptid_t ptid)
+{
+ if (ptid_equal (minus_one_ptid, ptid)
+ || ptid_equal (null_ptid, ptid))
+ return 0;
+
+ return (ptid_get_lwp (ptid) != 0);
+}
+
+/* Returns true if PTID represents a tid. */
+
+int
+ptid_tid_p (ptid_t ptid)
+{
+ if (ptid_equal (minus_one_ptid, ptid)
+ || ptid_equal (null_ptid, ptid))
+ return 0;
+
+ return (ptid_get_tid (ptid) != 0);
+}
ptid_get_lwp - Fetch the lwp component of a ptid.
ptid_get_tid - Fetch the tid component of a ptid.
ptid_equal - Test to see if two ptids are equal.
+ ptid_is_pid - Test if a ptid is of the form (pid, 0, 0).
+ ptid_lwp_p - Test if a ptid's lwp component is non-zero.
+ ptid_tid_p - Test if a ptid's tid component is non-zero.
Please do NOT access the struct ptid members directly (except, of
course, in the implementation of the above ptid manipulation
/* Return true if PTID represents a process id. */
int ptid_is_pid (ptid_t ptid);
+/* Return true if PTID's lwp member is non-zero. */
+int ptid_lwp_p (ptid_t ptid);
+
+/* Return true if PTID's tid member is non-zero. */
+int ptid_tid_p (ptid_t ptid);
+
#endif
extern int use_windows;
-/* Provide default definitions of PIDGET, TIDGET, and MERGEPID.
- The name ``TIDGET'' is a historical accident. Many uses of TIDGET
- in the code actually refer to a lightweight process id, i.e,
- something that can be considered a process id in its own right for
- certain purposes. */
-
-#ifndef PIDGET
-#define PIDGET(PTID) (ptid_get_pid (PTID))
-#define TIDGET(PTID) (ptid_get_lwp (PTID))
-#define MERGEPID(PID, TID) ptid_build (PID, TID, 0)
-#endif
-
/* If this definition isn't overridden by the header files, assume
that isatty and fileno exist on this system. */
#ifndef ISATTY
else
{
/* Default corefile name is "core.PID". */
- corefilename = xstrprintf ("core.%d", PIDGET (inferior_ptid));
+ corefilename = xstrprintf ("core.%d", ptid_get_pid (inferior_ptid));
}
filename_chain = make_cleanup (xfree, corefilename);
extern void switch_to_thread (ptid_t ptid);
/* Marks thread PTID is running, or stopped.
- If PIDGET (PTID) is -1, marks all threads. */
+ If ptid_get_pid (PTID) is -1, marks all threads. */
extern void set_running (ptid_t ptid, int running);
/* Marks or clears thread(s) PTID as having been requested to stop.
/* In the frontend's perpective is there any thread running? */
extern int any_running (void);
-/* Marks thread PTID as executing, or not. If PIDGET (PTID) is -1,
+/* Marks thread PTID as executing, or not. If ptid_get_pid (PTID) is -1,
marks all threads.
Note that this is different from the running state. See the
"executing" -> "running"
"exited" -> "exited"
- If PIDGET (PTID) is -1, go over all threads.
+ If ptid_get_pid (PTID) is -1, go over all threads.
Notifications are only emitted if the thread state did change. */
extern void finish_thread_state (ptid_t ptid);
if (resume_all)
/* Allow all threads to run, except perhaps single-stepping one. */
{
- inf_debug (inf, "running all threads; tid = %d", PIDGET (inferior_ptid));
+ inf_debug (inf, "running all threads; tid = %d",
+ ptid_get_pid (inferior_ptid));
ptid = inferior_ptid; /* What to step. */
inf_set_threads_resume_sc (inf, 0, 1);
}
}
/* GNU/Linux LWP ID's are process ID's. */
- tid = TIDGET (inferior_ptid);
+ tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
errno = 0;
val = ptrace (PTRACE_PEEKUSER, tid, hppa_linux_register_addr (regno, 0), 0);
return;
/* GNU/Linux LWP ID's are process ID's. */
- tid = TIDGET (inferior_ptid);
+ tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
errno = 0;
regcache_raw_collect (regcache, regno, &val);
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
hppabsd_collect_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
hppabsd_collect_fpregset (regcache, &fpregs, regnum);
- if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
hppanbsd_collect_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
hppanbsd_collect_fpregset (regcache, &fpregs, regnum);
- if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
}
/* GNU/Linux LWP ID's are process ID's. */
- tid = TIDGET (inferior_ptid);
+ tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
errno = 0;
val = ptrace (PTRACE_PEEKUSER, tid,
return;
/* GNU/Linux LWP ID's are process ID's. */
- tid = TIDGET (inferior_ptid);
+ tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
errno = 0;
regcache_raw_collect (regcache, regno, &val);
}
/* GNU/Linux LWP ID's are process ID's. */
- tid = TIDGET (inferior_ptid);
+ tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
/* Use the PTRACE_GETFPXREGS request whenever possible, since it
transfers more registers in one system call, and we'll cache the
}
/* GNU/Linux LWP ID's are process ID's. */
- tid = TIDGET (inferior_ptid);
+ tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
/* Use the PTRACE_SETFPXREGS requests whenever possible, since it
transfers more registers in one system call. But remember that
int tid;
unsigned long value;
- tid = TIDGET (ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = PIDGET (ptid);
+ tid = ptid_get_pid (ptid);
errno = 0;
value = ptrace (PTRACE_PEEKUSER, tid,
{
int tid;
- tid = TIDGET (ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = PIDGET (ptid);
+ tid = ptid_get_pid (ptid);
errno = 0;
ptrace (PTRACE_POKEUSER, tid,
i386_linux_resume (struct target_ops *ops,
ptid_t ptid, int step, enum gdb_signal signal)
{
- int pid = PIDGET (ptid);
+ int pid = ptid_get_pid (ptid);
int request;
static uint64_t xcr0;
/* GNU/Linux LWP ID's are process ID's. */
- tid = TIDGET (inferior_ptid);
+ tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
#ifdef HAVE_PTRACE_GETFPXREGS
if (have_ptrace_getfpxregs == -1)
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
char xmmregs[512];
if (have_ptrace_xmmregs != 0
- && ptrace(PT_GETXMMREGS, PIDGET (inferior_ptid),
+ && ptrace(PT_GETXMMREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
{
have_ptrace_xmmregs = 1;
}
else
{
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
i387_supply_fsave (regcache, -1, &fpregs);
}
#else
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
i386bsd_collect_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
char xmmregs[512];
if (have_ptrace_xmmregs != 0
- && ptrace(PT_GETXMMREGS, PIDGET (inferior_ptid),
+ && ptrace(PT_GETXMMREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) xmmregs, 0) == 0)
{
have_ptrace_xmmregs = 1;
i387_collect_fxsave (regcache, regnum, xmmregs);
- if (ptrace (PT_SETXMMREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETXMMREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) xmmregs, 0) == -1)
perror_with_name (_("Couldn't write XMM registers"));
}
{
have_ptrace_xmmregs = 0;
#endif
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
i387_collect_fsave (regcache, regnum, &fpregs);
- if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
#ifdef HAVE_PT_GETXMMREGS
{
struct dbreg dbregs;
- if (ptrace (PT_GETDBREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETDBREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
perror_with_name (_("Couldn't read debug registers"));
{
struct dbreg dbregs;
- if (ptrace (PT_GETDBREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETDBREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
perror_with_name (_("Couldn't get debug registers"));
DBREG_DRX ((&dbregs), regnum) = value;
- if (ptrace (PT_SETDBREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETDBREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &dbregs, 0) == -1)
perror_with_name (_("Couldn't write debug registers"));
}
{
int tid;
- tid = TIDGET (ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = PIDGET (ptid);
+ tid = ptid_get_pid (ptid);
(void) ptrace (PT_WRITE_U, tid, (PTRACE_TYPE_ARG3) (PT_DBR + 8 * idx), val);
}
exec_file = (char *) get_exec_file (0);
if (!exec_file)
{
- exec_file = target_pid_to_exec_file (PIDGET (inferior_ptid));
+ exec_file = target_pid_to_exec_file (ptid_get_pid (inferior_ptid));
if (exec_file)
{
/* It's possible we don't have a full path, but rather just a
}
/* Take any necessary post-attaching actions for this platform. */
- target_post_attach (PIDGET (inferior_ptid));
+ target_post_attach (ptid_get_pid (inferior_ptid));
post_create_inferior (¤t_target, from_tty);
extern const char *get_inferior_io_terminal (void);
/* Collected pid, tid, etc. of the debugged inferior. When there's
- no inferior, PIDGET (inferior_ptid) will be 0. */
+ no inferior, ptid_get_pid (inferior_ptid) will be 0. */
extern ptid_t inferior_ptid;
(and the non-threaded child_terminal_init_inferior can just pass in
inferior_ptid to the same routine). */
/* We assume INFERIOR_PID is also the child's process group. */
- terminal_init_inferior_with_pgrp (PIDGET (inferior_ptid));
+ terminal_init_inferior_with_pgrp (ptid_get_pid (inferior_ptid));
#endif /* PROCESS_GROUP_TYPE */
}
pass_signal (int signo)
{
#ifndef _WIN32
- kill (PIDGET (inferior_ptid), SIGINT);
+ kill (ptid_get_pid (inferior_ptid), SIGINT);
#endif
}
is set. */
fprintf_unfiltered (tmp_stream,
- "infrun: target_wait (%d", PIDGET (waiton_ptid));
- if (PIDGET (waiton_ptid) != -1)
+ "infrun: target_wait (%d", ptid_get_pid (waiton_ptid));
+ if (ptid_get_pid (waiton_ptid) != -1)
fprintf_unfiltered (tmp_stream,
" [%s]", target_pid_to_str (waiton_ptid));
fprintf_unfiltered (tmp_stream, ", status) =\n");
fprintf_unfiltered (tmp_stream,
"infrun: %d [%s],\n",
- PIDGET (result_ptid), target_pid_to_str (result_ptid));
+ ptid_get_pid (result_ptid),
+ target_pid_to_str (result_ptid));
fprintf_unfiltered (tmp_stream,
"infrun: %s\n",
status_string);
{
struct fork_info *fp;
- if (fork_list == NULL && pid != PIDGET (inferior_ptid))
+ if (fork_list == NULL && pid != ptid_get_pid (inferior_ptid))
{
/* Special case -- if this is the first fork in the list
(the list is hitherto empty), and if this new fork is
NOT the current inferior_ptid, then add inferior_ptid
first, as a special zeroeth fork id. */
highest_fork_num = -1;
- add_fork (PIDGET (inferior_ptid)); /* safe recursion */
+ add_fork (ptid_get_pid (inferior_ptid)); /* safe recursion */
}
fp = XZALLOC (struct fork_info);
{
/* Now save the 'state' (file position) of all open file descriptors.
Unfortunately fork does not take care of that for us... */
- snprintf (path, PATH_MAX, "/proc/%ld/fd", (long) PIDGET (fp->ptid));
+ snprintf (path, PATH_MAX, "/proc/%ld/fd",
+ (long) ptid_get_pid (fp->ptid));
if ((d = opendir (path)) != NULL)
{
long tmp;
for (fp = fork_list; fp; fp = fp->next)
{
- pid = PIDGET (fp->ptid);
+ pid = ptid_get_pid (fp->ptid);
do {
/* Use SIGKILL instead of PTRACE_KILL because the former works even
if the thread is running, while the later doesn't. */
delete it from the fork_list, and switch to the next available
fork. */
- if (ptrace (PTRACE_DETACH, PIDGET (inferior_ptid), 0, 0))
+ if (ptrace (PTRACE_DETACH, ptid_get_pid (inferior_ptid), 0, 0))
error (_("Unable to detach %s"), target_pid_to_str (inferior_ptid));
delete_fork (inferior_ptid);
error (_("\
Please switch to another checkpoint before deleting the current one"));
- if (ptrace (PTRACE_KILL, PIDGET (ptid), 0, 0))
+ if (ptrace (PTRACE_KILL, ptid_get_pid (ptid), 0, 0))
error (_("Unable to kill pid %s"), target_pid_to_str (ptid));
fi = find_fork_ptid (ptid);
if ((!find_thread_ptid (pptid) && find_fork_ptid (pptid))
|| (find_thread_ptid (pptid) && is_stopped (pptid)))
{
- if (inferior_call_waitpid (pptid, PIDGET (ptid)))
+ if (inferior_call_waitpid (pptid, ptid_get_pid (ptid)))
warning (_("Unable to wait pid %s"), target_pid_to_str (ptid));
}
}
error (_("\
Please switch to another checkpoint before detaching the current one"));
- if (ptrace (PTRACE_DETACH, PIDGET (ptid), 0, 0))
+ if (ptrace (PTRACE_DETACH, ptid_get_pid (ptid), 0, 0))
error (_("Unable to detach %s"), target_pid_to_str (ptid));
if (from_tty)
/* Tell linux-nat.c that we're checkpointing this inferior. */
old_chain = make_cleanup_restore_integer (&checkpointing_pid);
- checkpointing_pid = PIDGET (inferior_ptid);
+ checkpointing_pid = ptid_get_pid (inferior_ptid);
ret = call_function_by_hand (fork_fn, 0, &ret);
do_cleanups (old_chain);
parent_pid = ptid_get_lwp (inferior_ptid);
if (parent_pid == 0)
parent_pid = ptid_get_pid (inferior_ptid);
- child_pid = PIDGET (inferior_thread ()->pending_follow.value.related_pid);
+ child_pid
+ = ptid_get_pid (inferior_thread ()->pending_follow.value.related_pid);
if (has_vforked
&& !non_stop /* Non-stop always resumes both branches. */
if (has_vforked)
{
/* keep breakpoints list in sync. */
- remove_breakpoints_pid (GET_PID (inferior_ptid));
+ remove_breakpoints_pid (ptid_get_pid (inferior_ptid));
}
if (info_verbose || debug_linux_nat)
{
struct lwp_info *lp;
- gdb_assert (is_lwp (ptid));
+ gdb_assert (ptid_lwp_p (ptid));
lp = (struct lwp_info *) xmalloc (sizeof (struct lwp_info));
struct lwp_info *lp;
int lwp;
- if (is_lwp (ptid))
- lwp = GET_LWP (ptid);
+ if (ptid_lwp_p (ptid))
+ lwp = ptid_get_lwp (ptid);
else
- lwp = GET_PID (ptid);
+ lwp = ptid_get_pid (ptid);
for (lp = lwp_list; lp; lp = lp->next)
- if (lwp == GET_LWP (lp->ptid))
+ if (lwp == ptid_get_lwp (lp->ptid))
return lp;
return NULL;
{
struct lwp_info *lp;
- purge_lwp_list (GET_PID (inferior_ptid));
+ purge_lwp_list (ptid_get_pid (inferior_ptid));
lp = add_lwp (new_ptid);
lp->stopped = 1;
linux_nat_post_attach_wait (ptid_t ptid, int first, int *cloned,
int *signalled)
{
- pid_t new_pid, pid = GET_LWP (ptid);
+ pid_t new_pid, pid = ptid_get_lwp (ptid);
int status;
if (linux_proc_pid_is_stopped (pid))
struct lwp_info *lp;
int lwpid;
- gdb_assert (is_lwp (ptid));
+ gdb_assert (ptid_lwp_p (ptid));
lp = find_lwp_pid (ptid);
- lwpid = GET_LWP (ptid);
+ lwpid = ptid_get_lwp (ptid);
/* We assume that we're already attached to any LWP that has an id
equal to the overall process id, and to any LWP that is already
and we've had PID wraparound since we last tried to stop all threads,
this assumption might be wrong; fortunately, this is very unlikely
to happen. */
- if (lwpid != GET_PID (ptid) && lp == NULL)
+ if (lwpid != ptid_get_pid (ptid) && lp == NULL)
{
int status, cloned = 0, signalled = 0;
lp->status = status;
}
- target_post_attach (GET_LWP (lp->ptid));
+ target_post_attach (ptid_get_lwp (lp->ptid));
if (debug_linux_nat)
{
/* The ptrace base target adds the main thread with (pid,0,0)
format. Decorate it with lwp info. */
- ptid = BUILD_LWP (GET_PID (inferior_ptid), GET_PID (inferior_ptid));
+ ptid = ptid_build (ptid_get_pid (inferior_ptid),
+ ptid_get_pid (inferior_ptid),
+ 0);
thread_change_ptid (inferior_ptid, ptid);
/* Add the initial process as the first LWP to the list. */
internal_error (__FILE__, __LINE__,
_("unexpected status %d for PID %ld"),
- status, (long) GET_LWP (ptid));
+ status, (long) ptid_get_lwp (ptid));
}
lp->stopped = 1;
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
"LNA: waitpid %ld, saving status %s\n",
- (long) GET_PID (lp->ptid), status_to_str (status));
+ (long) ptid_get_pid (lp->ptid), status_to_str (status));
lp->status = status;
get_last_target_status (&last_ptid, &last);
- if (GET_LWP (lp->ptid) == GET_LWP (last_ptid))
+ if (ptid_get_lwp (lp->ptid) == ptid_get_lwp (last_ptid))
{
struct thread_info *tp = find_thread_ptid (lp->ptid);
"DC: Sending SIGCONT to %s\n",
target_pid_to_str (lp->ptid));
- kill_lwp (GET_LWP (lp->ptid), SIGCONT);
+ kill_lwp (ptid_get_lwp (lp->ptid), SIGCONT);
lp->signalled = 0;
}
/* We don't actually detach from the LWP that has an id equal to the
overall process id just yet. */
- if (GET_LWP (lp->ptid) != GET_PID (lp->ptid))
+ if (ptid_get_lwp (lp->ptid) != ptid_get_pid (lp->ptid))
{
int status = 0;
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (lp);
errno = 0;
- if (ptrace (PTRACE_DETACH, GET_LWP (lp->ptid), 0,
+ if (ptrace (PTRACE_DETACH, ptid_get_lwp (lp->ptid), 0,
WSTOPSIG (status)) < 0)
error (_("Can't detach %s: %s"), target_pid_to_str (lp->ptid),
safe_strerror (errno));
int status;
struct lwp_info *main_lwp;
- pid = GET_PID (inferior_ptid);
+ pid = ptid_get_pid (inferior_ptid);
/* Don't unregister from the event loop, as there may be other
inferiors running. */
iterate_over_lwps (pid_to_ptid (pid), detach_callback, NULL);
/* Only the initial process should be left right now. */
- gdb_assert (num_lwps (GET_PID (inferior_ptid)) == 1);
+ gdb_assert (num_lwps (ptid_get_pid (inferior_ptid)) == 1);
main_lwp = find_lwp_pid (pid_to_ptid (pid));
{
if (lp->stopped)
{
- struct inferior *inf = find_inferior_pid (GET_PID (lp->ptid));
+ struct inferior *inf = find_inferior_pid (ptid_get_pid (lp->ptid));
if (inf->vfork_child != NULL)
{
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (lp);
linux_ops->to_resume (linux_ops,
- pid_to_ptid (GET_LWP (lp->ptid)),
+ pid_to_ptid (ptid_get_lwp (lp->ptid)),
step, signo);
lp->stopped = 0;
lp->step = step;
iterate_over_lwps (ptid, linux_nat_resume_callback, NULL);
/* Convert to something the lower layer understands. */
- ptid = pid_to_ptid (GET_LWP (lp->ptid));
+ ptid = pid_to_ptid (ptid_get_lwp (lp->ptid));
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (lp);
"for LWP %ld (stopping threads), "
"resuming with PTRACE_CONT for SIGSTOP\n",
syscall_number,
- GET_LWP (lp->ptid));
+ ptid_get_lwp (lp->ptid));
lp->syscall_state = TARGET_WAITKIND_IGNORE;
- ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0, 0);
+ ptrace (PTRACE_CONT, ptid_get_lwp (lp->ptid), 0, 0);
return 1;
}
== TARGET_WAITKIND_SYSCALL_ENTRY
? "entry" : "return",
syscall_number,
- GET_LWP (lp->ptid));
+ ptid_get_lwp (lp->ptid));
return 0;
}
lp->syscall_state == TARGET_WAITKIND_SYSCALL_ENTRY
? "entry" : "return",
syscall_number,
- GET_LWP (lp->ptid));
+ ptid_get_lwp (lp->ptid));
}
else
{
"with no syscall catchpoints."
" %d for LWP %ld, ignoring\n",
syscall_number,
- GET_LWP (lp->ptid));
+ ptid_get_lwp (lp->ptid));
lp->syscall_state = TARGET_WAITKIND_IGNORE;
}
registers_changed ();
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (lp);
- linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)),
+ linux_ops->to_resume (linux_ops, pid_to_ptid (ptid_get_lwp (lp->ptid)),
lp->step, GDB_SIGNAL_0);
return 1;
}
linux_handle_extended_wait (struct lwp_info *lp, int status,
int stopping)
{
- int pid = GET_LWP (lp->ptid);
+ int pid = ptid_get_lwp (lp->ptid);
struct target_waitstatus *ourstatus = &lp->waitstatus;
int event = status >> 16;
}
if (event == PTRACE_EVENT_FORK
- && linux_fork_checkpointing_p (GET_PID (lp->ptid)))
+ && linux_fork_checkpointing_p (ptid_get_pid (lp->ptid)))
{
/* Handle checkpointing by linux-fork.c here as a special
case. We don't want the follow-fork-mode or 'catch fork'
"from LWP %d, new child is LWP %ld\n",
pid, new_pid);
- new_lp = add_lwp (BUILD_LWP (new_pid, GET_PID (lp->ptid)));
+ new_lp = add_lwp (ptid_build (ptid_get_pid (lp->ptid), new_pid, 0));
new_lp->cloned = 1;
new_lp->stopped = 1;
{
/* We're not using thread_db. Add it to GDB's
list. */
- target_post_attach (GET_LWP (new_lp->ptid));
+ target_post_attach (ptid_get_lwp (new_lp->ptid));
add_thread (new_lp->ptid);
}
fprintf_unfiltered (gdb_stdlog,
"LHEW: waitpid of new LWP %ld, "
"saving status %s\n",
- (long) GET_LWP (new_lp->ptid),
+ (long) ptid_get_lwp (new_lp->ptid),
status_to_str (status));
new_lp->status = status;
}
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
"LHEW: resuming new LWP %ld\n",
- GET_LWP (new_lp->ptid));
+ ptid_get_lwp (new_lp->ptid));
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (new_lp);
linux_ops->to_resume (linux_ops, pid_to_ptid (new_pid),
"LHEW: resuming parent LWP %d\n", pid);
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (lp);
- linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)),
+ linux_ops->to_resume (linux_ops,
+ pid_to_ptid (ptid_get_lwp (lp->ptid)),
0, GDB_SIGNAL_0);
return 1;
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
"LHEW: Got exec event from LWP %ld\n",
- GET_LWP (lp->ptid));
+ ptid_get_lwp (lp->ptid));
ourstatus->kind = TARGET_WAITKIND_EXECD;
ourstatus->value.execd_pathname
fprintf_unfiltered (gdb_stdlog,
"LHEW: Got expected PTRACE_EVENT_"
"VFORK_DONE from LWP %ld: stopping\n",
- GET_LWP (lp->ptid));
+ ptid_get_lwp (lp->ptid));
ourstatus->kind = TARGET_WAITKIND_VFORK_DONE;
return 0;
fprintf_unfiltered (gdb_stdlog,
"LHEW: Got PTRACE_EVENT_VFORK_DONE "
"from LWP %ld: resuming\n",
- GET_LWP (lp->ptid));
- ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0, 0);
+ ptid_get_lwp (lp->ptid));
+ ptrace (PTRACE_CONT, ptid_get_lwp (lp->ptid), 0, 0);
return 1;
}
/* If my_waitpid returns 0 it means the __WCLONE vs. non-__WCLONE kind
was right and we should just call sigsuspend. */
- pid = my_waitpid (GET_LWP (lp->ptid), &status, WNOHANG);
+ pid = my_waitpid (ptid_get_lwp (lp->ptid), &status, WNOHANG);
if (pid == -1 && errno == ECHILD)
- pid = my_waitpid (GET_LWP (lp->ptid), &status, __WCLONE | WNOHANG);
+ pid = my_waitpid (ptid_get_lwp (lp->ptid), &status, __WCLONE | WNOHANG);
if (pid == -1 && errno == ECHILD)
{
/* The thread has previously exited. We need to delete it
Therefore always use WNOHANG with sigsuspend - it is equivalent to
waiting waitpid but linux_proc_pid_is_zombie is safe this way. */
- if (GET_PID (lp->ptid) == GET_LWP (lp->ptid)
- && linux_proc_pid_is_zombie (GET_LWP (lp->ptid)))
+ if (ptid_get_pid (lp->ptid) == ptid_get_lwp (lp->ptid)
+ && linux_proc_pid_is_zombie (ptid_get_lwp (lp->ptid)))
{
thread_dead = 1;
if (debug_linux_nat)
if (!thread_dead)
{
- gdb_assert (pid == GET_LWP (lp->ptid));
+ gdb_assert (pid == ptid_get_lwp (lp->ptid));
if (debug_linux_nat)
{
target_pid_to_str (lp->ptid));
}
errno = 0;
- ret = kill_lwp (GET_LWP (lp->ptid), SIGSTOP);
+ ret = kill_lwp (ptid_get_lwp (lp->ptid), SIGSTOP);
if (debug_linux_nat)
{
fprintf_unfiltered (gdb_stdlog,
if (!lp->ignore_sigint)
return;
- if (!linux_nat_has_pending_sigint (GET_LWP (lp->ptid)))
+ if (!linux_nat_has_pending_sigint (ptid_get_lwp (lp->ptid)))
{
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
static int
stop_wait_callback (struct lwp_info *lp, void *data)
{
- struct inferior *inf = find_inferior_pid (GET_PID (lp->ptid));
+ struct inferior *inf = find_inferior_pid (ptid_get_pid (lp->ptid));
/* If this is a vfork parent, bail out, it is not going to report
any SIGSTOP until the vfork is done with. */
lp->ignore_sigint = 0;
errno = 0;
- ptrace (PTRACE_CONT, GET_LWP (lp->ptid), 0, 0);
+ ptrace (PTRACE_CONT, ptid_get_lwp (lp->ptid), 0, 0);
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
"PTRACE_CONT %s, 0, 0 (%s) "
fprintf_unfiltered (gdb_stdlog,
"SARC: core wanted LWP %ld stopped "
"(leaving SIGSTOP pending)\n",
- GET_LWP (lp->ptid));
+ ptid_get_lwp (lp->ptid));
lp->status = W_STOPCODE (SIGSTOP);
}
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
"SARC: re-resuming LWP %ld\n",
- GET_LWP (lp->ptid));
+ ptid_get_lwp (lp->ptid));
resume_lwp (lp, lp->step, GDB_SIGNAL_0);
}
else
fprintf_unfiltered (gdb_stdlog,
"SARC: not re-resuming LWP %ld "
"(has pending)\n",
- GET_LWP (lp->ptid));
+ ptid_get_lwp (lp->ptid));
if (new_pending_p)
*new_pending_p = 1;
}
"LLW: Re-adding thread group leader LWP %d.\n",
lwpid);
- lp = add_lwp (BUILD_LWP (lwpid, lwpid));
+ lp = add_lwp (ptid_build (lwpid, lwpid, 0));
lp->stopped = 1;
lp->resumed = 1;
add_thread (lp->ptid);
/* Check if the thread has exited. */
if ((WIFEXITED (status) || WIFSIGNALED (status))
- && num_lwps (GET_PID (lp->ptid)) > 1)
+ && num_lwps (ptid_get_pid (lp->ptid)) > 1)
{
/* If this is the main thread, we must stop all threads and verify
if they are still alive. This is because in the nptl thread model
should be ignored or whether it means the end of the debugged
application, regardless of which threading model is being
used. */
- if (GET_PID (lp->ptid) == GET_LWP (lp->ptid))
+ if (ptid_get_pid (lp->ptid) == ptid_get_lwp (lp->ptid))
{
lp->stopped = 1;
- iterate_over_lwps (pid_to_ptid (GET_PID (lp->ptid)),
+ iterate_over_lwps (pid_to_ptid (ptid_get_pid (lp->ptid)),
stop_and_resume_callback, new_pending_p);
}
"LLW: %s exited.\n",
target_pid_to_str (lp->ptid));
- if (num_lwps (GET_PID (lp->ptid)) > 1)
+ if (num_lwps (ptid_get_pid (lp->ptid)) > 1)
{
/* If there is at least one more LWP, then the exit signal
was not the end of the debugged application and should be
thread model, LWPs other than the main thread do not issue
signals when they exit so we must check whenever the thread has
stopped. A similar check is made in stop_wait_callback(). */
- if (num_lwps (GET_PID (lp->ptid)) > 1 && !linux_thread_alive (lp->ptid))
+ if (num_lwps (ptid_get_pid (lp->ptid)) > 1 && !linux_thread_alive (lp->ptid))
{
- ptid_t ptid = pid_to_ptid (GET_PID (lp->ptid));
+ ptid_t ptid = pid_to_ptid (ptid_get_pid (lp->ptid));
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (lp);
- linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)),
- lp->step, GDB_SIGNAL_0);
+ linux_ops->to_resume (linux_ops,
+ pid_to_ptid (ptid_get_lwp (lp->ptid)),
+ lp->step, GDB_SIGNAL_0);
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
"LLW: %s %s, 0, 0 (discard SIGSTOP)\n",
registers_changed ();
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (lp);
- linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)),
+ linux_ops->to_resume (linux_ops, pid_to_ptid (ptid_get_lwp (lp->ptid)),
lp->step, GDB_SIGNAL_0);
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
{
/* Upgrade the main thread's ptid. */
thread_change_ptid (inferior_ptid,
- BUILD_LWP (GET_PID (inferior_ptid),
- GET_PID (inferior_ptid)));
+ ptid_build (ptid_get_pid (inferior_ptid),
+ ptid_get_pid (inferior_ptid), 0));
lp = add_initial_lwp (inferior_ptid);
lp->resumed = 1;
target_pid_to_str (lp->ptid));
}
}
- else if (is_lwp (ptid))
+ else if (ptid_lwp_p (ptid))
{
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
registers_changed ();
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (lp);
- linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)),
+ linux_ops->to_resume (linux_ops,
+ pid_to_ptid (ptid_get_lwp (lp->ptid)),
lp->step, signo);
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
registers_changed ();
if (linux_nat_prepare_to_resume != NULL)
linux_nat_prepare_to_resume (lp);
- linux_ops->to_resume (linux_ops, pid_to_ptid (GET_LWP (lp->ptid)),
+ linux_ops->to_resume (linux_ops, pid_to_ptid (ptid_get_lwp (lp->ptid)),
lp->step, GDB_SIGNAL_0);
lp->stopped = 0;
lp->stopped_by_watchpoint = 0;
/* PTRACE_KILL may resume the inferior. Send SIGKILL first. */
errno = 0;
- kill (GET_LWP (lp->ptid), SIGKILL);
+ kill (ptid_get_lwp (lp->ptid), SIGKILL);
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
"KC: kill (SIGKILL) %s, 0, 0 (%s)\n",
/* Some kernels ignore even SIGKILL for processes under ptrace. */
errno = 0;
- ptrace (PTRACE_KILL, GET_LWP (lp->ptid), 0, 0);
+ ptrace (PTRACE_KILL, ptid_get_lwp (lp->ptid), 0, 0);
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
"KC: PTRACE_KILL %s, 0, 0 (%s)\n",
{
do
{
- pid = my_waitpid (GET_LWP (lp->ptid), NULL, __WCLONE);
+ pid = my_waitpid (ptid_get_lwp (lp->ptid), NULL, __WCLONE);
if (pid != (pid_t) -1)
{
if (debug_linux_nat)
kill_callback (lp, NULL);
}
}
- while (pid == GET_LWP (lp->ptid));
+ while (pid == ptid_get_lwp (lp->ptid));
gdb_assert (pid == -1 && errno == ECHILD);
}
do
{
- pid = my_waitpid (GET_LWP (lp->ptid), NULL, 0);
+ pid = my_waitpid (ptid_get_lwp (lp->ptid), NULL, 0);
if (pid != (pid_t) -1)
{
if (debug_linux_nat)
kill_callback (lp, NULL);
}
}
- while (pid == GET_LWP (lp->ptid));
+ while (pid == ptid_get_lwp (lp->ptid));
gdb_assert (pid == -1 && errno == ECHILD);
return 0;
if (last.kind == TARGET_WAITKIND_FORKED
|| last.kind == TARGET_WAITKIND_VFORKED)
{
- ptrace (PT_KILL, PIDGET (last.value.related_pid), 0, 0);
+ ptrace (PT_KILL, ptid_get_pid (last.value.related_pid), 0, 0);
wait (&status);
/* Let the arch-specific native code know this process is
gone. */
- linux_nat_forget_process (PIDGET (last.value.related_pid));
+ linux_nat_forget_process (ptid_get_pid (last.value.related_pid));
}
if (forks_exist_p ())
gdb_assert (object == TARGET_OBJECT_SIGNAL_INFO);
gdb_assert (readbuf || writebuf);
- pid = GET_LWP (inferior_ptid);
+ pid = ptid_get_lwp (inferior_ptid);
if (pid == 0)
- pid = GET_PID (inferior_ptid);
+ pid = ptid_get_pid (inferior_ptid);
if (offset > sizeof (siginfo))
return -1;
old_chain = save_inferior_ptid ();
- if (is_lwp (inferior_ptid))
- inferior_ptid = pid_to_ptid (GET_LWP (inferior_ptid));
+ if (ptid_lwp_p (inferior_ptid))
+ inferior_ptid = pid_to_ptid (ptid_get_lwp (inferior_ptid));
xfer = linux_ops->to_xfer_partial (ops, object, annex, readbuf, writebuf,
offset, len);
{
int err, tmp_errno;
- gdb_assert (is_lwp (ptid));
+ gdb_assert (ptid_lwp_p (ptid));
/* Send signal 0 instead of anything ptrace, because ptracing a
running thread errors out claiming that the thread doesn't
exist. */
- err = kill_lwp (GET_LWP (ptid), 0);
+ err = kill_lwp (ptid_get_lwp (ptid), 0);
tmp_errno = errno;
if (debug_linux_nat)
fprintf_unfiltered (gdb_stdlog,
{
static char buf[64];
- if (is_lwp (ptid)
- && (GET_PID (ptid) != GET_LWP (ptid)
- || num_lwps (GET_PID (ptid)) > 1))
+ if (ptid_lwp_p (ptid)
+ && (ptid_get_pid (ptid) != ptid_get_lwp (ptid)
+ || num_lwps (ptid_get_pid (ptid)) > 1))
{
- snprintf (buf, sizeof (buf), "LWP %ld", GET_LWP (ptid));
+ snprintf (buf, sizeof (buf), "LWP %ld", ptid_get_lwp (ptid));
return buf;
}
/* We could keep this file open and cache it - possibly one per
thread. That requires some juggling, but is even faster. */
- sprintf (filename, "/proc/%d/mem", PIDGET (inferior_ptid));
+ sprintf (filename, "/proc/%d/mem", ptid_get_pid (inferior_ptid));
fd = gdb_open_cloexec (filename, O_RDONLY | O_LARGEFILE, 0);
if (fd == -1)
return 0;
char buf[128];
int fd = 0;
int ret = -1;
- int pid = PIDGET (inferior_ptid);
+ int pid = ptid_get_pid (inferior_ptid);
if (!annex)
{
struct inferior *inf;
int pid;
- pid = GET_LWP (ptid);
- if (GET_LWP (ptid) == 0)
+ pid = ptid_get_lwp (ptid);
+ if (ptid_get_lwp (ptid) == 0)
{
/* An (lwpid,0,0) ptid. Look up the lwp object to get at the
tgid. */
lwp = find_lwp_pid (ptid);
- pid = GET_PID (lwp->ptid);
+ pid = ptid_get_pid (lwp->ptid);
}
else
{
/* A (pid,lwpid,0) ptid. */
- pid = GET_PID (ptid);
+ pid = ptid_get_pid (ptid);
}
inf = find_inferior_pid (pid);
{
int pid;
- pid = GET_LWP (ptid);
+ pid = ptid_get_lwp (ptid);
if (pid == 0)
- pid = GET_PID (ptid);
+ pid = ptid_get_pid (ptid);
errno = 0;
ptrace (PTRACE_GETSIGINFO, pid, (PTRACE_TYPE_ARG3) 0, siginfo);
(LP) != NULL; \
(LP) = (LP)->next)
-#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)
-
/* Attempt to initialize libthread_db. */
void check_for_thread_db (void);
/* This ptid comes from linux-nat.c, which should always fill in the
LWP. */
- gdb_assert (GET_LWP (ptid) != 0);
+ gdb_assert (ptid_get_lwp (ptid) != 0);
- info = get_thread_db_info (GET_PID (ptid));
+ info = get_thread_db_info (ptid_get_pid (ptid));
/* Access an lwp we know is stopped. */
info->proc_handle.ptid = ptid;
- err = info->td_ta_map_lwp2thr_p (info->thread_agent, GET_LWP (ptid), &th);
+ err = info->td_ta_map_lwp2thr_p (info->thread_agent, ptid_get_lwp (ptid),
+ &th);
if (err != TD_OK)
error (_("Cannot find user-level thread for LWP %ld: %s"),
- GET_LWP (ptid), thread_db_err_str (err));
+ ptid_get_lwp (ptid), thread_db_err_str (err));
/* Long-winded way of fetching the thread info. */
io.thread_db_info = info;
td_err_e err;
struct thread_db_info *info;
- info = get_thread_db_info (GET_PID (ptid));
+ info = get_thread_db_info (ptid_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);
+ gdb_assert (ptid_get_lwp (ptid) != 0);
/* Access an lwp we know is stopped. */
info->proc_handle.ptid = ptid;
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);
+ err = info->td_ta_map_lwp2thr_p (info->thread_agent, ptid_get_lwp (ptid),
+ &th);
if (err != TD_OK)
/* Cannot find user-level thread. */
return 0;
td_err_e err;
struct thread_db_info *info;
- info = get_thread_db_info (GET_PID (inferior_ptid));
+ info = get_thread_db_info (ptid_get_pid (inferior_ptid));
/* Access an lwp we know is stopped. */
info->proc_handle.ptid = inferior_ptid;
td_err_e err;
struct thread_db_info *info;
- info = get_thread_db_info (GET_PID (inferior_ptid));
+ info = get_thread_db_info (ptid_get_pid (inferior_ptid));
/* We cannot use the thread event reporting facility if these
functions aren't available. */
return 1;
/* This library "refused" to work on current inferior. */
- delete_thread_db_info (GET_PID (inferior_ptid));
+ delete_thread_db_info (ptid_get_pid (inferior_ptid));
return 0;
}
{
struct thread_db_info *info;
- info = get_thread_db_info (GET_PID (inferior_ptid));
+ info = get_thread_db_info (ptid_get_pid (inferior_ptid));
if (info != NULL)
return 1;
{
int res;
- res = lin_lwp_attach_lwp (BUILD_LWP (ti_p->ti_lid, GET_PID (ptid)));
+ res = lin_lwp_attach_lwp (ptid_build (ptid_get_pid (ptid),
+ ti_p->ti_lid, 0));
if (res < 0)
{
/* Error, stop iterating. */
else
tp->private = private;
- info = get_thread_db_info (GET_PID (ptid));
+ info = get_thread_db_info (ptid_get_pid (ptid));
/* Enable thread event reporting for this thread, except when
debugging a core file. */
struct target_ops *target_beneath = find_target_beneath (ops);
struct thread_db_info *info;
- info = get_thread_db_info (GET_PID (inferior_ptid));
+ info = get_thread_db_info (ptid_get_pid (inferior_ptid));
if (info)
{
remove_thread_event_breakpoints ();
}
- delete_thread_db_info (GET_PID (inferior_ptid));
+ delete_thread_db_info (ptid_get_pid (inferior_ptid));
}
target_beneath->to_detach (target_beneath, args, from_tty);
int loop = 0;
struct thread_db_info *info;
- info = get_thread_db_info (GET_PID (ptid));
+ info = get_thread_db_info (ptid_get_pid (ptid));
/* Bail out early if we're not at a thread event breakpoint. */
stop_pc = regcache_read_pc (regcache)
if (err != TD_OK)
error (_("Cannot get thread info: %s"), thread_db_err_str (err));
- ptid = ptid_build (GET_PID (ptid), ti.ti_lid, 0);
+ ptid = ptid_build (ptid_get_pid (ptid), ti.ti_lid, 0);
switch (msg.event)
{
|| ourstatus->kind == TARGET_WAITKIND_SIGNALLED)
return ptid;
- info = get_thread_db_info (GET_PID (ptid));
+ info = get_thread_db_info (ptid_get_pid (ptid));
/* 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 (GET_PID (ptid));
+ delete_thread_db_info (ptid_get_pid (ptid));
if (!thread_db_list)
unpush_target (&thread_db_ops);
{
struct target_ops *target_beneath = find_target_beneath (ops);
- delete_thread_db_info (GET_PID (inferior_ptid));
+ delete_thread_db_info (ptid_get_pid (inferior_ptid));
target_beneath->to_mourn_inferior (target_beneath);
struct thread_db_info *info;
int i, loop;
- info = get_thread_db_info (GET_PID (ptid));
+ info = get_thread_db_info (ptid_get_pid (ptid));
/* Access an lwp we know is stopped. */
info->proc_handle.ptid = ptid;
tid = thread_info->private->tid;
snprintf (buf, sizeof (buf), "Thread 0x%lx (LWP %ld)",
- tid, GET_LWP (ptid));
+ tid, ptid_get_lwp (ptid));
return buf;
}
psaddr_t address;
struct thread_db_info *info;
- info = get_thread_db_info (GET_PID (ptid));
+ info = get_thread_db_info (ptid_get_pid (ptid));
/* glibc doesn't provide the needed interface. */
if (!info->td_thr_tls_get_addr_p)
struct thread_db_info *info;
if (ptid_equal (ptid, minus_one_ptid))
- info = get_thread_db_info (GET_PID (inferior_ptid));
+ info = get_thread_db_info (ptid_get_pid (inferior_ptid));
else
- info = get_thread_db_info (GET_PID (ptid));
+ info = get_thread_db_info (ptid_get_pid (ptid));
/* This workaround is only needed for child fork lwps stopped in a
PTRACE_O_TRACEFORK event. When the inferior is resumed, the
int tid;
/* GNU/Linux LWP ID's are process ID's. */
- tid = TIDGET (inferior_ptid);
+ tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
/* Use the PTRACE_GETREGS request whenever possible, since it
transfers more registers in one system call, and we'll cache the
int tid;
/* GNU/Linux LWP ID's are process ID's. */
- if ((tid = TIDGET (inferior_ptid)) == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ if ((tid = ptid_get_lwp (inferior_ptid)) == 0)
+ tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
/* Use the PTRACE_SETREGS request whenever possible, since it
transfers more registers in one system call. */
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
m68kbsd_collect_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
m68kbsd_collect_fpregset (regcache, &fpregs, regnum);
- if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
int tid;
/* Overload thread id onto process id. */
- tid = TIDGET (inferior_ptid);
+ tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid); /* no thread id, just use
+ tid = ptid_get_pid (inferior_ptid); /* no thread id, just use
process id. */
regaddr = 4 * regmap[regno];
gdb_byte buf[MAX_REGISTER_SIZE];
/* Overload thread id onto process id. */
- tid = TIDGET (inferior_ptid);
+ tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid); /* no thread id, just use
+ tid = ptid_get_pid (inferior_ptid); /* no thread id, just use
process id. */
regaddr = 4 * regmap[regno];
}
/* GNU/Linux LWP ID's are process ID's. */
- tid = TIDGET (inferior_ptid);
+ tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
/* Use the PTRACE_GETFPXREGS request whenever possible, since it
transfers more registers in one system call, and we'll cache the
}
/* GNU/Linux LWP ID's are process ID's. */
- tid = TIDGET (inferior_ptid);
+ tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
/* Use the PTRACE_SETFPREGS requests whenever possible, since it
transfers more registers in one system call. But remember that
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
m88kbsd_collect_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
current_token ? current_token : "");
}
- if (PIDGET (ptid) == -1)
+ if (ptid_get_pid (ptid) == -1)
fprintf_unfiltered (raw_stdout, "*running,thread-id=\"all\"\n");
else if (ptid_is_pid (ptid))
{
if (!is_stopped (thread->ptid))
return;
- if (pid != 0 && PIDGET (thread->ptid) != pid)
+ if (pid != 0 && ptid_get_pid (thread->ptid) != pid)
return;
switch_to_thread (thread->ptid);
if (!is_running (thread->ptid))
return 0;
- if (PIDGET (thread->ptid) != pid)
+ if (ptid_get_pid (thread->ptid) != pid)
return 0;
target_stop (thread->ptid);
{
int pid = *(int *)p;
- if (PIDGET (ti->ptid) == pid && !is_exited (ti->ptid))
+ if (ptid_get_pid (ti->ptid) == pid && !is_exited (ti->ptid))
return 1;
return 0;
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
mips64obsd_collect_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
mipsnbsd_fill_reg (regcache, (char *) ®s, regno);
- if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
mipsnbsd_fill_fpreg (regcache, (char *) &fpregs, regno);
- if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
struct sigevent event;
char path[PATH_MAX];
- snprintf (path, PATH_MAX - 1, "%s/%d/as", nto_procfs_path, PIDGET (ptid));
+ snprintf (path, PATH_MAX - 1, "%s/%d/as", nto_procfs_path,
+ ptid_get_pid (ptid));
ctl_fd = open (path, O_RDWR);
if (ctl_fd == -1)
error (_("Couldn't open proc file %s, error %d (%s)"), path, errno,
if (devctl (ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status), 0) == EOK
&& status.flags & _DEBUG_FLAG_STOPPED)
- SignalKill (nto_node (), PIDGET (ptid), 0, SIGCONT, 0, 0);
+ SignalKill (nto_node (), ptid_get_pid (ptid), 0, SIGCONT, 0, 0);
nto_init_solib_absolute_prefix ();
- return ptid_build (PIDGET (ptid), 0, status.tid);
+ return ptid_build (ptid_get_pid (ptid), 0, status.tid);
}
/* Ask the user what to do when an interrupt is received. */
{
int waitval = 0;
- waitpid (PIDGET (inferior_ptid), &waitval, WNOHANG);
+ waitpid (ptid_get_pid (inferior_ptid), &waitval, WNOHANG);
if (exit_signo)
{
/* Abnormal death. */
siggnal = atoi (args);
if (siggnal)
- SignalKill (nto_node (), PIDGET (inferior_ptid), 0, siggnal, 0, 0);
+ SignalKill (nto_node (), ptid_get_pid (inferior_ptid), 0, siggnal, 0, 0);
close (ctl_fd);
ctl_fd = -1;
{
if (signal_to_pass != status.info.si_signo)
{
- SignalKill (nto_node (), PIDGET (inferior_ptid), 0,
+ SignalKill (nto_node (), ptid_get_pid (inferior_ptid), 0,
signal_to_pass, 0, 0);
run.flags |= _DEBUG_RUN_CLRFLT | _DEBUG_RUN_CLRSIG;
}
{
if (!ptid_equal (inferior_ptid, null_ptid))
{
- SignalKill (nto_node (), PIDGET (inferior_ptid), 0, SIGKILL, 0, 0);
+ SignalKill (nto_node (), ptid_get_pid (inferior_ptid), 0, SIGKILL, 0, 0);
close (ctl_fd);
}
inferior_ptid = null_ptid;
struct regcache *regcache, int regno)
{
/* Overload thread id onto process id. */
- int tid = TIDGET (inferior_ptid);
+ int tid = ptid_get_lwp (inferior_ptid);
/* No thread id, just use process id. */
if (tid == 0)
- tid = PIDGET (inferior_ptid);
+ tid = ptid_get_pid (inferior_ptid);
if (regno == -1)
fetch_ppc_registers (regcache, tid);
{
int tid;
- tid = TIDGET (inferior_ptid);
+ tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid);
+ tid = ptid_get_pid (inferior_ptid);
/* Check for kernel support for PowerPC HWDEBUG ptrace interface. */
if (ptrace (PPC_PTRACE_GETHWDBGINFO, tid, 0, &hwdebug_info) >= 0)
/* We need to know whether ptrace supports PTRACE_SET_DEBUGREG
and whether the target has DABR. If either answer is no, the
ptrace call will return -1. Fail in that case. */
- tid = TIDGET (ptid);
+ tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = PIDGET (ptid);
+ tid = ptid_get_pid (ptid);
if (ptrace (PTRACE_SET_DEBUGREG, tid, 0, 0) == -1)
return 0;
}
ALL_LWPS (lp)
- hwdebug_insert_point (&p, TIDGET (lp->ptid));
+ hwdebug_insert_point (&p, ptid_get_lwp (lp->ptid));
return 0;
}
}
ALL_LWPS (lp)
- hwdebug_remove_point (&p, TIDGET (lp->ptid));
+ hwdebug_remove_point (&p, ptid_get_lwp (lp->ptid));
return 0;
}
p.condition_value = 0;
ALL_LWPS (lp)
- hwdebug_insert_point (&p, TIDGET (lp->ptid));
+ hwdebug_insert_point (&p, ptid_get_lwp (lp->ptid));
return 0;
}
p.condition_value = 0;
ALL_LWPS (lp)
- hwdebug_remove_point (&p, TIDGET (lp->ptid));
+ hwdebug_remove_point (&p, ptid_get_lwp (lp->ptid));
return 0;
}
can_use_watchpoint_cond_accel (void)
{
struct thread_points *p;
- int tid = TIDGET (inferior_ptid);
+ int tid = ptid_get_lwp (inferior_ptid);
int cnt = hwdebug_info.num_condition_regs, i;
CORE_ADDR tmp_value;
create_watchpoint_request (&p, addr, len, rw, cond, 1);
ALL_LWPS (lp)
- hwdebug_insert_point (&p, TIDGET (lp->ptid));
+ hwdebug_insert_point (&p, ptid_get_lwp (lp->ptid));
ret = 0;
}
saved_dabr_value = dabr_value;
ALL_LWPS (lp)
- if (ptrace (PTRACE_SET_DEBUGREG, TIDGET (lp->ptid), 0,
+ if (ptrace (PTRACE_SET_DEBUGREG, ptid_get_lwp (lp->ptid), 0,
saved_dabr_value) < 0)
return -1;
create_watchpoint_request (&p, addr, len, rw, cond, 0);
ALL_LWPS (lp)
- hwdebug_remove_point (&p, TIDGET (lp->ptid));
+ hwdebug_remove_point (&p, ptid_get_lwp (lp->ptid));
ret = 0;
}
{
saved_dabr_value = 0;
ALL_LWPS (lp)
- if (ptrace (PTRACE_SET_DEBUGREG, TIDGET (lp->ptid), 0,
+ if (ptrace (PTRACE_SET_DEBUGREG, ptid_get_lwp (lp->ptid), 0,
saved_dabr_value) < 0)
return -1;
static void
ppc_linux_new_thread (struct lwp_info *lp)
{
- int tid = TIDGET (lp->ptid);
+ int tid = ptid_get_lwp (lp->ptid);
if (have_ptrace_hwdebug_interface ())
{
ppc_linux_thread_exit (struct thread_info *tp, int silent)
{
int i;
- int tid = TIDGET (tp->ptid);
+ int tid = ptid_get_lwp (tp->ptid);
struct hw_break_tuple *hw_breaks;
struct thread_points *t = NULL, *p;
/* The index (or slot) of the *point is passed in the si_errno field. */
int slot = siginfo.si_errno;
- t = hwdebug_find_thread_points_by_tid (TIDGET (inferior_ptid), 0);
+ t = hwdebug_find_thread_points_by_tid (ptid_get_lwp (inferior_ptid), 0);
/* Find out if this *point is a hardware breakpoint.
If so, we should return 0. */
struct regcache *regcache, int regno)
{
/* Overload thread id onto process id. */
- int tid = TIDGET (inferior_ptid);
+ int tid = ptid_get_lwp (inferior_ptid);
/* No thread id, just use process id. */
if (tid == 0)
- tid = PIDGET (inferior_ptid);
+ tid = ptid_get_pid (inferior_ptid);
if (regno >= 0)
store_register (regcache, tid, regno);
#ifdef __powerpc64__
long msr;
- int tid = TIDGET (inferior_ptid);
+ int tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid);
+ tid = ptid_get_pid (inferior_ptid);
errno = 0;
msr = (long) ptrace (PTRACE_PEEKUSER, tid, PT_MSR * 8, 0);
int isa205 = 0;
int cell = 0;
- int tid = TIDGET (inferior_ptid);
+ int tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid);
+ tid = ptid_get_pid (inferior_ptid);
if (have_ptrace_getsetevrregs)
{
{
gdb_gregset_t regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
const struct regset *fpregset = ppc_fbsd_fpregset ();
gdb_fpregset_t fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get FP registers"));
{
gdb_gregset_t regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
fill_gregset (regcache, ®s, regno);
- if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
{
gdb_fpregset_t fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get FP registers"));
fill_fpregset (regcache, &fpregs, regno);
- if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't set FP registers"));
}
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get FP registers"));
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
ppc_collect_gregset (&ppcnbsd_gregset, regcache,
regnum, ®s, sizeof regs);
- if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get FP registers"));
ppc_collect_fpregset (&ppcnbsd_fpregset, regcache,
regnum, &fpregs, sizeof fpregs);
- if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't set FP registers"));
}
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
regnum, ®s, sizeof regs);
#endif
- if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
{
struct fpreg fpregs;
- if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't get floating point status"));
ppc_collect_fpregset (&ppcobsd_fpregset, regcache,
regnum, &fpregs, sizeof fpregs);
- if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETFPREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &fpregs, 0) == -1)
perror_with_name (_("Couldn't write floating point status"));
}
#endif
\f
-/* Building process ids. */
-
-#define BUILD_LWP(lwp, pid) ptid_build (pid, lwp, 0)
-\f
-
/* Helper functions. */
/* Convert a psaddr_t to a CORE_ADDR. */
struct cleanup *old_chain = save_inferior_ptid ();
struct regcache *regcache;
- inferior_ptid = BUILD_LWP (lwpid, ptid_get_pid (ph->ptid));
+ inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
target_fetch_registers (regcache, -1);
struct cleanup *old_chain = save_inferior_ptid ();
struct regcache *regcache;
- inferior_ptid = BUILD_LWP (lwpid, ptid_get_pid (ph->ptid));
+ inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
supply_gregset (regcache, (const gdb_gregset_t *) gregset);
struct cleanup *old_chain = save_inferior_ptid ();
struct regcache *regcache;
- inferior_ptid = BUILD_LWP (lwpid, ptid_get_pid (ph->ptid));
+ inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
target_fetch_registers (regcache, -1);
struct cleanup *old_chain = save_inferior_ptid ();
struct regcache *regcache;
- inferior_ptid = BUILD_LWP (lwpid, ptid_get_pid (ph->ptid));
+ inferior_ptid = ptid_build (ptid_get_pid (ph->ptid), lwpid, 0);
regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset);
procinfo *pi;
/* Find procinfo for the lwp. */
- if ((pi = find_procinfo (PIDGET (ptid), TIDGET (ptid))) == NULL)
+ if ((pi = find_procinfo (ptid_get_pid (ptid), ptid_get_lwp (ptid))) == NULL)
{
warning (_("procfs_find_LDT_entry: could not find procinfo for %d:%ld."),
- PIDGET (ptid), TIDGET (ptid));
+ ptid_get_pid (ptid), ptid_get_lwp (ptid));
return NULL;
}
/* get its general registers. */
if ((gregs = proc_get_gregs (pi)) == NULL)
{
warning (_("procfs_find_LDT_entry: could not read gregs for %d:%ld."),
- PIDGET (ptid), TIDGET (ptid));
+ ptid_get_pid (ptid), ptid_get_lwp (ptid));
return NULL;
}
/* Now extract the GS register's lower 16 bits. */
procfs_detach (struct target_ops *ops, char *args, int from_tty)
{
int sig = 0;
- int pid = PIDGET (inferior_ptid);
+ int pid = ptid_get_pid (inferior_ptid);
if (args)
sig = atoi (args);
int fail;
int lwpid;
- if ((pi = create_procinfo (PIDGET (ptid), 0)) == NULL)
+ if ((pi = create_procinfo (ptid_get_pid (ptid), 0)) == NULL)
perror (_("procfs: out of memory in 'attach'"));
if (!open_procinfo_files (pi, FD_CTL))
{
fprintf_filtered (gdb_stderr, "procfs:%d -- ", __LINE__);
sprintf (errmsg, "do_attach: couldn't open /proc file for process %d",
- PIDGET (ptid));
+ ptid_get_pid (ptid));
dead_procinfo (pi, errmsg, NOKILL);
}
create_procinfo (pi->pid, lwpid);
/* Add it to gdb's thread list. */
- ptid = MERGEPID (pi->pid, lwpid);
+ ptid = ptid_build (pi->pid, lwpid, 0);
add_thread (ptid);
return ptid;
procinfo *pi;
/* Find procinfo for the main process. */
- pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0); /* FIXME: threads */
+ pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid),
+ 0); /* FIXME: threads */
if (signo)
if (!proc_set_current_signal (pi, signo))
proc_warn (pi, "do_detach, set_current_signal", __LINE__);
{
gdb_gregset_t *gregs;
procinfo *pi;
- int pid = PIDGET (inferior_ptid);
- int tid = TIDGET (inferior_ptid);
+ int pid = ptid_get_pid (inferior_ptid);
+ int tid = ptid_get_lwp (inferior_ptid);
struct gdbarch *gdbarch = get_regcache_arch (regcache);
pi = find_procinfo_or_die (pid, tid);
{
gdb_gregset_t *gregs;
procinfo *pi;
- int pid = PIDGET (inferior_ptid);
- int tid = TIDGET (inferior_ptid);
+ int pid = ptid_get_pid (inferior_ptid);
+ int tid = ptid_get_lwp (inferior_ptid);
struct gdbarch *gdbarch = get_regcache_arch (regcache);
pi = find_procinfo_or_die (pid, tid);
retval = pid_to_ptid (-1);
/* Find procinfo for main process. */
- pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
+ pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0);
if (pi)
{
/* We must assume that the status is stale now... */
/* /proc file not found; presumably child has terminated. */
wait_retval = wait (&wstat); /* "wait" for the child's exit. */
- if (wait_retval != PIDGET (inferior_ptid)) /* wrong child? */
+ /* Wrong child? */
+ if (wait_retval != ptid_get_pid (inferior_ptid))
error (_("procfs: couldn't stop "
"process %d: wait returned %d."),
- PIDGET (inferior_ptid), wait_retval);
+ ptid_get_pid (inferior_ptid), wait_retval);
/* FIXME: might I not just use waitpid?
Or try find_procinfo to see if I know about this child? */
retval = pid_to_ptid (wait_retval);
/* The 'pid' we will return to GDB is composed of
the process ID plus the lwp ID. */
- retval = MERGEPID (pi->pid, proc_get_current_thread (pi));
+ retval = ptid_build (pi->pid, proc_get_current_thread (pi), 0);
switch (why) {
case PR_SIGNALLED:
if (!find_procinfo (pi->pid, temp_tid))
create_procinfo (pi->pid, temp_tid);
- temp_ptid = MERGEPID (pi->pid, temp_tid);
+ temp_ptid = ptid_build (pi->pid, temp_tid, 0);
/* If not in GDB's thread list, add it. */
if (!in_thread_list (temp_ptid))
add_thread (temp_ptid);
create_procinfo (pi->pid, temp_tid);
/* If not in GDB's thread list, add it. */
- temp_ptid = MERGEPID (pi->pid, temp_tid);
+ temp_ptid = ptid_build (pi->pid, temp_tid, 0);
if (!in_thread_list (temp_ptid))
add_thread (temp_ptid);
}
/* Got this far without error: If retval isn't in the
threads database, add it. */
- if (PIDGET (retval) > 0 &&
+ if (ptid_get_pid (retval) > 0 &&
!ptid_equal (retval, inferior_ptid) &&
!in_thread_list (retval))
{
GDB's list and to our own. If we don't create a
procinfo, resume may be unhappy later. */
add_thread (retval);
- if (find_procinfo (PIDGET (retval), TIDGET (retval)) == NULL)
- create_procinfo (PIDGET (retval), TIDGET (retval));
+ if (find_procinfo (ptid_get_pid (retval),
+ ptid_get_lwp (retval)) == NULL)
+ create_procinfo (ptid_get_pid (retval),
+ ptid_get_lwp (retval));
}
}
else /* Flags do not indicate STOPPED. */
int nbytes = 0;
/* Find procinfo for main process. */
- pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
+ pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0);
if (pi->as_fd == 0 &&
open_procinfo_files (pi, FD_AS) == 0)
{
to proc_run_process (for use in the prrun struct by ioctl). */
/* Find procinfo for main process. */
- pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
+ pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0);
/* First cut: ignore pid argument. */
errno = 0;
/* Void the process procinfo's caches. */
invalidate_cache (NULL, pi, NULL);
- if (PIDGET (ptid) != -1)
+ if (ptid_get_pid (ptid) != -1)
{
/* Resume a specific thread, presumably suppressing the
others. */
- thread = find_procinfo (PIDGET (ptid), TIDGET (ptid));
+ thread = find_procinfo (ptid_get_pid (ptid), ptid_get_lwp (ptid));
if (thread != NULL)
{
if (thread->tid != 0)
procfs_pass_signals (int numsigs, unsigned char *pass_signals)
{
gdb_sigset_t signals;
- procinfo *pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
+ procinfo *pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0);
int signo;
prfillset (&signals);
if (!ptid_equal (inferior_ptid, null_ptid)) /* ? */
{
/* Find procinfo for main process. */
- procinfo *pi = find_procinfo (PIDGET (inferior_ptid), 0);
+ procinfo *pi = find_procinfo (ptid_get_pid (inferior_ptid), 0);
if (pi)
unconditionally_kill_inferior (pi);
if (!ptid_equal (inferior_ptid, null_ptid))
{
/* Find procinfo for main process. */
- pi = find_procinfo (PIDGET (inferior_ptid), 0);
+ pi = find_procinfo (ptid_get_pid (inferior_ptid), 0);
if (pi)
destroy_procinfo (pi);
}
this point, but it didn't have any lwp info yet. Notify the core
about it. This changes inferior_ptid as well. */
thread_change_ptid (pid_to_ptid (pid),
- MERGEPID (pid, lwpid));
+ ptid_build (pid, lwpid), 0);
/* Typically two, one trap to exec the shell, one to exec the
program being debugged. Defined by "inferior.h". */
if (current_inferior ()->attach_flag || !target_can_run (¤t_target))
return;
- proc_trace_syscalls_1 (find_procinfo_or_die (PIDGET (inferior_ptid), 0),
- SYS_syssgi, PR_SYSEXIT, FLAG_RESET, 0);
+ proc_trace_syscalls_1 (find_procinfo_or_die (ptid_get_pid (inferior_ptid),
+ 0), SYS_syssgi, PR_SYSEXIT, FLAG_RESET, 0);
#endif
}
static int
procfs_notice_thread (procinfo *pi, procinfo *thread, void *ptr)
{
- ptid_t gdb_threadid = MERGEPID (pi->pid, thread->tid);
+ ptid_t gdb_threadid = ptid_build (pi->pid, thread->tid, 0);
if (!in_thread_list (gdb_threadid) || is_exited (gdb_threadid))
add_thread (gdb_threadid);
procinfo *pi;
/* Find procinfo for main process. */
- pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
+ pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0);
proc_update_threads (pi);
proc_iterate_over_threads (pi, procfs_notice_thread, NULL);
}
int proc, thread;
procinfo *pi;
- proc = PIDGET (ptid);
- thread = TIDGET (ptid);
+ proc = ptid_get_pid (ptid);
+ thread = ptid_get_lwp (ptid);
/* If I don't know it, it ain't alive! */
if ((pi = find_procinfo (proc, thread)) == NULL)
return 0;
{
static char buf[80];
- if (TIDGET (ptid) == 0)
- sprintf (buf, "process %d", PIDGET (ptid));
+ if (ptid_get_lwp (ptid) == 0)
+ sprintf (buf, "process %d", ptid_get_pid (ptid));
else
- sprintf (buf, "LWP %ld", TIDGET (ptid));
+ sprintf (buf, "LWP %ld", ptid_get_lwp (ptid));
return buf;
}
int pflags = 0;
procinfo *pi;
- pi = find_procinfo_or_die (PIDGET (ptid) == -1 ?
- PIDGET (inferior_ptid) : PIDGET (ptid), 0);
+ pi = find_procinfo_or_die (ptid_get_pid (ptid) == -1 ?
+ ptid_get_pid (inferior_ptid) : ptid_get_pid (ptid),
+ 0);
/* Translate from GDB's flags to /proc's. */
if (len > 0) /* len == 0 means delete watchpoint. */
{
procinfo *pi;
- pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
+ pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0);
if (proc_flags (pi) & (PR_STOPPED | PR_ISTOP))
{
{
procinfo *pi;
- pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
+ pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0);
return proc_watchpoint_address (pi, addr);
}
static int
proc_find_memory_regions (find_memory_region_ftype func, void *data)
{
- procinfo *pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
+ procinfo *pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0);
return iterate_over_mappings (pi, func, data,
find_memory_regions_callback);
argv++;
}
if (pid == 0)
- pid = PIDGET (inferior_ptid);
+ pid = ptid_get_pid (inferior_ptid);
if (pid == 0)
error (_("No current process: you must name one."));
else
{
procinfo *pi;
- if (PIDGET (inferior_ptid) <= 0)
+ if (ptid_get_pid (inferior_ptid) <= 0)
error (_("you must be debugging a process to use this command."));
if (args == NULL || args[0] == 0)
error_no_arg (_("system call to trace"));
- pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
+ pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0);
if (isdigit (args[0]))
{
const int syscallnum = atoi (args);
unsigned long merged_pid;
struct cleanup *old_chain;
- merged_pid = TIDGET (ptid) << 16 | PIDGET (ptid);
+ merged_pid = ptid_get_lwp (ptid) << 16 | ptid_get_pid (ptid);
/* This part is the old method for fetching registers.
It should be replaced by the newer one using regsets
if (pi != NULL)
{
- ptid_t ptid = MERGEPID (pi->pid, thread->tid);
+ ptid_t ptid = ptid_build (pi->pid, thread->tid, 0);
args->note_data = procfs_do_thread_registers (args->obfd, ptid,
args->note_data,
gdb_fpregset_t fpregs;
char fname[16] = {'\0'};
char psargs[80] = {'\0'};
- procinfo *pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0);
+ procinfo *pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0);
char *note_data = NULL;
char *inf_args;
struct procfs_corefile_thread_data thread_args;
#ifdef NEW_PROC_API
fill_gregset (get_current_regcache (), &gregs, -1);
note_data = elfcore_write_pstatus (obfd, note_data, note_size,
- PIDGET (inferior_ptid),
+ ptid_get_pid (inferior_ptid),
stop_signal, &gregs);
#endif
PyObject *inf_obj;
thread_object *found = NULL;
- pid = PIDGET (ptid);
+ pid = ptid_get_pid (ptid);
if (pid == 0)
return NULL;
cleanup = ensure_python_env (python_gdbarch, python_language);
- inf_obj = (inferior_object *) find_inferior_object (PIDGET(tp->ptid));
+ inf_obj
+ = (inferior_object *) find_inferior_object (ptid_get_pid (tp->ptid));
if (!inf_obj)
{
do_cleanups (cleanup);
return NULL;
thread_obj->thread = tp;
- thread_obj->inf_obj = find_inferior_object (PIDGET (tp->ptid));
+ thread_obj->inf_obj = find_inferior_object (ptid_get_pid (tp->ptid));
return thread_obj;
}
{
/* Default recfile name is "gdb_record.PID". */
xsnprintf (recfilename_buffer, sizeof (recfilename_buffer),
- "gdb_record.%d", PIDGET (inferior_ptid));
+ "gdb_record.%d", ptid_get_pid (inferior_ptid));
recfilename = recfilename_buffer;
}
/* Floating-point registers. */
if (isfloat)
- rs6000_ptrace32 (PT_READ_FPR, PIDGET (inferior_ptid), addr, nr, 0);
+ rs6000_ptrace32 (PT_READ_FPR, ptid_get_pid (inferior_ptid), addr, nr, 0);
/* Bogus register number. */
else if (nr < 0)
else
{
if (!ARCH64 ())
- *addr = rs6000_ptrace32 (PT_READ_GPR, PIDGET (inferior_ptid),
+ *addr = rs6000_ptrace32 (PT_READ_GPR, ptid_get_pid (inferior_ptid),
(int *) nr, 0, 0);
else
{
/* PT_READ_GPR requires the buffer parameter to point to long long,
even if the register is really only 32 bits. */
long long buf;
- rs6000_ptrace64 (PT_READ_GPR, PIDGET (inferior_ptid), nr, 0, &buf);
+ rs6000_ptrace64 (PT_READ_GPR, ptid_get_pid (inferior_ptid),
+ nr, 0, &buf);
if (register_size (gdbarch, regno) == 8)
memcpy (addr, &buf, 8);
else
/* Floating-point registers. */
if (isfloat)
- rs6000_ptrace32 (PT_WRITE_FPR, PIDGET (inferior_ptid), addr, nr, 0);
+ rs6000_ptrace32 (PT_WRITE_FPR, ptid_get_pid (inferior_ptid), addr, nr, 0);
/* Bogus register number. */
else if (nr < 0)
the register's value is passed by value, but for 64-bit inferiors,
the address of a buffer containing the value is passed. */
if (!ARCH64 ())
- rs6000_ptrace32 (PT_WRITE_GPR, PIDGET (inferior_ptid),
+ rs6000_ptrace32 (PT_WRITE_GPR, ptid_get_pid (inferior_ptid),
(int *) nr, *addr, 0);
else
{
memcpy (&buf, addr, 8);
else
buf = *addr;
- rs6000_ptrace64 (PT_WRITE_GPR, PIDGET (inferior_ptid), nr, 0, &buf);
+ rs6000_ptrace64 (PT_WRITE_GPR, ptid_get_pid (inferior_ptid),
+ nr, 0, &buf);
}
}
prev_pc = regcache_read_pc (regcache);
regcache_write_pc (regcache, DUMMY_INSN_ADDR);
if (ARCH64 ())
- ret = rs6000_ptrace64 (PT_CONTINUE, PIDGET (inferior_ptid), 1, 0, NULL);
+ ret = rs6000_ptrace64 (PT_CONTINUE, ptid_get_pid (inferior_ptid),
+ 1, 0, NULL);
else
- ret = rs6000_ptrace32 (PT_CONTINUE, PIDGET (inferior_ptid),
+ ret = rs6000_ptrace32 (PT_CONTINUE, ptid_get_pid (inferior_ptid),
(int *) 1, 0, NULL);
if (ret != 0)
do
{
- pid = waitpid (PIDGET (inferior_ptid), &status, 0);
+ pid = waitpid (ptid_get_pid (inferior_ptid), &status, 0);
}
- while (pid != PIDGET (inferior_ptid));
+ while (pid != ptid_get_pid (inferior_ptid));
regcache_write_pc (regcache, prev_pc);
deprecated_remove_raw_breakpoint (gdbarch, bp);
s390_inferior_tid (void)
{
/* GNU/Linux LWP ID's are process ID's. */
- int tid = TIDGET (inferior_ptid);
+ int tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+ tid = ptid_get_pid (inferior_ptid); /* Not a threaded program. */
return tid;
}
CORE_ADDR watch_lo_addr = (CORE_ADDR)-1, watch_hi_addr = 0;
struct watch_area *area;
- tid = TIDGET (lp->ptid);
+ tid = ptid_get_lwp (lp->ptid);
if (tid == 0)
- tid = PIDGET (lp->ptid);
+ tid = ptid_get_pid (lp->ptid);
for (area = watch_base; area; area = area->next)
{
{
struct reg inferior_registers;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
perror_with_name (_("Couldn't get registers"));
{
struct reg inferior_registers;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
perror_with_name (_("Couldn't get registers"));
(char *) &inferior_registers,
SHNBSD_SIZEOF_GREGS);
- if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) &inferior_registers, 0) == -1)
perror_with_name (_("Couldn't set registers"));
/* Default definitions: These must be defined in tm.h if they are to
be shared with a process module such as procfs. */
-#define GET_PID(ptid) ptid_get_pid (ptid)
-#define GET_LWP(ptid) ptid_get_lwp (ptid)
-#define GET_THREAD(ptid) ptid_get_tid (ptid)
-
-#define is_lwp(ptid) (GET_LWP (ptid) != 0)
-#define is_thread(ptid) (GET_THREAD (ptid) != 0)
-
-#define BUILD_LWP(lwp, pid) ptid_build (pid, lwp, 0)
-#define BUILD_THREAD(tid, pid) ptid_build (pid, 0, tid)
-
/* Pointers to routines from libthread_db resolved by dlopen(). */
static void (*p_td_log)(const int on_off);
td_thrhandle_t th;
td_err_e val;
- if (is_lwp (thread_id))
+ if (ptid_lwp_p (thread_id))
return thread_id; /* It's already an LWP ID. */
/* It's a thread. Convert to LWP. */
- val = p_td_ta_map_id2thr (main_ta, GET_THREAD (thread_id), &th);
+ val = p_td_ta_map_id2thr (main_ta, ptid_get_tid (thread_id), &th);
if (val == TD_NOTHR)
return pid_to_ptid (-1); /* Thread must have terminated. */
else if (val != TD_OK)
td_state_string (ti.ti_state));
}
- return BUILD_LWP (ti.ti_lid, PIDGET (thread_id));
+ return ptid_build (ptid_get_pid (thread_id), ti.ti_lid, 0);
}
/* Convert an LWP ID into a POSIX or Solaris thread ID. If LWP_ID
td_thrhandle_t th;
td_err_e val;
- if (is_thread (lwp))
+ if (ptid_tid_p (lwp))
return lwp; /* It's already a thread ID. */
/* It's an LWP. Convert it to a thread ID. */
if (!target_thread_alive (lwp))
return pid_to_ptid (-1); /* Must be a defunct LPW. */
- val = p_td_ta_map_lwp2thr (main_ta, GET_LWP (lwp), &th);
+ val = p_td_ta_map_lwp2thr (main_ta, ptid_get_lwp (lwp), &th);
if (val == TD_NOTHR)
return pid_to_ptid (-1); /* Thread must have terminated. */
else if (val != TD_OK)
else if (val != TD_OK)
error (_("lwp_to_thread: td_thr_get_info: %s."), td_err_string (val));
- return BUILD_THREAD (ti.ti_tid, PIDGET (lwp));
+ return ptid_build (ptid_get_pid (lwp), 0 , ti.ti_tid);
}
\f
struct target_ops *beneath = find_target_beneath (ops);
sol_thread_active = 0;
- inferior_ptid = pid_to_ptid (PIDGET (main_ph.ptid));
+ inferior_ptid = pid_to_ptid (ptid_get_pid (main_ph.ptid));
unpush_target (ops);
beneath->to_detach (beneath, args, from_tty);
}
old_chain = save_inferior_ptid ();
- inferior_ptid = thread_to_lwp (inferior_ptid, PIDGET (main_ph.ptid));
- if (PIDGET (inferior_ptid) == -1)
+ inferior_ptid = thread_to_lwp (inferior_ptid, ptid_get_pid (main_ph.ptid));
+ if (ptid_get_pid (inferior_ptid) == -1)
inferior_ptid = procfs_first_available ();
- if (PIDGET (ptid) != -1)
+ if (ptid_get_pid (ptid) != -1)
{
ptid_t save_ptid = ptid;
ptid = thread_to_lwp (ptid, -2);
- if (PIDGET (ptid) == -2) /* Inactive thread. */
+ if (ptid_get_pid (ptid) == -2) /* Inactive thread. */
error (_("This version of Solaris can't start inactive threads."));
- if (info_verbose && PIDGET (ptid) == -1)
+ if (info_verbose && ptid_get_pid (ptid) == -1)
warning (_("Specified thread %ld seems to have terminated"),
- GET_THREAD (save_ptid));
+ ptid_get_tid (save_ptid));
}
beneath->to_resume (beneath, ptid, step, signo);
save_ptid = inferior_ptid;
old_chain = save_inferior_ptid ();
- inferior_ptid = thread_to_lwp (inferior_ptid, PIDGET (main_ph.ptid));
- if (PIDGET (inferior_ptid) == -1)
+ inferior_ptid = thread_to_lwp (inferior_ptid, ptid_get_pid (main_ph.ptid));
+ if (ptid_get_pid (inferior_ptid) == -1)
inferior_ptid = procfs_first_available ();
- if (PIDGET (ptid) != -1)
+ if (ptid_get_pid (ptid) != -1)
{
ptid_t save_ptid = ptid;
ptid = thread_to_lwp (ptid, -2);
- if (PIDGET (ptid) == -2) /* Inactive thread. */
+ if (ptid_get_pid (ptid) == -2) /* Inactive thread. */
error (_("This version of Solaris can't start inactive threads."));
- if (info_verbose && PIDGET (ptid) == -1)
+ if (info_verbose && ptid_get_pid (ptid) == -1)
warning (_("Specified thread %ld seems to have terminated"),
- GET_THREAD (save_ptid));
+ ptid_get_tid (save_ptid));
}
rtnval = beneath->to_wait (beneath, ptid, ourstatus, options);
{
/* Map the LWP of interest back to the appropriate thread ID. */
rtnval = lwp_to_thread (rtnval);
- if (PIDGET (rtnval) == -1)
+ if (ptid_get_pid (rtnval) == -1)
rtnval = save_ptid;
/* See if we have a new thread. */
- if (is_thread (rtnval)
+ if (ptid_tid_p (rtnval)
&& !ptid_equal (rtnval, save_ptid)
&& (!in_thread_list (rtnval)
|| is_exited (rtnval)))
gdb_fpregset_t *fpregset_p = &fpregset;
struct target_ops *beneath = find_target_beneath (ops);
- if (!is_thread (inferior_ptid))
+ if (!ptid_tid_p (inferior_ptid))
{
/* It's an LWP; pass the request on to the layer beneath. */
beneath->to_fetch_registers (beneath, regcache, regnum);
}
/* Solaris thread: convert INFERIOR_PTID into a td_thrhandle_t. */
- thread = GET_THREAD (inferior_ptid);
+ thread = ptid_get_tid (inferior_ptid);
if (thread == 0)
error (_("sol_thread_fetch_registers: thread == 0"));
prgregset_t gregset;
prfpregset_t fpregset;
- if (!is_thread (inferior_ptid))
+ if (!ptid_tid_p (inferior_ptid))
{
struct target_ops *beneath = find_target_beneath (ops);
}
/* Solaris thread: convert INFERIOR_PTID into a td_thrhandle_t. */
- thread = GET_THREAD (inferior_ptid);
+ thread = ptid_get_tid (inferior_ptid);
val = p_td_ta_map_id2thr (main_ta, thread, &thandle);
if (val != TD_OK)
old_chain = save_inferior_ptid ();
- if (is_thread (inferior_ptid) || !target_thread_alive (inferior_ptid))
+ if (ptid_tid_p (inferior_ptid) || !target_thread_alive (inferior_ptid))
{
/* It's either a thread or an LWP that isn't alive. Any live
LWP will do so use the first available.
main_ph.ptid = inferior_ptid; /* Save for xfer_memory. */
ptid = lwp_to_thread (inferior_ptid);
- if (PIDGET (ptid) != -1)
+ if (ptid_get_pid (ptid) != -1)
inferior_ptid = ptid;
target_find_new_threads ();
static int
sol_thread_alive (struct target_ops *ops, ptid_t ptid)
{
- if (is_thread (ptid))
+ if (ptid_tid_p (ptid))
{
/* It's a (user-level) thread. */
td_err_e val;
td_thrhandle_t th;
int pid;
- pid = GET_THREAD (ptid);
+ pid = ptid_get_tid (ptid);
if ((val = p_td_ta_map_id2thr (main_ta, pid, &th)) != TD_OK)
return 0; /* Thread not found. */
if ((val = p_td_thr_validate (&th)) != TD_OK)
old_chain = save_inferior_ptid ();
- if (is_thread (inferior_ptid) || !target_thread_alive (inferior_ptid))
+ if (ptid_tid_p (inferior_ptid) || !target_thread_alive (inferior_ptid))
{
/* It's either a thread or an LWP that isn't alive. Any live
LWP will do so use the first available.
old_chain = save_inferior_ptid ();
- inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
+ inferior_ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0);
regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
target_fetch_registers (regcache, -1);
old_chain = save_inferior_ptid ();
- inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
+ inferior_ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0);
regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
supply_gregset (regcache, (const gdb_gregset_t *) gregset);
old_chain = save_inferior_ptid ();
- inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
+ inferior_ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0);
regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
target_fetch_registers (regcache, -1);
old_chain = save_inferior_ptid ();
- inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
+ inferior_ptid = ptid_build (ptid_get_pid (inferior_ptid), lwpid, 0);
regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset);
/* FIXME: can't I get the process ID from the prochandle or
something? */
- if (PIDGET (inferior_ptid) <= 0 || lwpid <= 0)
+ if (ptid_get_pid (inferior_ptid) <= 0 || lwpid <= 0)
return PS_BADLID;
- ret = procfs_find_LDT_entry (BUILD_LWP (lwpid, PIDGET (inferior_ptid)));
+ ret = procfs_find_LDT_entry (ptid_build (ptid_get_pid (inferior_ptid),
+ lwpid, 0));
if (ret)
{
memcpy (pldt, ret, sizeof (struct ssd));
{
static char buf[100];
- if (is_thread (ptid))
+ if (ptid_tid_p (ptid))
{
ptid_t lwp;
lwp = thread_to_lwp (ptid, -2);
- if (PIDGET (lwp) == -1)
+ if (ptid_get_pid (lwp) == -1)
xsnprintf (buf, sizeof (buf), "Thread %ld (defunct)",
- GET_THREAD (ptid));
- else if (PIDGET (lwp) != -2)
+ ptid_get_tid (ptid));
+ else if (ptid_get_pid (lwp) != -2)
xsnprintf (buf, sizeof (buf), "Thread %ld (LWP %ld)",
- GET_THREAD (ptid), GET_LWP (lwp));
+ ptid_get_tid (ptid), ptid_get_lwp (lwp));
else
- xsnprintf (buf, sizeof (buf), "Thread %ld ", GET_THREAD (ptid));
+ xsnprintf (buf, sizeof (buf), "Thread %ld ",
+ ptid_get_tid (ptid));
}
- else if (GET_LWP (ptid) != 0)
- xsnprintf (buf, sizeof (buf), "LWP %ld ", GET_LWP (ptid));
+ else if (ptid_get_lwp (ptid) != 0)
+ xsnprintf (buf, sizeof (buf), "LWP %ld ", ptid_get_lwp (ptid));
else
- xsnprintf (buf, sizeof (buf), "process %d ", PIDGET (ptid));
+ xsnprintf (buf, sizeof (buf), "process %d ", ptid_get_pid (ptid));
return buf;
}
if (retval != TD_OK)
return -1;
- ptid = BUILD_THREAD (ti.ti_tid, PIDGET (inferior_ptid));
+ ptid = ptid_build (ptid_get_pid (inferior_ptid), 0, ti.ti_tid);
if (!in_thread_list (ptid) || is_exited (ptid))
add_thread (ptid);
goto keep_going;
anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
- store_unsigned_integer (buf, 4, byte_order, PIDGET (inferior_ptid));
+ store_unsigned_integer (buf, 4, byte_order, ptid_get_pid (inferior_ptid));
status = target_write_memory (anaddr, buf, 4);
if (status != 0)
{
These functions should instead be paramaterized with an explicit
object (struct regcache, struct thread_info?) into which the LWPs
registers can be written. */
- pid = TIDGET (inferior_ptid);
+ pid = ptid_get_lwp (inferior_ptid);
if (pid == 0)
- pid = PIDGET (inferior_ptid);
+ pid = ptid_get_pid (inferior_ptid);
if (regnum == SPARC_G0_REGNUM)
{
/* NOTE: cagney/2002-12-02: See comment in fetch_inferior_registers
about threaded assumptions. */
- pid = TIDGET (inferior_ptid);
+ pid = ptid_get_lwp (inferior_ptid);
if (pid == 0)
- pid = PIDGET (inferior_ptid);
+ pid = ptid_get_pid (inferior_ptid);
if (regnum == -1 || sparc_gregset_supplies_p (gdbarch, regnum))
{
{
int pid;
- pid = TIDGET (inferior_ptid);
+ pid = ptid_get_lwp (inferior_ptid);
if (pid == 0)
- pid = PIDGET (inferior_ptid);
+ pid = ptid_get_pid (inferior_ptid);
/* Sanity check. The proper type for a cookie is register_t, but
we can't assume that this type exists on all systems supported
{
PTRACE_TYPE_RET res;
- int tid = TIDGET (inferior_ptid);
+ int tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid);
+ tid = ptid_get_pid (inferior_ptid);
#ifndef __powerpc64__
/* If running as a 32-bit process on a 64-bit system, we attempt
/ sizeof (PTRACE_TYPE_RET));
PTRACE_TYPE_RET *buffer;
- int tid = TIDGET (inferior_ptid);
+ int tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid);
+ tid = ptid_get_pid (inferior_ptid);
buffer = (PTRACE_TYPE_RET *) alloca (count * sizeof (PTRACE_TYPE_RET));
for (i = 0; i < count; i++, addr += sizeof (PTRACE_TYPE_RET))
/ sizeof (PTRACE_TYPE_RET));
PTRACE_TYPE_RET *buffer;
- int tid = TIDGET (inferior_ptid);
+ int tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid);
+ tid = ptid_get_pid (inferior_ptid);
buffer = (PTRACE_TYPE_RET *) alloca (count * sizeof (PTRACE_TYPE_RET));
char buf[128];
int fd = 0;
int ret = -1;
- int pid = PIDGET (inferior_ptid);
+ int pid = ptid_get_pid (inferior_ptid);
if (!annex)
return 0;
int fd;
ULONGEST addr;
- int tid = TIDGET (ptid);
+ int tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = PIDGET (ptid);
+ tid = ptid_get_pid (ptid);
while (!parse_spufs_run (&fd, &addr))
{
set_sigint_trap (); /* Causes SIGINT to be passed on to the
attached process. */
- pid = waitpid (PIDGET (ptid), &status, 0);
+ pid = waitpid (ptid_get_pid (ptid), &status, 0);
if (pid == -1 && errno == ECHILD)
/* Try again with __WCLONE to check cloned processes. */
- pid = waitpid (PIDGET (ptid), &status, __WCLONE);
+ pid = waitpid (ptid_get_pid (ptid), &status, __WCLONE);
save_errno = errno;
/* Make sure we don't report an event for the exit of the
original program, if we've detached from it. */
- if (pid != -1 && !WIFSTOPPED (status) && pid != PIDGET (inferior_ptid))
+ if (pid != -1 && !WIFSTOPPED (status)
+ && pid != ptid_get_pid (inferior_ptid))
{
pid = -1;
save_errno = EINTR;
else
/* If we're in breakpoints-always-inserted mode, have to remove
them before detaching. */
- remove_breakpoints_pid (PIDGET (inferior_ptid));
+ remove_breakpoints_pid (ptid_get_pid (inferior_ptid));
prepare_for_detach ();
fprintf_unfiltered (gdb_stdlog,
"target_wait (%d, status, options={%s})"
" = %d, %s\n",
- PIDGET (ptid), options_string,
- PIDGET (retval), status_string);
+ ptid_get_pid (ptid), options_string,
+ ptid_get_pid (retval), status_string);
xfree (status_string);
xfree (options_string);
}
t->to_resume (t, ptid, step, signal);
if (targetdebug)
fprintf_unfiltered (gdb_stdlog, "target_resume (%d, %s, %s)\n",
- PIDGET (ptid),
+ ptid_get_pid (ptid),
step ? "step" : "continue",
gdb_signal_to_name (signal));
retval = t->to_thread_alive (t, ptid);
if (targetdebug)
fprintf_unfiltered (gdb_stdlog, "target_thread_alive (%d) = %d\n",
- PIDGET (ptid), retval);
+ ptid_get_pid (ptid), retval);
return retval;
}
if (targetdebug)
fprintf_unfiltered (gdb_stdlog,
"target_core_of_thread (%d) = %d\n",
- PIDGET (ptid), retval);
+ ptid_get_pid (ptid), retval);
return retval;
}
}
debug_target.to_post_startup_inferior (ptid);
fprintf_unfiltered (gdb_stdlog, "target_post_startup_inferior (%d)\n",
- PIDGET (ptid));
+ ptid_get_pid (ptid));
}
static int
if (!number_is_in_list (requested_threads, tp->num))
continue;
- if (pid != -1 && PIDGET (tp->ptid) != pid)
+ if (pid != -1 && ptid_get_pid (tp->ptid) != pid)
continue;
if (tp->state == THREAD_EXITED)
if (!number_is_in_list (requested_threads, tp->num))
continue;
- if (pid != -1 && PIDGET (tp->ptid) != pid)
+ if (pid != -1 && ptid_get_pid (tp->ptid) != pid)
{
if (requested_threads != NULL && *requested_threads != '\0')
error (_("Requested thread not found in requested process"));
int pid;
errno = 0;
- pid = PIDGET (inferior_ptid);
+ pid = ptid_get_pid (inferior_ptid);
u_ar0 = ptrace (PT_READ_U, pid, u_ar0_offset, 0);
if (errno)
perror_with_name (_("Unable to determine location of registers"));
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
{
struct reg regs;
- if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_GETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't get registers"));
vaxbsd_collect_gregset (regcache, ®s, regnum);
- if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+ if (ptrace (PT_SETREGS, ptid_get_pid (inferior_ptid),
(PTRACE_TYPE_ARG3) ®s, 0) == -1)
perror_with_name (_("Couldn't write registers"));
}
windows_close (void)
{
DEBUG_EVENTS (("gdb: windows_close, inferior_ptid=%d\n",
- PIDGET (inferior_ptid)));
+ ptid_get_pid (inferior_ptid)));
}
/* Convert pid to printable format. */
static int
get_thread_id (ptid_t ptid)
{
- int tid = TIDGET (ptid);
+ int tid = ptid_get_lwp (ptid);
if (0 == tid)
- tid = PIDGET (ptid);
+ tid = ptid_get_pid (ptid);
return tid;
}
#define GET_THREAD_ID(PTID) get_thread_id (PTID)