might cause problems when calling functions in the inferior.
At least fpu_control and fpa_pcr (probably more) should be added
to the registers array to solve this properly. */
- mptrace (XPT_RREGS, inferior_pid, (PTRACE_ARG3_TYPE) & regs, 0);
+ mptrace (XPT_RREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & regs, 0);
regs.pr_eax = *(int *) ®isters[REGISTER_BYTE (0)];
regs.pr_ebx = *(int *) ®isters[REGISTER_BYTE (5)];
memcpy (regs.pr_fpu.fpu_stack[5], ®isters[REGISTER_BYTE (ST5_REGNUM)], 10);
memcpy (regs.pr_fpu.fpu_stack[6], ®isters[REGISTER_BYTE (ST6_REGNUM)], 10);
memcpy (regs.pr_fpu.fpu_stack[7], ®isters[REGISTER_BYTE (ST7_REGNUM)], 10);
- mptrace (XPT_WREGS, inferior_pid, (PTRACE_ARG3_TYPE) & regs, 0);
+ mptrace (XPT_WREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & regs, 0);
}
void
registers_fetched ();
- mptrace (XPT_RREGS, inferior_pid, (PTRACE_ARG3_TYPE) & regs, 0);
+ mptrace (XPT_RREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & regs, 0);
*(int *) ®isters[REGISTER_BYTE (EAX_REGNUM)] = regs.pr_eax;
*(int *) ®isters[REGISTER_BYTE (EBX_REGNUM)] = regs.pr_ebx;
*(int *) ®isters[REGISTER_BYTE (ECX_REGNUM)] = regs.pr_ecx;
if (have_inferior_p ())
{
- PTRACE_READ_REGS (inferior_pid, (PTRACE_ARG3_TYPE) & regset);
+ PTRACE_READ_REGS (PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & regset);
}
else
{
/*
* Thanks to XPT_MPDEBUGGER, we have to mange child_wait().
*/
-int
-child_wait (int pid, struct target_waitstatus *status)
+ptid_t
+child_wait (ptid_t ptid, struct target_waitstatus *status)
{
int save_errno, rv, xvaloff, saoff, sa_hand;
struct pt_stop pt;
#ifdef SVR4_SHARED_LIBS /* use this to distinguish ptx 2 vs ptx 4 */
prstatus_t pstatus;
#endif
+ int pid = PIDGET (ptid);
do
{
pid = pt.ps_pid;
- if (pid != inferior_pid)
+ if (pid != PIDGET (inferior_ptid))
{
/* NOTE: the mystery fork in csh/tcsh needs to be ignored.
* We should not return new children for the initial run
}
}
- while (pid != inferior_pid); /* Some other child died or stopped */
+ while (pid != PIDGET (inferior_ptid)); /* Some other child died or stopped */
- return pid;
+ return pid_to_ptid (pid);
}
#else /* !ATTACH_DETACH */
/*
* the MPDEBUGGER child_wait() works properly. This will go away when
* that is fixed.
*/
-child_wait (int pid, struct target_waitstatus *ourstatus)
+ptid_t
+child_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
{
int save_errno;
int status;
+ int pid = PIDGET (ptid);
do
{
safe_strerror (save_errno));
ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
- return -1;
+ return pid_to_ptid (-1);
}
}
- while (pid != inferior_pid); /* Some other child died or stopped */
+ while (pid != PIDGET (inferior_ptid)); /* Some other child died or stopped */
store_waitstatus (ourstatus, status);
- return pid;
+ return pid_to_ptid (pid);
}
#endif /* ATTACH_DETACH */
\f
void
kill_inferior (void)
{
- if (inferior_pid == 0)
+ if (ptid_equal (inferior_ptid, null_ptid))
return;
/* For MPDEBUGGER, don't use PT_KILL, since the child will stop
again with a PTS_EXIT. Just hit him with SIGKILL (so he stops)
and detach. */
- kill (inferior_pid, SIGKILL);
+ kill (PIDGET (inferior_ptid), SIGKILL);
#ifdef ATTACH_DETACH
detach (SIGKILL);
#else /* ATTACH_DETACH */
- ptrace (PT_KILL, inferior_pid, 0, 0);
+ ptrace (PT_KILL, PIDGET (inferior_ptid), 0, 0);
wait ((int *) NULL);
#endif /* ATTACH_DETACH */
target_mourn_inferior ();
If SIGNAL is nonzero, give it that signal. */
void
-child_resume (int pid, int step, enum target_signal signal)
+child_resume (ptid_t ptid, int step, enum target_signal signal)
{
+ int pid = PIDGET (ptid);
+
errno = 0;
if (pid == -1)
- pid = inferior_pid;
+ pid = PIDGET (inferior_ptid);
/* An address of (PTRACE_ARG3_TYPE)1 tells ptrace to continue from where
it was. (If GDB wanted it to start some other way, we have already
{
int rv;
- rv = mptrace (XPT_UNDEBUG, inferior_pid, 1, signo);
+ rv = mptrace (XPT_UNDEBUG, PIDGET (inferior_ptid), 1, signo);
if (-1 == rv)
{
error ("mptrace(XPT_UNDEBUG): %s", safe_strerror (errno));
{
register int i;
/* Round starting address down to longword boundary. */
- register CORE_ADDR addr = memaddr & -sizeof (PTRACE_XFER_TYPE);
+ register CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (PTRACE_XFER_TYPE);
/* Round ending address up; get number of longwords that makes. */
register int count
= (((memaddr + len) - addr) + sizeof (PTRACE_XFER_TYPE) - 1)
/ sizeof (PTRACE_XFER_TYPE);
/* Allocate buffer of that many longwords. */
+ /* FIXME (alloca): This code, cloned from infptrace.c, is unsafe
+ because it uses alloca to allocate a buffer of arbitrary size.
+ For very large xfers, this could crash GDB's stack. */
register PTRACE_XFER_TYPE *buffer
- = (PTRACE_XFER_TYPE *) alloca (count * sizeof (PTRACE_XFER_TYPE));
+ = (PTRACE_XFER_TYPE *) alloca (count * sizeof (PTRACE_XFER_TYPE));
if (write)
{
if (addr != memaddr || len < (int) sizeof (PTRACE_XFER_TYPE))
{
/* Need part of initial word -- fetch it. */
- buffer[0] = ptrace (PT_RTEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr,
+ buffer[0] = ptrace (PT_RTEXT, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) addr,
0);
}
if (count > 1) /* FIXME, avoid if even boundary */
{
buffer[count - 1]
- = ptrace (PT_RTEXT, inferior_pid,
+ = ptrace (PT_RTEXT, PIDGET (inferior_ptid),
((PTRACE_ARG3_TYPE)
(addr + (count - 1) * sizeof (PTRACE_XFER_TYPE))),
0);
for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
{
errno = 0;
- ptrace (PT_WDATA, inferior_pid, (PTRACE_ARG3_TYPE) addr,
+ ptrace (PT_WDATA, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) addr,
buffer[i]);
if (errno)
{
/* Using the appropriate one (I or D) is necessary for
Gould NP1, at least. */
errno = 0;
- ptrace (PT_WTEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr,
+ ptrace (PT_WTEXT, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) addr,
buffer[i]);
}
if (errno)
for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
{
errno = 0;
- buffer[i] = ptrace (PT_RTEXT, inferior_pid,
+ buffer[i] = ptrace (PT_RTEXT, PIDGET (inferior_ptid),
(PTRACE_ARG3_TYPE) addr, 0);
if (errno)
return 0;