projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix to previous changes
[unix-history]
/
usr
/
src
/
sys
/
kern
/
sys_process.c
diff --git
a/usr/src/sys/kern/sys_process.c
b/usr/src/sys/kern/sys_process.c
index
0913d72
..
bc36b1a
100644
(file)
--- a/
usr/src/sys/kern/sys_process.c
+++ b/
usr/src/sys/kern/sys_process.c
@@
-1,28
+1,27
@@
-/*
- * Copyright (c) 1982 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+/*-
+ * Copyright (c) 1982, 1986, 1989 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.proprietary.c%
*
*
- * @(#)sys_process.c
6.6
(Berkeley) %G%
+ * @(#)sys_process.c
7.22
(Berkeley) %G%
*/
*/
-#include "../machine/reg.h"
-#include "../machine/psl.h"
-#include "../machine/pte.h"
-
+#define IPCREG
#include "param.h"
#include "param.h"
-#include "systm.h"
-#include "dir.h"
-#include "user.h"
#include "proc.h"
#include "proc.h"
-#include "inode.h"
-#include "text.h"
+#include "vnode.h"
#include "seg.h"
#include "seg.h"
-#include "vm.h"
#include "buf.h"
#include "buf.h"
-#include "acct.h"
#include "ptrace.h"
#include "ptrace.h"
+#include "machine/reg.h"
+#include "machine/psl.h"
+#include "vm/vm.h"
+#include "vm/vm_page.h"
+
+#include "user.h"
+
/*
* Priority for tracing
*/
/*
* Priority for tracing
*/
@@
-44,29
+43,28
@@
struct {
} ipc;
/*
} ipc;
/*
- *
sys-trace
system call.
+ *
Process debugging
system call.
*/
*/
-ptrace()
-{
- register struct proc *p;
- register struct a {
+ptrace(curp, uap, retval)
+ struct proc *curp;
+ register struct args {
int req;
int pid;
int *addr;
int data;
} *uap;
int req;
int pid;
int *addr;
int data;
} *uap;
+ int *retval;
+{
+ register struct proc *p;
- uap = (struct a *)u.u_ap;
if (uap->req <= 0) {
if (uap->req <= 0) {
-
u.u_proc
p->p_flag |= STRC;
- return;
+
cur
p->p_flag |= STRC;
+ return
(0)
;
}
p = pfind(uap->pid);
}
p = pfind(uap->pid);
- if (p == 0 || p->p_stat != SSTOP || p->p_ppid != u.u_procp->p_pid ||
- !(p->p_flag & STRC)) {
- u.u_error = ESRCH;
- return;
- }
+ if (p == 0 || p->p_stat != SSTOP || p->p_pptr != curp ||
+ !(p->p_flag & STRC))
+ return (ESRCH);
while (ipc.ip_lock)
sleep((caddr_t)&ipc, IPCPRI);
ipc.ip_lock = p->p_pid;
while (ipc.ip_lock)
sleep((caddr_t)&ipc, IPCPRI);
ipc.ip_lock = p->p_pid;
@@
-79,36
+77,45
@@
ptrace()
setrun(p);
sleep((caddr_t)&ipc, IPCPRI);
}
setrun(p);
sleep((caddr_t)&ipc, IPCPRI);
}
- u.u_r.r_val1 = ipc.ip_data;
- if (ipc.ip_req < 0)
- u.u_error = EIO;
+ *retval = ipc.ip_data;
ipc.ip_lock = 0;
wakeup((caddr_t)&ipc);
ipc.ip_lock = 0;
wakeup((caddr_t)&ipc);
+ if (ipc.ip_req < 0)
+ return (EIO);
+ return (0);
}
}
-#if defined(vax)
-#define NIPCREG 16
-int ipcreg[NIPCREG] =
- {R0,R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,AP,FP,SP,PC};
-#endif
+#define PHYSOFF(p, o) ((caddr_t)(p) + (o))
-#define PHYSOFF(p, o) \
- ((physadr)(p)+((o)/sizeof(((physadr)0)->r[0])))
+#if defined(i386)
+#undef PC
+#undef SP
+#undef PS
+#undef R0
+#undef R1
+
+#define PC tEIP
+#define SP tESP
+#define PS tEFLAGS
+#define R0 tEDX
+#define R1 tECX
+#endif
/*
/*
- *
Code that
the child process
- *
executes to implement the command
- *
of the parent process in tracing
.
+ *
Transmit a tracing request from the parent to
the child process
+ *
being debugged. This code runs in the context of the child process
+ *
to fulfill the command requested by the parent
.
*/
*/
-procxmt()
+procxmt(p)
+ register struct proc *p;
{
{
- register int i;
- register *p;
- register struct text *xp;
+ register int i, *poff;
+ extern char kstack[];
- if (ipc.ip_lock !=
u.u_proc
p->p_pid)
+ if (ipc.ip_lock != p->p_pid)
return (0);
return (0);
- u.u_procp->p_slptime = 0;
+ p->p_slptime = 0;
+ p->p_addr->u_kproc.kp_proc.p_regs = p->p_regs; /* u.u_ar0 */
i = ipc.ip_req;
ipc.ip_req = 0;
switch (i) {
i = ipc.ip_req;
ipc.ip_req = 0;
switch (i) {
@@
-126,33
+133,35
@@
procxmt()
break;
case PT_READ_U: /* read the child's u. */
break;
case PT_READ_U: /* read the child's u. */
+#ifdef HPUXCOMPAT
+ if (p->p_addr->u_pcb.pcb_flags & PCB_HPUXTRACE)
+ i = hpuxtobsduoff(ipc.ip_addr);
+ else
+#endif
i = (int)ipc.ip_addr;
i = (int)ipc.ip_addr;
- if (
i<0 || i >= ctob(UPAGES)
)
+ if (
(u_int) i > ctob(UPAGES)-sizeof(int) || (i & 1) != 0
)
goto error;
goto error;
- ipc.ip_data = *(int *)PHYSOFF(
&u
, i);
+ ipc.ip_data = *(int *)PHYSOFF(
p->p_addr
, i);
break;
case PT_WRITE_I: /* write the child's text space */
break;
case PT_WRITE_I: /* write the child's text space */
- /*
- * If text, must assure exclusive use
- */
- if (xp = u.u_procp->p_textp) {
- if (xp->x_count!=1 || xp->x_iptr->i_mode&ISVTX)
- goto error;
- xp->x_flag |= XTRC;
- }
- i = -1;
if ((i = suiword((caddr_t)ipc.ip_addr, ipc.ip_data)) < 0) {
if ((i = suiword((caddr_t)ipc.ip_addr, ipc.ip_data)) < 0) {
- if (chgprot((caddr_t)ipc.ip_addr, RW) &&
- chgprot((caddr_t)ipc.ip_addr+(sizeof(int)-1), RW))
+ vm_offset_t sa, ea;
+ int rv;
+
+ sa = trunc_page((vm_offset_t)ipc.ip_addr);
+ ea = round_page((vm_offset_t)ipc.ip_addr+sizeof(int)-1);
+ rv = vm_map_protect(&p->p_vmspace->vm_map, sa, ea,
+ VM_PROT_DEFAULT, FALSE);
+ if (rv == KERN_SUCCESS) {
i = suiword((caddr_t)ipc.ip_addr, ipc.ip_data);
i = suiword((caddr_t)ipc.ip_addr, ipc.ip_data);
- (void) chgprot((caddr_t)ipc.ip_addr, RO);
- (void) chgprot((caddr_t)ipc.ip_addr+(sizeof(int)-1), RO);
+ (void) vm_map_protect(&p->p_vmspace->vm_map,
+ sa, ea, VM_PROT_READ|VM_PROT_EXECUTE,
+ FALSE);
+ }
}
if (i < 0)
goto error;
}
if (i < 0)
goto error;
- if (xp)
- xp->x_flag |= XWRIT;
break;
case PT_WRITE_D: /* write the child's data space */
break;
case PT_WRITE_D: /* write the child's data space */
@@
-162,37
+171,53
@@
procxmt()
break;
case PT_WRITE_U: /* write the child's u. */
break;
case PT_WRITE_U: /* write the child's u. */
+#ifdef HPUXCOMPAT
+ if (p->p_addr->u_pcb.pcb_flags & PCB_HPUXTRACE)
+ i = hpuxtobsduoff(ipc.ip_addr);
+ else
+#endif
i = (int)ipc.ip_addr;
i = (int)ipc.ip_addr;
- p
= (int *)PHYSOFF(&u
, i);
+ p
off = (int *)PHYSOFF(kstack
, i);
for (i=0; i<NIPCREG; i++)
for (i=0; i<NIPCREG; i++)
- if (p
== &u.u_ar0
[ipcreg[i]])
+ if (p
off == &p->p_regs
[ipcreg[i]])
goto ok;
goto ok;
- if (p
== &u.u_ar0
[PS]) {
+ if (p
off == &p->p_regs
[PS]) {
ipc.ip_data |= PSL_USERSET;
ipc.ip_data |= PSL_USERSET;
- ipc.ip_data &= ~PSL_USERCLR;
+ ipc.ip_data &= ~PSL_USERCLR;
+#ifdef PSL_CM_CLR
+ if (ipc.ip_data & PSL_CM)
+ ipc.ip_data &= ~PSL_CM_CLR;
+#endif
goto ok;
}
goto ok;
}
+#if defined(hp300)
+#ifdef FPCOPROC
+ if (poff >= (int *)&((struct user *)kstack)->u_pcb.pcb_fpregs.fpf_regs &&
+ poff <= (int *)&((struct user *)kstack)->u_pcb.pcb_fpregs.fpf_fpiar)
+ goto ok;
+#endif
+#endif
goto error;
ok:
goto error;
ok:
- *p = ipc.ip_data;
+ *p
off
= ipc.ip_data;
break;
case PT_STEP: /* single step the child */
case PT_CONTINUE: /* continue the child */
if ((int)ipc.ip_addr != 1)
break;
case PT_STEP: /* single step the child */
case PT_CONTINUE: /* continue the child */
if ((int)ipc.ip_addr != 1)
-
u.u_ar0
[PC] = (int)ipc.ip_addr;
+
p->p_regs
[PC] = (int)ipc.ip_addr;
if ((unsigned)ipc.ip_data > NSIG)
goto error;
if ((unsigned)ipc.ip_data > NSIG)
goto error;
-
u.u_procp->p_cursig = ipc.ip_data;
/* see issig */
+
p->p_xstat = ipc.ip_data;
/* see issig */
if (i == PT_STEP)
if (i == PT_STEP)
-
u.u_ar0
[PS] |= PSL_T;
+
p->p_regs
[PS] |= PSL_T;
wakeup((caddr_t)&ipc);
return (1);
case PT_KILL: /* kill the child process */
wakeup((caddr_t)&ipc);
wakeup((caddr_t)&ipc);
return (1);
case PT_KILL: /* kill the child process */
wakeup((caddr_t)&ipc);
- exit(
u.u_procp->p_cursig
);
+ exit(
p, (int)p->p_xstat
);
default:
error:
default:
error:
@@
-201,3
+226,29
@@
procxmt()
wakeup((caddr_t)&ipc);
return (0);
}
wakeup((caddr_t)&ipc);
return (0);
}
+
+/*
+ * Process debugging system call.
+ */
+/* ARGSUSED */
+profil(p, uap, retval)
+ struct proc *p;
+ register struct args {
+ short *bufbase;
+ unsigned bufsize;
+ unsigned pcoffset;
+ unsigned pcscale;
+ } *uap;
+ int *retval;
+{
+ register struct uprof *upp = &p->p_stats->p_prof;
+
+ upp->pr_base = uap->bufbase;
+ upp->pr_size = uap->bufsize;
+ upp->pr_off = uap->pcoffset;
+ upp->pr_scale = uap->pcscale;
+#ifdef PROFTIMER
+ initprofclock();
+#endif
+ return (0);
+}