diff options
author | Luis Machado <luisgpm@br.ibm.com> | 2013-09-30 11:50:12 +0000 |
---|---|---|
committer | Luis Machado <luisgpm@br.ibm.com> | 2013-09-30 11:50:12 +0000 |
commit | dfd4cc6311a8cf56cd6f4e0249fc243cface5a7f (patch) | |
tree | 2e04ba61970e95577c3e53f9b52d17b47fcb5324 /gdb | |
parent | cbb2b07e3398d52f52f27f015562b8deff884541 (diff) | |
download | gdb-dfd4cc6311a8cf56cd6f4e0249fc243cface5a7f.zip gdb-dfd4cc6311a8cf56cd6f4e0249fc243cface5a7f.tar.gz gdb-dfd4cc6311a8cf56cd6f4e0249fc243cface5a7f.tar.bz2 |
* 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.
Diffstat (limited to 'gdb')
61 files changed, 605 insertions, 536 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5788c69..ac189cb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,53 @@ +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 diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index f685619..256725b 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -54,10 +54,10 @@ 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; } @@ -683,7 +683,7 @@ aarch64_linux_prepare_to_resume (struct lwp_info *lwp) 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)); diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c index 806dcbe..97a5ab3 100644 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -73,12 +73,6 @@ static int debug_aix_thread; #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. */ @@ -283,7 +277,7 @@ pid_to_prc (ptid_t *ptidp) 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 @@ -669,7 +663,7 @@ get_signaled_thread (void) while (1) { - if (getthrds (PIDGET (inferior_ptid), &thrinf, + if (getthrds (ptid_get_pid (inferior_ptid), &thrinf, sizeof (thrinf), &ktid, 1) != 1) break; @@ -752,7 +746,7 @@ sync_threadlists (void) /* 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) @@ -762,7 +756,7 @@ sync_threadlists (void) } 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; @@ -773,7 +767,7 @@ sync_threadlists (void) 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; @@ -996,7 +990,7 @@ aix_thread_resume (struct target_ops *ops, 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); } @@ -1005,12 +999,12 @@ aix_thread_resume (struct target_ops *ops, 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) @@ -1035,11 +1029,11 @@ aix_thread_wait (struct target_ops *ops, 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. */ @@ -1698,7 +1692,7 @@ aix_thread_xfer_partial (struct target_ops *ops, enum target_object object, 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); diff --git a/gdb/alphabsd-nat.c b/gdb/alphabsd-nat.c index 083f962..8e6942f 100644 --- a/gdb/alphabsd-nat.c +++ b/gdb/alphabsd-nat.c @@ -91,7 +91,7 @@ alphabsd_fetch_inferior_registers (struct target_ops *ops, { 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")); @@ -105,7 +105,7 @@ alphabsd_fetch_inferior_registers (struct target_ops *ops, { 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")); @@ -123,13 +123,13 @@ alphabsd_store_inferior_registers (struct target_ops *ops, 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")); @@ -142,13 +142,13 @@ alphabsd_store_inferior_registers (struct target_ops *ops, { 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")); } diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c index 8dfe7c5..a61d218 100644 --- a/gdb/amd64-linux-nat.c +++ b/gdb/amd64-linux-nat.c @@ -164,9 +164,9 @@ amd64_linux_fetch_inferior_registers (struct target_ops *ops, 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)) { @@ -219,9 +219,9 @@ amd64_linux_store_inferior_registers (struct target_ops *ops, 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)) { @@ -281,9 +281,9 @@ amd64_linux_dr_get (ptid_t ptid, int 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, @@ -301,9 +301,9 @@ amd64_linux_dr_set (ptid_t ptid, int regnum, unsigned long value) { 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, @@ -1046,9 +1046,9 @@ amd64_linux_read_description (struct target_ops *ops) 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; diff --git a/gdb/amd64bsd-nat.c b/gdb/amd64bsd-nat.c index 1cd9207..b4c5818 100644 --- a/gdb/amd64bsd-nat.c +++ b/gdb/amd64bsd-nat.c @@ -49,7 +49,7 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops, { 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")); @@ -62,7 +62,7 @@ amd64bsd_fetch_inferior_registers (struct target_ops *ops, { 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")); @@ -83,13 +83,13 @@ amd64bsd_store_inferior_registers (struct target_ops *ops, { 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")); @@ -101,13 +101,13 @@ amd64bsd_store_inferior_registers (struct target_ops *ops, { 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")); } @@ -137,7 +137,7 @@ amd64bsd_dr_get (ptid_t ptid, int regnum) { 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")); @@ -149,7 +149,7 @@ amd64bsd_dr_set (int regnum, unsigned long value) { 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")); @@ -160,7 +160,7 @@ amd64bsd_dr_set (int regnum, unsigned long value) 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")); } diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c index 09359cd..96573d9 100644 --- a/gdb/arm-linux-nat.c +++ b/gdb/arm-linux-nat.c @@ -80,9 +80,9 @@ extern int arm_apcs_32; 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; } @@ -671,7 +671,7 @@ arm_linux_read_description (struct target_ops *ops) /* 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 @@ -1047,7 +1047,7 @@ arm_linux_insert_hw_breakpoint (struct gdbarch *gdbarch, 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; } @@ -1065,7 +1065,7 @@ arm_linux_remove_hw_breakpoint (struct gdbarch *gdbarch, 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; } @@ -1116,7 +1116,7 @@ arm_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw, 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; } @@ -1134,7 +1134,7 @@ arm_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw, 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; } @@ -1190,7 +1190,7 @@ arm_linux_watchpoint_addr_within_range (struct target_ops *target, 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) @@ -1225,7 +1225,7 @@ arm_linux_thread_exit (struct thread_info *tp, int silent) 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; diff --git a/gdb/armnbsd-nat.c b/gdb/armnbsd-nat.c index 81cb2b0..20d8378 100644 --- a/gdb/armnbsd-nat.c +++ b/gdb/armnbsd-nat.c @@ -79,7 +79,7 @@ fetch_register (struct regcache *regcache, int regno) 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) @@ -132,7 +132,7 @@ fetch_regs (struct regcache *regcache) 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) @@ -150,7 +150,7 @@ fetch_fp_register (struct regcache *regcache, int regno) 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) @@ -180,7 +180,7 @@ fetch_fp_regs (struct regcache *regcache) 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) @@ -218,7 +218,7 @@ store_register (const struct regcache *regcache, int regno) 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) @@ -281,7 +281,7 @@ store_register (const struct regcache *regcache, int regno) 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) @@ -329,7 +329,7 @@ store_regs (const struct regcache *regcache) 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) @@ -342,7 +342,7 @@ store_fp_register (const struct regcache *regcache, int regno) 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) @@ -364,7 +364,7 @@ store_fp_register (const struct regcache *regcache, int regno) 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) @@ -386,7 +386,7 @@ store_fp_regs (const struct regcache *regcache) 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) @@ -48,7 +48,7 @@ procfs_xfer_auxv (gdb_byte *readbuf, 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) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index c132e24..b98ca9e 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3581,7 +3581,7 @@ detach_breakpoints (ptid_t ptid) 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. */ @@ -7546,7 +7546,7 @@ struct fork_catchpoint 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 @@ -7555,7 +7555,7 @@ insert_catch_fork (struct bp_location *bl) 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 @@ -7663,7 +7663,7 @@ static struct breakpoint_ops catch_fork_breakpoint_ops; 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 @@ -7672,7 +7672,7 @@ insert_catch_vfork (struct bp_location *bl) 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 @@ -8165,7 +8165,7 @@ insert_catch_syscall (struct bp_location *bl) } } - 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, @@ -8205,7 +8205,7 @@ remove_catch_syscall (struct bp_location *bl) } } - 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, @@ -8528,13 +8528,13 @@ dtor_catch_exec (struct breakpoint *b) 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 diff --git a/gdb/common/ptid.c b/gdb/common/ptid.c index 506b5c2..e8d25c0 100644 --- a/gdb/common/ptid.c +++ b/gdb/common/ptid.c @@ -83,10 +83,33 @@ ptid_equal (ptid_t ptid1, ptid_t ptid2) 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); +} diff --git a/gdb/common/ptid.h b/gdb/common/ptid.h index fefe8b6..1326506 100644 --- a/gdb/common/ptid.h +++ b/gdb/common/ptid.h @@ -33,6 +33,9 @@ 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 @@ -82,4 +85,10 @@ int ptid_equal (ptid_t p1, ptid_t p2); /* 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 @@ -753,18 +753,6 @@ extern int (*deprecated_ui_load_progress_hook) (const char *section, 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 diff --git a/gdb/gcore.c b/gdb/gcore.c index a4bb9ca..49f9b22 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -136,7 +136,7 @@ gcore_command (char *args, int from_tty) 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); diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index c3b85dc..81dc7ed 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -323,7 +323,7 @@ extern int thread_count (void); 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. @@ -361,7 +361,7 @@ extern int is_stopped (ptid_t ptid); /* 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 @@ -379,7 +379,7 @@ extern int is_executing (ptid_t ptid); "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); diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index b99f557..4a25759 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2015,7 +2015,8 @@ gnu_resume (struct target_ops *ops, 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); } diff --git a/gdb/hppa-linux-nat.c b/gdb/hppa-linux-nat.c index 3d8496c..4f5ca69 100644 --- a/gdb/hppa-linux-nat.c +++ b/gdb/hppa-linux-nat.c @@ -224,9 +224,9 @@ fetch_register (struct regcache *regcache, int 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. */ errno = 0; val = ptrace (PTRACE_PEEKUSER, tid, hppa_linux_register_addr (regno, 0), 0); @@ -251,9 +251,9 @@ store_register (const struct regcache *regcache, int regno) 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); diff --git a/gdb/hppabsd-nat.c b/gdb/hppabsd-nat.c index 193fff3..181754e 100644 --- a/gdb/hppabsd-nat.c +++ b/gdb/hppabsd-nat.c @@ -191,7 +191,7 @@ hppabsd_fetch_registers (struct target_ops *ops, { 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")); @@ -202,7 +202,7 @@ hppabsd_fetch_registers (struct target_ops *ops, { 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")); @@ -221,13 +221,13 @@ hppabsd_store_registers (struct target_ops *ops, { 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")); } @@ -236,13 +236,13 @@ hppabsd_store_registers (struct target_ops *ops, { 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")); } diff --git a/gdb/hppanbsd-nat.c b/gdb/hppanbsd-nat.c index c381b6f..be1d9dc 100644 --- a/gdb/hppanbsd-nat.c +++ b/gdb/hppanbsd-nat.c @@ -167,7 +167,7 @@ hppanbsd_fetch_registers (struct target_ops *ops, { 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")); @@ -178,7 +178,7 @@ hppanbsd_fetch_registers (struct target_ops *ops, { 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")); @@ -197,13 +197,13 @@ hppanbsd_store_registers (struct target_ops *ops, { 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")); } @@ -212,13 +212,13 @@ hppanbsd_store_registers (struct target_ops *ops, { 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")); } diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c index be2b6c9..52ecc38 100644 --- a/gdb/i386-linux-nat.c +++ b/gdb/i386-linux-nat.c @@ -148,9 +148,9 @@ fetch_register (struct regcache *regcache, int 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. */ errno = 0; val = ptrace (PTRACE_PEEKUSER, tid, @@ -176,9 +176,9 @@ store_register (const struct regcache *regcache, int regno) 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); @@ -514,9 +514,9 @@ i386_linux_fetch_inferior_registers (struct target_ops *ops, } /* 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 @@ -595,9 +595,9 @@ i386_linux_store_inferior_registers (struct target_ops *ops, } /* 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 @@ -652,9 +652,9 @@ i386_linux_dr_get (ptid_t ptid, int 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, @@ -672,9 +672,9 @@ i386_linux_dr_set (ptid_t ptid, int regnum, unsigned long value) { 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, @@ -917,7 +917,7 @@ static void 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; @@ -1000,9 +1000,9 @@ i386_linux_read_description (struct target_ops *ops) 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) diff --git a/gdb/i386bsd-nat.c b/gdb/i386bsd-nat.c index 797e7dc..9bd1e6c 100644 --- a/gdb/i386bsd-nat.c +++ b/gdb/i386bsd-nat.c @@ -136,7 +136,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops, { 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")); @@ -152,7 +152,7 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops, 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; @@ -160,14 +160,14 @@ i386bsd_fetch_inferior_registers (struct target_ops *ops, } 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")); @@ -187,13 +187,13 @@ i386bsd_store_inferior_registers (struct target_ops *ops, { 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")); @@ -208,14 +208,14 @@ i386bsd_store_inferior_registers (struct target_ops *ops, 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")); } @@ -223,13 +223,13 @@ i386bsd_store_inferior_registers (struct target_ops *ops, { 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 @@ -268,7 +268,7 @@ i386bsd_dr_get (ptid_t ptid, int regnum) { 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")); @@ -280,7 +280,7 @@ i386bsd_dr_set (int regnum, unsigned int value) { 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")); @@ -291,7 +291,7 @@ i386bsd_dr_set (int regnum, unsigned int value) 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")); } diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c index 3bd4237..9d2f75c 100644 --- a/gdb/ia64-linux-nat.c +++ b/gdb/ia64-linux-nat.c @@ -511,9 +511,9 @@ store_debug_register (ptid_t ptid, int idx, long val) { 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); } diff --git a/gdb/infcmd.c b/gdb/infcmd.c index e29dcde..0659605 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2408,7 +2408,7 @@ attach_command_post_wait (char *args, int from_tty, int async_exec) 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 @@ -2433,7 +2433,7 @@ attach_command_post_wait (char *args, int from_tty, int async_exec) } /* 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); diff --git a/gdb/inferior.h b/gdb/inferior.h index 1b83e52..922a0f2 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -90,7 +90,7 @@ extern void set_inferior_io_terminal (const char *terminal_name); 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; diff --git a/gdb/inflow.c b/gdb/inflow.c index faf4888..f64c0c1 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -264,7 +264,7 @@ terminal_init_inferior (void) (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 */ } @@ -769,7 +769,7 @@ static void pass_signal (int signo) { #ifndef _WIN32 - kill (PIDGET (inferior_ptid), SIGINT); + kill (ptid_get_pid (inferior_ptid), SIGINT); #endif } diff --git a/gdb/infrun.c b/gdb/infrun.c index 8952b23..db0ad8d 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2607,14 +2607,15 @@ print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid, 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); diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c index 3774a7f..bff807e 100644 --- a/gdb/linux-fork.c +++ b/gdb/linux-fork.c @@ -71,14 +71,14 @@ add_fork (pid_t pid) { 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); @@ -282,7 +282,8 @@ fork_save_infrun_state (struct fork_info *fp, int clobber_regs) { /* 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; @@ -333,7 +334,7 @@ linux_fork_killall (void) 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. */ @@ -392,7 +393,7 @@ linux_fork_detach (char *args, int from_tty) 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); @@ -497,7 +498,7 @@ delete_checkpoint_command (char *args, int from_tty) 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); @@ -516,7 +517,7 @@ Please switch to another checkpoint before deleting the current one")); 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)); } } @@ -537,7 +538,7 @@ detach_checkpoint_command (char *args, int from_tty) 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) @@ -680,7 +681,7 @@ checkpoint_command (char *args, int 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); diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 90638e2..4784a5e 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -387,7 +387,8 @@ linux_child_follow_fork (struct target_ops *ops, int follow_child, 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. */ @@ -428,7 +429,7 @@ holding the child stopped. Try \"set detach-on-fork\" or \ 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) @@ -935,7 +936,7 @@ add_initial_lwp (ptid_t ptid) { struct lwp_info *lp; - gdb_assert (is_lwp (ptid)); + gdb_assert (ptid_lwp_p (ptid)); lp = (struct lwp_info *) xmalloc (sizeof (struct lwp_info)); @@ -1007,13 +1008,13 @@ find_lwp_pid (ptid_t ptid) 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; @@ -1055,7 +1056,7 @@ linux_nat_switch_fork (ptid_t new_ptid) { 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; @@ -1096,7 +1097,7 @@ static int 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)) @@ -1174,10 +1175,10 @@ lin_lwp_attach_lwp (ptid_t ptid) 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 @@ -1185,7 +1186,7 @@ lin_lwp_attach_lwp (ptid_t ptid) 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; @@ -1253,7 +1254,7 @@ lin_lwp_attach_lwp (ptid_t ptid) lp->status = status; } - target_post_attach (GET_LWP (lp->ptid)); + target_post_attach (ptid_get_lwp (lp->ptid)); if (debug_linux_nat) { @@ -1362,7 +1363,9 @@ linux_nat_attach (struct target_ops *ops, char *args, int from_tty) /* 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. */ @@ -1400,7 +1403,7 @@ linux_nat_attach (struct target_ops *ops, char *args, int from_tty) internal_error (__FILE__, __LINE__, _("unexpected status %d for PID %ld"), - status, (long) GET_LWP (ptid)); + status, (long) ptid_get_lwp (ptid)); } lp->stopped = 1; @@ -1410,7 +1413,7 @@ linux_nat_attach (struct target_ops *ops, char *args, int from_tty) 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; @@ -1462,7 +1465,7 @@ get_pending_status (struct lwp_info *lp, int *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); @@ -1520,13 +1523,13 @@ detach_callback (struct lwp_info *lp, void *data) "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; @@ -1536,7 +1539,7 @@ detach_callback (struct lwp_info *lp, void *data) 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)); @@ -1560,7 +1563,7 @@ linux_nat_detach (struct target_ops *ops, char *args, int from_tty) 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. */ @@ -1575,7 +1578,7 @@ linux_nat_detach (struct target_ops *ops, char *args, int from_tty) 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)); @@ -1618,7 +1621,7 @@ resume_lwp (struct lwp_info *lp, int step, enum gdb_signal signo) { 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) { @@ -1642,7 +1645,7 @@ resume_lwp (struct lwp_info *lp, int step, enum gdb_signal signo) 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; @@ -1795,7 +1798,7 @@ linux_nat_resume (struct target_ops *ops, 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); @@ -1883,10 +1886,10 @@ linux_handle_syscall_trap (struct lwp_info *lp, int stopping) "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; } @@ -1915,7 +1918,7 @@ linux_handle_syscall_trap (struct lwp_info *lp, int stopping) == TARGET_WAITKIND_SYSCALL_ENTRY ? "entry" : "return", syscall_number, - GET_LWP (lp->ptid)); + ptid_get_lwp (lp->ptid)); return 0; } @@ -1926,7 +1929,7 @@ linux_handle_syscall_trap (struct lwp_info *lp, int stopping) lp->syscall_state == TARGET_WAITKIND_SYSCALL_ENTRY ? "entry" : "return", syscall_number, - GET_LWP (lp->ptid)); + ptid_get_lwp (lp->ptid)); } else { @@ -1952,7 +1955,7 @@ linux_handle_syscall_trap (struct lwp_info *lp, int stopping) "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; } @@ -1968,7 +1971,7 @@ linux_handle_syscall_trap (struct lwp_info *lp, int stopping) 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; } @@ -1983,7 +1986,7 @@ static int 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; @@ -2024,7 +2027,7 @@ linux_handle_extended_wait (struct lwp_info *lp, int status, } 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' @@ -2063,7 +2066,7 @@ linux_handle_extended_wait (struct lwp_info *lp, int status, "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; @@ -2120,7 +2123,7 @@ linux_handle_extended_wait (struct lwp_info *lp, int status, { /* 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); } @@ -2144,7 +2147,7 @@ linux_handle_extended_wait (struct lwp_info *lp, int status, 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; } @@ -2162,7 +2165,7 @@ linux_handle_extended_wait (struct lwp_info *lp, int 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), @@ -2176,7 +2179,8 @@ linux_handle_extended_wait (struct lwp_info *lp, int status, "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; @@ -2190,7 +2194,7 @@ linux_handle_extended_wait (struct lwp_info *lp, int status, 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 @@ -2207,7 +2211,7 @@ linux_handle_extended_wait (struct lwp_info *lp, int status, 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; @@ -2217,8 +2221,8 @@ linux_handle_extended_wait (struct lwp_info *lp, int status, 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; } @@ -2248,9 +2252,9 @@ wait_lwp (struct lwp_info *lp) /* 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 @@ -2281,8 +2285,8 @@ wait_lwp (struct lwp_info *lp) 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) @@ -2306,7 +2310,7 @@ wait_lwp (struct lwp_info *lp) if (!thread_dead) { - gdb_assert (pid == GET_LWP (lp->ptid)); + gdb_assert (pid == ptid_get_lwp (lp->ptid)); if (debug_linux_nat) { @@ -2376,7 +2380,7 @@ stop_callback (struct lwp_info *lp, void *data) 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, @@ -2444,7 +2448,7 @@ maybe_clear_ignore_sigint (struct lwp_info *lp) 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, @@ -2564,7 +2568,7 @@ linux_nat_set_status_is_event (struct target_ops *t, 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. */ @@ -2585,7 +2589,7 @@ stop_wait_callback (struct lwp_info *lp, void *data) 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) " @@ -2873,7 +2877,7 @@ stop_and_resume_callback (struct lwp_info *lp, void *data) 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); } @@ -2882,7 +2886,7 @@ stop_and_resume_callback (struct lwp_info *lp, void *data) 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 @@ -2891,7 +2895,7 @@ stop_and_resume_callback (struct lwp_info *lp, void *data) 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; } @@ -2936,7 +2940,7 @@ linux_nat_filter_event (int lwpid, int status, int *new_pending_p) "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); @@ -2983,7 +2987,7 @@ linux_nat_filter_event (int lwpid, int status, int *new_pending_p) /* 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 @@ -2995,10 +2999,10 @@ linux_nat_filter_event (int lwpid, int status, int *new_pending_p) 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); } @@ -3007,7 +3011,7 @@ linux_nat_filter_event (int lwpid, int status, int *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 @@ -3021,9 +3025,9 @@ linux_nat_filter_event (int lwpid, int status, int *new_pending_p) 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, @@ -3059,8 +3063,9 @@ linux_nat_filter_event (int lwpid, int status, int *new_pending_p) 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", @@ -3092,7 +3097,7 @@ linux_nat_filter_event (int lwpid, int status, int *new_pending_p) 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, @@ -3199,8 +3204,8 @@ linux_nat_wait_1 (struct target_ops *ops, { /* 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; @@ -3227,7 +3232,7 @@ retry: 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, @@ -3471,7 +3476,8 @@ retry: 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, @@ -3629,7 +3635,7 @@ resume_stopped_resumed_lwps (struct lwp_info *lp, void *data) 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; @@ -3695,7 +3701,7 @@ kill_callback (struct lwp_info *lp, void *data) /* 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", @@ -3705,7 +3711,7 @@ kill_callback (struct lwp_info *lp, void *data) /* 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", @@ -3731,7 +3737,7 @@ kill_wait_callback (struct lwp_info *lp, void *data) { 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) @@ -3746,14 +3752,14 @@ kill_wait_callback (struct lwp_info *lp, void *data) 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) @@ -3764,7 +3770,7 @@ kill_wait_callback (struct lwp_info *lp, void *data) 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; @@ -3786,12 +3792,12 @@ linux_nat_kill (struct target_ops *ops) 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 ()) @@ -3871,9 +3877,9 @@ linux_xfer_siginfo (struct target_ops *ops, enum target_object object, 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; @@ -3933,8 +3939,8 @@ linux_nat_xfer_partial (struct target_ops *ops, enum target_object object, 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); @@ -3948,12 +3954,12 @@ linux_thread_alive (ptid_t ptid) { 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, @@ -3978,11 +3984,11 @@ linux_nat_pid_to_str (struct target_ops *ops, ptid_t ptid) { 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; } @@ -4126,7 +4132,7 @@ linux_proc_xfer_partial (struct target_ops *ops, enum target_object object, /* 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; @@ -4210,7 +4216,7 @@ linux_proc_xfer_spu (struct target_ops *ops, enum target_object object, char buf[128]; int fd = 0; int ret = -1; - int pid = PIDGET (inferior_ptid); + int pid = ptid_get_pid (inferior_ptid); if (!annex) { @@ -4773,18 +4779,18 @@ linux_nat_thread_address_space (struct target_ops *t, ptid_t ptid) 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); @@ -4929,9 +4935,9 @@ linux_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo) { 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); diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h index 044f646..0fc68ef 100644 --- a/gdb/linux-nat.h +++ b/gdb/linux-nat.h @@ -110,11 +110,6 @@ extern struct lwp_info *lwp_list; (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); diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 3813f63..593fc29 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -452,16 +452,17 @@ thread_from_lwp (ptid_t ptid) /* 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; @@ -481,14 +482,14 @@ thread_db_attach_lwp (ptid_t ptid) 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; @@ -499,7 +500,8 @@ thread_db_attach_lwp (ptid_t 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; @@ -532,7 +534,7 @@ enable_thread_event (int event, CORE_ADDR *bp) 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; @@ -594,7 +596,7 @@ enable_thread_event_reporting (void) 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. */ @@ -877,7 +879,7 @@ try_thread_db_load (const char *library) 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; } @@ -1090,7 +1092,7 @@ thread_db_load (void) { 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; @@ -1266,7 +1268,8 @@ attach_thread (ptid_t ptid, const td_thrhandle_t *th_p, { 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. */ @@ -1303,7 +1306,7 @@ attach_thread (ptid_t ptid, const td_thrhandle_t *th_p, 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. */ @@ -1342,7 +1345,7 @@ thread_db_detach (struct target_ops *ops, char *args, int from_tty) 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) { @@ -1358,7 +1361,7 @@ thread_db_detach (struct target_ops *ops, char *args, int from_tty) 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); @@ -1387,7 +1390,7 @@ check_event (ptid_t ptid) 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) @@ -1437,7 +1440,7 @@ check_event (ptid_t ptid) 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) { @@ -1481,7 +1484,7 @@ thread_db_wait (struct target_ops *ops, || 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) @@ -1491,7 +1494,7 @@ thread_db_wait (struct target_ops *ops, { /* 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); @@ -1525,7 +1528,7 @@ thread_db_mourn_inferior (struct target_ops *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); @@ -1665,7 +1668,7 @@ thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new) 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; @@ -1745,7 +1748,7 @@ thread_db_pid_to_str (struct target_ops *ops, ptid_t 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; } @@ -1797,7 +1800,7 @@ thread_db_get_thread_local_address (struct target_ops *ops, 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) @@ -1883,9 +1886,9 @@ thread_db_resume (struct target_ops *ops, 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 diff --git a/gdb/m32r-linux-nat.c b/gdb/m32r-linux-nat.c index e5f755b..70bd528 100644 --- a/gdb/m32r-linux-nat.c +++ b/gdb/m32r-linux-nat.c @@ -200,9 +200,9 @@ m32r_linux_fetch_inferior_registers (struct target_ops *ops, 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 @@ -227,8 +227,8 @@ m32r_linux_store_inferior_registers (struct target_ops *ops, 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. */ diff --git a/gdb/m68kbsd-nat.c b/gdb/m68kbsd-nat.c index 30e6fba..3792959 100644 --- a/gdb/m68kbsd-nat.c +++ b/gdb/m68kbsd-nat.c @@ -116,7 +116,7 @@ m68kbsd_fetch_inferior_registers (struct target_ops *ops, { 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")); @@ -127,7 +127,7 @@ m68kbsd_fetch_inferior_registers (struct target_ops *ops, { 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")); @@ -146,13 +146,13 @@ m68kbsd_store_inferior_registers (struct target_ops *ops, { 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")); } @@ -161,13 +161,13 @@ m68kbsd_store_inferior_registers (struct target_ops *ops, { 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")); } diff --git a/gdb/m68klinux-nat.c b/gdb/m68klinux-nat.c index 5e30ad2..5e928e6 100644 --- a/gdb/m68klinux-nat.c +++ b/gdb/m68klinux-nat.c @@ -112,9 +112,9 @@ fetch_register (struct regcache *regcache, int regno) 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]; @@ -166,9 +166,9 @@ store_register (const struct regcache *regcache, int 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]; @@ -420,9 +420,9 @@ m68k_linux_fetch_inferior_registers (struct target_ops *ops, } /* 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 @@ -477,9 +477,9 @@ m68k_linux_store_inferior_registers (struct target_ops *ops, } /* 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 diff --git a/gdb/m88kbsd-nat.c b/gdb/m88kbsd-nat.c index f5ca73c..4f72306 100644 --- a/gdb/m88kbsd-nat.c +++ b/gdb/m88kbsd-nat.c @@ -68,7 +68,7 @@ m88kbsd_fetch_inferior_registers (struct target_ops *ops, { 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")); @@ -84,13 +84,13 @@ m88kbsd_store_inferior_registers (struct target_ops *ops, { 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")); } diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 80cc005..44ebd21 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -727,7 +727,7 @@ mi_on_resume (ptid_t ptid) 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)) { diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index e8c4744..a840579 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -210,7 +210,7 @@ proceed_thread (struct thread_info *thread, int pid) 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); @@ -320,7 +320,7 @@ interrupt_thread_callback (struct thread_info *thread, void *arg) 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); @@ -414,7 +414,7 @@ find_thread_of_process (struct thread_info *ti, void *p) { 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; diff --git a/gdb/mips64obsd-nat.c b/gdb/mips64obsd-nat.c index 22909fc..a633edb 100644 --- a/gdb/mips64obsd-nat.c +++ b/gdb/mips64obsd-nat.c @@ -82,7 +82,7 @@ mips64obsd_fetch_inferior_registers (struct target_ops *ops, { 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")); @@ -98,13 +98,13 @@ mips64obsd_store_inferior_registers (struct target_ops *ops, { 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")); } diff --git a/gdb/mipsnbsd-nat.c b/gdb/mipsnbsd-nat.c index 9bd514f..202b404 100644 --- a/gdb/mipsnbsd-nat.c +++ b/gdb/mipsnbsd-nat.c @@ -47,7 +47,7 @@ mipsnbsd_fetch_inferior_registers (struct target_ops *ops, { 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")); @@ -61,7 +61,7 @@ mipsnbsd_fetch_inferior_registers (struct target_ops *ops, { 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")); @@ -78,13 +78,13 @@ mipsnbsd_store_inferior_registers (struct target_ops *ops, { 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")); @@ -97,13 +97,13 @@ mipsnbsd_store_inferior_registers (struct target_ops *ops, { 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")); } diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c index 5109fac..1e6ec74 100644 --- a/gdb/nto-procfs.c +++ b/gdb/nto-procfs.c @@ -661,7 +661,8 @@ do_attach (ptid_t ptid) 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, @@ -679,9 +680,9 @@ do_attach (ptid_t ptid) 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. */ @@ -789,7 +790,7 @@ procfs_wait (struct target_ops *ops, { int waitval = 0; - waitpid (PIDGET (inferior_ptid), &waitval, WNOHANG); + waitpid (ptid_get_pid (inferior_ptid), &waitval, WNOHANG); if (exit_signo) { /* Abnormal death. */ @@ -894,7 +895,7 @@ procfs_detach (struct target_ops *ops, char *args, int from_tty) 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; @@ -992,7 +993,7 @@ procfs_resume (struct target_ops *ops, { 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; } @@ -1016,7 +1017,7 @@ procfs_mourn_inferior (struct target_ops *ops) { 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; diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index c518f77..66e8062 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -864,11 +864,11 @@ ppc_linux_fetch_inferior_registers (struct target_ops *ops, 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); @@ -1417,9 +1417,9 @@ have_ptrace_hwdebug_interface (void) { 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) @@ -1484,9 +1484,9 @@ ppc_linux_can_use_hw_breakpoint (int type, int cnt, int ot) /* 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; @@ -1702,7 +1702,7 @@ ppc_linux_insert_hw_breakpoint (struct gdbarch *gdbarch, } ALL_LWPS (lp) - hwdebug_insert_point (&p, TIDGET (lp->ptid)); + hwdebug_insert_point (&p, ptid_get_lwp (lp->ptid)); return 0; } @@ -1738,7 +1738,7 @@ ppc_linux_remove_hw_breakpoint (struct gdbarch *gdbarch, } ALL_LWPS (lp) - hwdebug_remove_point (&p, TIDGET (lp->ptid)); + hwdebug_remove_point (&p, ptid_get_lwp (lp->ptid)); return 0; } @@ -1781,7 +1781,7 @@ ppc_linux_insert_mask_watchpoint (struct target_ops *ops, CORE_ADDR addr, 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; } @@ -1809,7 +1809,7 @@ ppc_linux_remove_mask_watchpoint (struct target_ops *ops, CORE_ADDR addr, 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; } @@ -1819,7 +1819,7 @@ static int 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; @@ -2086,7 +2086,7 @@ ppc_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw, 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; } @@ -2130,7 +2130,7 @@ ppc_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw, 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; @@ -2154,7 +2154,7 @@ ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw, 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; } @@ -2162,7 +2162,7 @@ ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw, { 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; @@ -2175,7 +2175,7 @@ ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw, 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 ()) { @@ -2214,7 +2214,7 @@ static void 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; @@ -2263,7 +2263,7 @@ ppc_linux_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_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. */ @@ -2335,11 +2335,11 @@ ppc_linux_store_inferior_registers (struct target_ops *ops, 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); @@ -2401,9 +2401,9 @@ ppc_linux_target_wordsize (void) #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); @@ -2445,9 +2445,9 @@ ppc_linux_read_description (struct target_ops *ops) 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) { diff --git a/gdb/ppcfbsd-nat.c b/gdb/ppcfbsd-nat.c index 190d460..4d4dfff 100644 --- a/gdb/ppcfbsd-nat.c +++ b/gdb/ppcfbsd-nat.c @@ -123,7 +123,7 @@ ppcfbsd_fetch_inferior_registers (struct target_ops *ops, { 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")); @@ -134,7 +134,7 @@ ppcfbsd_fetch_inferior_registers (struct target_ops *ops, 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")); @@ -151,13 +151,13 @@ ppcfbsd_store_inferior_registers (struct target_ops *ops, { 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")); @@ -165,13 +165,13 @@ ppcfbsd_store_inferior_registers (struct target_ops *ops, { 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")); } diff --git a/gdb/ppcnbsd-nat.c b/gdb/ppcnbsd-nat.c index 4828453..a816980 100644 --- a/gdb/ppcnbsd-nat.c +++ b/gdb/ppcnbsd-nat.c @@ -88,7 +88,7 @@ ppcnbsd_fetch_inferior_registers (struct target_ops *ops, { 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")); @@ -100,7 +100,7 @@ ppcnbsd_fetch_inferior_registers (struct target_ops *ops, { 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")); @@ -119,14 +119,14 @@ ppcnbsd_store_inferior_registers (struct target_ops *ops, { 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")); } @@ -135,14 +135,14 @@ ppcnbsd_store_inferior_registers (struct target_ops *ops, { 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")); } diff --git a/gdb/ppcobsd-nat.c b/gdb/ppcobsd-nat.c index 55e1a0a..1286c80 100644 --- a/gdb/ppcobsd-nat.c +++ b/gdb/ppcobsd-nat.c @@ -77,7 +77,7 @@ ppcobsd_fetch_registers (struct target_ops *ops, { 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")); @@ -94,7 +94,7 @@ ppcobsd_fetch_registers (struct target_ops *ops, { 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")); @@ -113,7 +113,7 @@ ppcobsd_store_registers (struct target_ops *ops, { 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")); @@ -124,7 +124,7 @@ ppcobsd_store_registers (struct target_ops *ops, 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")); @@ -134,14 +134,14 @@ ppcobsd_store_registers (struct target_ops *ops, { 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")); } diff --git a/gdb/proc-service.c b/gdb/proc-service.c index 83e1d67..f76ad4b 100644 --- a/gdb/proc-service.c +++ b/gdb/proc-service.c @@ -51,11 +51,6 @@ typedef size_t gdb_ps_size_t; #endif -/* Building process ids. */ - -#define BUILD_LWP(lwp, pid) ptid_build (pid, lwp, 0) - - /* Helper functions. */ /* Convert a psaddr_t to a CORE_ADDR. */ @@ -267,7 +262,7 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_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); @@ -286,7 +281,7 @@ ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prgregset_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 ()); supply_gregset (regcache, (const gdb_gregset_t *) gregset); @@ -306,7 +301,7 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, 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); @@ -326,7 +321,7 @@ ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, 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); diff --git a/gdb/procfs.c b/gdb/procfs.c index 20da81a..97bb86c 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -2569,17 +2569,17 @@ procfs_find_LDT_entry (ptid_t ptid) 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. */ @@ -3074,7 +3074,7 @@ static void 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); @@ -3107,14 +3107,14 @@ do_attach (ptid_t ptid) 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); } @@ -3163,7 +3163,7 @@ do_attach (ptid_t ptid) 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; @@ -3175,7 +3175,8 @@ do_detach (int signo) 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__); @@ -3233,8 +3234,8 @@ procfs_fetch_registers (struct target_ops *ops, { 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); @@ -3282,8 +3283,8 @@ procfs_store_registers (struct target_ops *ops, { 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); @@ -3584,7 +3585,7 @@ wait_again: 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... */ @@ -3610,10 +3611,11 @@ wait_again: /* /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); @@ -3657,7 +3659,7 @@ wait_again: /* 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: @@ -3793,7 +3795,7 @@ wait_again: 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); @@ -3863,7 +3865,7 @@ wait_again: 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); @@ -3942,7 +3944,7 @@ wait_again: } /* 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)) { @@ -3950,8 +3952,10 @@ wait_again: 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. */ @@ -4023,7 +4027,7 @@ procfs_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int dowrite, 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) { @@ -4166,7 +4170,7 @@ procfs_resume (struct target_ops *ops, 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; @@ -4186,11 +4190,11 @@ procfs_resume (struct target_ops *ops, /* 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) @@ -4228,7 +4232,7 @@ static void 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); @@ -4335,7 +4339,7 @@ procfs_kill_inferior (struct target_ops *ops) 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); @@ -4353,7 +4357,7 @@ procfs_mourn_inferior (struct target_ops *ops) 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); } @@ -4445,7 +4449,7 @@ procfs_init_inferior (struct target_ops *ops, int pid) 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". */ @@ -4698,8 +4702,8 @@ procfs_inferior_created (struct target_ops *ops, int from_tty) 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 } @@ -4708,7 +4712,7 @@ procfs_inferior_created (struct target_ops *ops, int from_tty) 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); @@ -4725,7 +4729,7 @@ procfs_find_new_threads (struct target_ops *ops) 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); } @@ -4740,8 +4744,8 @@ procfs_thread_alive (struct target_ops *ops, ptid_t ptid) 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; @@ -4766,10 +4770,10 @@ procfs_pid_to_str (struct target_ops *ops, ptid_t ptid) { 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; } @@ -4784,8 +4788,9 @@ procfs_set_watchpoint (ptid_t ptid, CORE_ADDR addr, int len, int rwflag, 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. */ @@ -4862,7 +4867,7 @@ procfs_stopped_by_watchpoint (void) { 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)) { @@ -4892,7 +4897,7 @@ procfs_stopped_data_address (struct target_ops *targ, CORE_ADDR *addr) { 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); } @@ -5053,7 +5058,7 @@ find_memory_regions_callback (struct prmap *map, 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); @@ -5197,7 +5202,7 @@ procfs_info_proc (struct target_ops *ops, char *args, 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 @@ -5289,13 +5294,13 @@ proc_trace_syscalls (char *args, int from_tty, int entry_or_exit, int mode) { 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); @@ -5380,7 +5385,7 @@ procfs_do_thread_registers (bfd *obfd, ptid_t ptid, 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 @@ -5433,7 +5438,7 @@ procfs_corefile_thread_callback (procinfo *pi, procinfo *thread, void *data) 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, @@ -5473,7 +5478,7 @@ procfs_make_note_section (bfd *obfd, int *note_size) 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; @@ -5510,7 +5515,7 @@ procfs_make_note_section (bfd *obfd, int *note_size) #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 diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index 26ee004..ed49290 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -210,7 +210,7 @@ find_thread_object (ptid_t ptid) PyObject *inf_obj; thread_object *found = NULL; - pid = PIDGET (ptid); + pid = ptid_get_pid (ptid); if (pid == 0) return NULL; @@ -280,7 +280,8 @@ delete_thread_object (struct thread_info *tp, int ignore) 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); diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c index d46f573..053995f 100644 --- a/gdb/python/py-infthread.c +++ b/gdb/python/py-infthread.c @@ -49,7 +49,7 @@ create_thread_object (struct thread_info *tp) 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; } diff --git a/gdb/record.c b/gdb/record.c index 07b1b97..4078def 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -300,7 +300,7 @@ cmd_record_save (char *args, int from_tty) { /* 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; } diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c index 374976e..fc9889c 100644 --- a/gdb/rs6000-nat.c +++ b/gdb/rs6000-nat.c @@ -180,7 +180,7 @@ fetch_register (struct regcache *regcache, int regno) /* 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) @@ -196,14 +196,15 @@ fetch_register (struct regcache *regcache, int regno) 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 @@ -242,7 +243,7 @@ store_register (struct regcache *regcache, int regno) /* 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) @@ -268,7 +269,7 @@ store_register (struct regcache *regcache, int regno) 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 { @@ -279,7 +280,8 @@ store_register (struct regcache *regcache, int regno) 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); } } @@ -566,9 +568,10 @@ exec_one_dummy_insn (struct regcache *regcache) 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) @@ -576,9 +579,9 @@ exec_one_dummy_insn (struct regcache *regcache) 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); diff --git a/gdb/s390-nat.c b/gdb/s390-nat.c index d16ae0c..19bc607 100644 --- a/gdb/s390-nat.c +++ b/gdb/s390-nat.c @@ -217,9 +217,9 @@ static int 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; } @@ -474,9 +474,9 @@ s390_fix_watch_points (struct lwp_info *lp) 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) { diff --git a/gdb/shnbsd-nat.c b/gdb/shnbsd-nat.c index 933b08d..fda8536 100644 --- a/gdb/shnbsd-nat.c +++ b/gdb/shnbsd-nat.c @@ -49,7 +49,7 @@ shnbsd_fetch_inferior_registers (struct target_ops *ops, { 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")); @@ -70,7 +70,7 @@ shnbsd_store_inferior_registers (struct target_ops *ops, { 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")); @@ -78,7 +78,7 @@ shnbsd_store_inferior_registers (struct target_ops *ops, (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")); diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index c9abaf7..4a0de1f 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -96,16 +96,6 @@ static void init_sol_thread_ops (void); /* 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); @@ -248,12 +238,12 @@ thread_to_lwp (ptid_t thread_id, int default_lwp) 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) @@ -273,7 +263,7 @@ thread_to_lwp (ptid_t thread_id, int default_lwp) 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 @@ -288,7 +278,7 @@ lwp_to_thread (ptid_t lwp) 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. */ @@ -296,7 +286,7 @@ lwp_to_thread (ptid_t lwp) 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) @@ -314,7 +304,7 @@ lwp_to_thread (ptid_t lwp) 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); } @@ -335,7 +325,7 @@ sol_thread_detach (struct target_ops *ops, char *args, int from_tty) 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); } @@ -354,20 +344,20 @@ sol_thread_resume (struct target_ops *ops, 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); @@ -390,20 +380,20 @@ sol_thread_wait (struct target_ops *ops, 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); @@ -412,11 +402,11 @@ sol_thread_wait (struct target_ops *ops, { /* 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))) @@ -445,7 +435,7 @@ sol_thread_fetch_registers (struct target_ops *ops, 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); @@ -453,7 +443,7 @@ sol_thread_fetch_registers (struct target_ops *ops, } /* 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")); @@ -497,7 +487,7 @@ sol_thread_store_registers (struct target_ops *ops, 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); @@ -507,7 +497,7 @@ sol_thread_store_registers (struct target_ops *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) @@ -564,7 +554,7 @@ sol_thread_xfer_partial (struct target_ops *ops, enum target_object object, 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. @@ -625,7 +615,7 @@ check_for_thread_db (void) 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 (); @@ -670,14 +660,14 @@ sol_thread_mourn_inferior (struct target_ops *ops) 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) @@ -789,7 +779,7 @@ rw_common (int dowrite, const struct ps_prochandle *ph, gdb_ps_addr_t addr, 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. @@ -862,7 +852,7 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_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); @@ -884,7 +874,7 @@ ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, 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); @@ -942,7 +932,7 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, 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); @@ -964,7 +954,7 @@ ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, 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); @@ -1011,10 +1001,11 @@ ps_lgetLDT (gdb_ps_prochandle_t ph, lwpid_t lwpid, /* 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)); @@ -1034,25 +1025,26 @@ solaris_pid_to_str (struct target_ops *ops, ptid_t ptid) { 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; } @@ -1072,7 +1064,7 @@ sol_find_new_threads_callback (const td_thrhandle_t *th, void *ignored) 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); diff --git a/gdb/solib-som.c b/gdb/solib-som.c index 98b32db..fd0ff81 100644 --- a/gdb/solib-som.c +++ b/gdb/solib-som.c @@ -220,7 +220,7 @@ som_solib_create_inferior_hook (int from_tty) 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) { diff --git a/gdb/sparc-nat.c b/gdb/sparc-nat.c index a562a6f..bb2b8a3 100644 --- a/gdb/sparc-nat.c +++ b/gdb/sparc-nat.c @@ -155,9 +155,9 @@ sparc_fetch_inferior_registers (struct target_ops *ops, 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) { @@ -199,9 +199,9 @@ sparc_store_inferior_registers (struct target_ops *ops, /* 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)) { @@ -282,9 +282,9 @@ sparc_xfer_wcookie (struct target_ops *ops, enum target_object object, { 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 diff --git a/gdb/spu-linux-nat.c b/gdb/spu-linux-nat.c index 9855bac..a456117 100644 --- a/gdb/spu-linux-nat.c +++ b/gdb/spu-linux-nat.c @@ -48,9 +48,9 @@ fetch_ppc_register (int regno) { 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 @@ -133,9 +133,9 @@ fetch_ppc_memory (ULONGEST memaddr, gdb_byte *myaddr, int len) / 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)) @@ -163,9 +163,9 @@ store_ppc_memory (ULONGEST memaddr, const gdb_byte *myaddr, int len) / 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)); @@ -236,7 +236,7 @@ spu_proc_xfer_spu (const char *annex, gdb_byte *readbuf, 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; @@ -394,9 +394,9 @@ spu_child_post_startup_inferior (ptid_t ptid) 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)) { @@ -443,16 +443,17 @@ spu_child_wait (struct target_ops *ops, 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; diff --git a/gdb/target.c b/gdb/target.c index 5ab328c..559ae0c 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -2615,7 +2615,7 @@ target_detach (char *args, int from_tty) 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 (); @@ -2678,8 +2678,8 @@ target_wait (ptid_t ptid, struct target_waitstatus *status, int options) 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); } @@ -2733,7 +2733,7 @@ target_resume (ptid_t ptid, int step, enum gdb_signal signal) 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)); @@ -3823,7 +3823,7 @@ target_thread_alive (ptid_t ptid) 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; } @@ -4010,7 +4010,7 @@ target_core_of_thread (ptid_t ptid) if (targetdebug) fprintf_unfiltered (gdb_stdlog, "target_core_of_thread (%d) = %d\n", - PIDGET (ptid), retval); + ptid_get_pid (ptid), retval); return retval; } } @@ -4749,7 +4749,7 @@ debug_to_post_startup_inferior (ptid_t ptid) 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 diff --git a/gdb/thread.c b/gdb/thread.c index 498e547..64a57c5 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -810,7 +810,7 @@ print_thread_info (struct ui_out *uiout, char *requested_threads, int pid) 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) @@ -847,7 +847,7 @@ print_thread_info (struct ui_out *uiout, char *requested_threads, int pid) 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")); diff --git a/gdb/vax-nat.c b/gdb/vax-nat.c index 884fddd..7025afe 100644 --- a/gdb/vax-nat.c +++ b/gdb/vax-nat.c @@ -74,7 +74,7 @@ vax_register_u_offset (struct gdbarch *gdbarch, int regnum, int store_p) 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")); diff --git a/gdb/vaxbsd-nat.c b/gdb/vaxbsd-nat.c index 9a41260..a88b8dc 100644 --- a/gdb/vaxbsd-nat.c +++ b/gdb/vaxbsd-nat.c @@ -68,7 +68,7 @@ vaxbsd_fetch_inferior_registers (struct target_ops *ops, { 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")); @@ -84,13 +84,13 @@ vaxbsd_store_inferior_registers (struct target_ops *ops, { 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")); } diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 47594f1..24b97ab 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -2388,7 +2388,7 @@ static void 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. */ diff --git a/gdb/xtensa-linux-nat.c b/gdb/xtensa-linux-nat.c index 3fdaa37..3934165 100644 --- a/gdb/xtensa-linux-nat.c +++ b/gdb/xtensa-linux-nat.c @@ -48,9 +48,9 @@ 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) |