Reduce use of curproc in several places:

- Change ktrace interface to pass in the current process, rather than
p->p_tracep, since the various ktr* function need curproc anyway.

 - Add curproc as a parameter to mi_switch() since all callers had it
handy anyway.

 - Add a second proc argument for inferior() since callers all had
curproc handy.

Also, miscellaneous cleanups in ktrace:

 - ktrace now always uses file-based, rather than vnode-based I/O
(simplifies, increases type safety); eliminate KTRFLAG_FD & KTRFAC_FD.
Do non-blocking I/O, and yield a finite number of times when receiving
EWOULDBLOCK before giving up.

 - move code duplicated between sys_fktrace and sys_ktrace into ktrace_common.

 - simplify interface to ktrwrite()
This commit is contained in:
sommerfeld 2000-05-27 00:40:29 +00:00
parent 29f616cebe
commit 40339b39f9
35 changed files with 303 additions and 341 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.53 2000/05/26 21:19:23 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.54 2000/05/27 00:40:29 sommerfeld Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -101,7 +101,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.53 2000/05/26 21:19:23 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.54 2000/05/27 00:40:29 sommerfeld Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -678,7 +678,7 @@ syscall(code, framep)
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, callp->sy_argsize, args + hidden);
ktrsyscall(p, code, callp->sy_argsize, args + hidden);
#endif
#ifdef SYSCALL_DEBUG
scdebug_call(p, code, args + hidden);
@ -720,7 +720,7 @@ syscall(code, framep)
userret(p, framep->tf_regs[FRAME_PC], sticks);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
@ -740,7 +740,7 @@ child_return(arg)
userret(p, p->p_md.md_tf->tf_regs[FRAME_PC], 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.74 2000/05/26 21:19:26 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.75 2000/05/27 00:40:30 sommerfeld Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -892,7 +892,7 @@ syscall(code, frame)
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, argsize, args);
ktrsyscall(p, code, argsize, args);
#endif
if (error)
goto bad;
@ -938,7 +938,7 @@ syscall(code, frame)
userret(p, frame.f_pc, sticks);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
@ -959,7 +959,7 @@ child_return(arg)
userret(p, f->f_pc, p->p_sticks);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: except.c,v 1.4 2000/05/26 21:19:30 thorpej Exp $ */
/* $NetBSD: except.c,v 1.5 2000/05/27 00:40:31 sommerfeld Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 Ben Harris
* All rights reserved.
@ -32,7 +32,7 @@
#include <sys/param.h>
__KERNEL_RCSID(0, "$NetBSD: except.c,v 1.4 2000/05/26 21:19:30 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: except.c,v 1.5 2000/05/27 00:40:31 sommerfeld Exp $");
#include "opt_cputypes.h"
#include "opt_ddb.h"
@ -254,7 +254,7 @@ swi_handler(struct trapframe *tf)
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, argsize, args);
ktrsyscall(p, code, argsize, args);
#endif
rval[0] = 0;
@ -290,7 +290,7 @@ swi_handler(struct trapframe *tf)
userret(p, pc, sticks);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
@ -315,7 +315,7 @@ child_return(void* ignore)
userret(p, tf->tf_r15 & R15_PC, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork /* XXX */, 0, &tf->tf_r0);
ktrsysret(p, SYS_fork /* XXX */, 0, &tf->tf_r0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: syscall.c,v 1.26 2000/03/13 23:52:27 soren Exp $ */
/* $NetBSD: syscall.c,v 1.27 2000/05/27 00:40:31 sommerfeld Exp $ */
/*
* Copyright (c) 1994-1998 Mark Brinicombe.
@ -300,7 +300,7 @@ syscall(frame, code)
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, argsize, args);
ktrsyscall(p, code, argsize, args);
#endif
rval[0] = 0;
rval[1] = frame->tf_r1;
@ -349,7 +349,7 @@ bad:
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
@ -369,7 +369,7 @@ child_return(arg)
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.50 2000/05/26 21:19:34 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.51 2000/05/27 00:40:32 sommerfeld Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -1128,7 +1128,7 @@ syscall(code, frame)
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, argsize, args);
ktrsyscall(p, code, argsize, args);
#endif
if (error)
goto bad;
@ -1176,7 +1176,7 @@ syscall(code, frame)
userret(p, &frame, sticks, (u_int)0, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
/*
@ -1197,6 +1197,6 @@ child_return(arg)
userret(p, f, 0, (u_int)0, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.77 2000/05/26 21:19:42 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.78 2000/05/27 00:40:32 sommerfeld Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -1124,7 +1124,7 @@ syscall(code, frame)
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, argsize, args);
ktrsyscall(p, code, argsize, args);
#endif
if (error)
goto bad;
@ -1167,7 +1167,7 @@ syscall(code, frame)
userret(p, &frame, sticks, (u_int)0, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
@ -1186,6 +1186,6 @@ child_return(arg)
userret(p, f, 0, (u_int)0, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.137 2000/05/26 21:19:47 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.138 2000/05/27 00:40:33 sommerfeld Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -759,7 +759,7 @@ syscall(frame)
#endif /* SYSCALL_DEBUG */
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, argsize, args);
ktrsyscall(p, code, argsize, args);
#endif /* KTRACE */
rval[0] = 0;
rval[1] = frame.tf_edx;
@ -804,7 +804,7 @@ syscall(frame)
userret(p, frame.tf_eip, sticks);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif /* KTRACE */
}
@ -821,6 +821,6 @@ child_return(arg)
userret(p, tf->tf_eip, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.5 2000/05/26 21:19:49 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.6 2000/05/27 00:40:34 sommerfeld Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -44,7 +44,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.5 2000/05/26 21:19:49 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.6 2000/05/27 00:40:34 sommerfeld Exp $");
#include "opt_ddb.h"
#include "opt_execfmt.h"
@ -1000,7 +1000,7 @@ syscall(code, frame)
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, argsize, args);
ktrsyscall(p, code, argsize, args);
#endif
if (error)
goto bad;
@ -1043,7 +1043,7 @@ syscall(code, frame)
userret(p, &frame, sticks, (u_int)0, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
@ -1062,6 +1062,6 @@ child_return(arg)
userret(p, f, 0, (u_int)0, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.80 2000/05/26 21:19:52 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.81 2000/05/27 00:40:34 sommerfeld Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -1097,7 +1097,7 @@ syscall(code, frame)
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, argsize, args);
ktrsyscall(p, code, argsize, args);
#endif
if (error)
goto bad;
@ -1140,7 +1140,7 @@ syscall(code, frame)
userret(p, &frame, sticks, (u_int)0, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
@ -1162,6 +1162,6 @@ child_return(arg)
userret(p, f, 0, (u_int)0, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.131 2000/05/26 21:19:56 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.132 2000/05/27 00:40:35 sommerfeld Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -44,7 +44,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.131 2000/05/26 21:19:56 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.132 2000/05/27 00:40:35 sommerfeld Exp $");
#include "opt_cputype.h" /* which mips CPU levels do we support? */
#include "opt_inet.h"
@ -306,7 +306,7 @@ syscall(status, cause, opc)
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, callp->sy_argsize, args);
ktrsyscall(p, code, callp->sy_argsize, args);
#endif
rval[0] = 0;
rval[1] = frame->f_regs[V1];
@ -341,7 +341,7 @@ syscall(status, cause, opc)
userret(p, opc, sticks);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
@ -362,7 +362,7 @@ child_return(arg)
userret(p, frame->f_regs[PC] - sizeof(int), 0); /* XXX */
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.38 2000/05/26 21:20:00 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.39 2000/05/27 00:40:36 sommerfeld Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -1126,7 +1126,7 @@ syscall(code, frame)
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, argsize, args);
ktrsyscall(p, code, argsize, args);
#endif
if (error)
goto bad;
@ -1169,7 +1169,7 @@ syscall(code, frame)
userret(p, &frame, sticks, (u_int)0, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
@ -1188,7 +1188,7 @@ child_return(arg)
userret(p, f, 0, (u_int)0, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.3 2000/05/26 21:20:01 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.4 2000/05/27 00:40:36 sommerfeld Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -1083,7 +1083,7 @@ syscall(code, frame)
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, argsize, args);
ktrsyscall(p, code, argsize, args);
#endif
if (error)
goto bad;
@ -1126,7 +1126,7 @@ syscall(code, frame)
userret(p, &frame, sticks, (u_int)0, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
@ -1145,7 +1145,7 @@ child_return(arg)
userret(p, f, 0, (u_int)0, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.21 2000/05/26 21:20:04 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.22 2000/05/27 00:40:37 sommerfeld Exp $ */
/*
* This file was taken from mvme68k/mvme68k/trap.c
@ -1132,7 +1132,7 @@ syscall(code, frame)
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, argsize, args);
ktrsyscall(p, code, argsize, args);
#endif
if (error)
goto bad;
@ -1175,7 +1175,7 @@ syscall(code, frame)
userret(p, &frame, sticks, (u_int)0, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
@ -1194,7 +1194,7 @@ child_return(arg)
userret(p, f, 0, (u_int)0, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.39 2000/05/26 21:20:10 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.40 2000/05/27 00:40:37 sommerfeld Exp $ */
/*-
* Copyright (c) 1996 Matthias Pfaller. All rights reserved.
@ -530,7 +530,7 @@ syscall(frame)
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, argsize, args);
ktrsyscall(p, code, argsize, args);
#endif
if (error)
goto bad;
@ -572,7 +572,7 @@ syscall(frame)
userret(p, frame.sf_regs.r_pc, sticks);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
@ -588,6 +588,6 @@ child_return(arg)
userret(p, p->p_md.md_regs->r_pc, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.25 2000/05/26 21:20:12 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.26 2000/05/27 00:40:40 sommerfeld Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -208,8 +208,8 @@ trap(frame)
#ifdef KTRACE
/* Can't get all the arguments! */
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code,
argsize, args);
ktrsyscall(p, code, argsize,
args);
#endif
goto syscall_bad;
}
@ -217,7 +217,7 @@ trap(frame)
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, argsize, params);
ktrsyscall(p, code, argsize, params);
#endif
rval[0] = 0;
rval[1] = frame->fixreg[FIRSTARG + 1];
@ -247,7 +247,7 @@ syscall_bad:
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
break;
@ -365,7 +365,7 @@ child_return(arg)
tf->srr1 &= ~PSL_FP; /* Disable FPU, as we can't be fpuproc */
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
/* Profiling? XXX */
curcpu()->ci_schedstate.spc_curpriority = p->p_priority;

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.11 2000/05/26 21:20:15 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.12 2000/05/27 00:40:40 sommerfeld Exp $ */
/*-
* Copyright (c) 1995 Charles M. Hannum. All rights reserved.
@ -515,7 +515,7 @@ syscall(frame)
//#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, argsize, args);
ktrsyscall(p, code, argsize, args);
#endif
if (error)
goto bad;
@ -561,7 +561,7 @@ syscall(frame)
userret(p, frame->tf_spc, sticks);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
@ -578,7 +578,7 @@ child_return(p, p2, p3, p4, frame)
userret(p, frame.tf_spc, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.90 2000/05/26 21:20:19 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.91 2000/05/27 00:40:41 sommerfeld Exp $ */
/*
* Copyright (c) 1996
@ -1223,7 +1223,7 @@ syscall(code, tf, pc)
if (error) {
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code,
ktrsyscall(p, code,
callp->sy_argsize, args.i);
#endif
goto bad;
@ -1234,7 +1234,7 @@ syscall(code, tf, pc)
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, callp->sy_argsize, args.i);
ktrsyscall(p, code, callp->sy_argsize, args.i);
#endif
rval[0] = 0;
rval[1] = tf->tf_out[1];
@ -1281,7 +1281,7 @@ syscall(code, tf, pc)
userret(p, pc, sticks);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
share_fpu(p, tf);
}
@ -1301,7 +1301,7 @@ child_return(arg)
userret(p, p->p_md.md_tf->tf_pc, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep,
ktrsysret(p,
(p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.40 2000/05/26 21:20:22 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.41 2000/05/27 00:40:41 sommerfeld Exp $ */
/*
* Copyright (c) 1996
@ -1939,7 +1939,7 @@ syscall(code, tf, pc)
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code,
ktrsyscall(p, code,
callp->sy_argsize, (register_t*)args.l);
#endif
if (error) goto bad;
@ -2008,10 +2008,10 @@ syscall(code, tf, pc)
sizeof(register32_t);
for (j=0; j<i; j++)
temp[j] = args.i[j];
ktrsyscall(p->p_tracep, code,
ktrsyscall(p, code,
i * sizeof(register_t), (register_t *)temp);
#else
ktrsyscall(p->p_tracep, code,
ktrsyscall(p, code,
callp->sy_argsize, (register_t *)args.i);
#endif
}
@ -2117,7 +2117,7 @@ syscall(code, tf, pc)
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
share_fpu(p, tf);
#ifdef DEBUG
@ -2150,7 +2150,7 @@ child_return(arg)
userret(p, p->p_md.md_tf->tf_pc, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep,
ktrsysret(p,
(p->p_flag & P_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.89 2000/05/26 21:20:24 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.90 2000/05/27 00:40:42 sommerfeld Exp $ */
/*
* Copyright (c) 1994 Gordon W. Ross
@ -729,7 +729,7 @@ syscall(code, tf)
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, argsize, args);
ktrsyscall(p, code, argsize, args);
#endif
if (error)
goto bad;
@ -775,7 +775,7 @@ syscall(code, tf)
userret(p, &tf, sticks);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
@ -802,7 +802,7 @@ child_return(arg)
userret(p, tf, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.51 2000/05/26 21:20:27 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.52 2000/05/27 00:40:43 sommerfeld Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@ -373,7 +373,7 @@ if(startsysc)printf("trap syscall %s pc %lx, psl %lx, sp %lx, pid %d, frame %p\n
if (err) {
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, frame->code,
ktrsyscall(p, frame->code,
callp->sy_argsize, args);
#endif
goto bad;
@ -381,7 +381,7 @@ if(startsysc)printf("trap syscall %s pc %lx, psl %lx, sp %lx, pid %d, frame %p\n
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, frame->code, callp->sy_argsize, args);
ktrsyscall(p, frame->code, callp->sy_argsize, args);
#endif
err = (*callp->sy_call)(curproc, args, rval);
exptr = curproc->p_addr->u_pcb.framep;
@ -418,6 +418,6 @@ bad:
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, frame->code, err, rval[0]);
ktrsysret(p, frame->code, err, rval[0]);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.39 2000/05/26 21:20:29 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.40 2000/05/27 00:40:43 sommerfeld Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -1173,7 +1173,7 @@ syscall(code, frame)
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code, argsize, args);
ktrsyscall(p, code, argsize, args);
#endif
if (error)
goto bad;
@ -1216,7 +1216,7 @@ syscall(code, frame)
userret(p, &frame, sticks, (u_int)0, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, code, error, rval[0]);
ktrsysret(p, code, error, rval[0]);
#endif
}
@ -1235,6 +1235,6 @@ child_return(arg)
userret(p, f, 0, (u_int)0, 0);
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSRET))
ktrsysret(p->p_tracep, SYS_fork, 0, 0);
ktrsysret(p, SYS_fork, 0, 0);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: hpux_compat.c,v 1.48 2000/03/28 23:57:32 simonb Exp $ */
/* $NetBSD: hpux_compat.c,v 1.49 2000/05/27 00:40:44 sommerfeld Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -900,7 +900,7 @@ hpux_sys_getpgrp2(cp, v, retval)
if (p == 0)
return (ESRCH);
if (cp->p_ucred->cr_uid && p->p_ucred->cr_uid != cp->p_ucred->cr_uid &&
!inferior(p))
!inferior(p, cp))
return (EPERM);
*retval = p->p_pgid;
return (0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: hpux_net.c,v 1.18 1999/06/13 21:34:32 oster Exp $ */
/* $NetBSD: hpux_net.c,v 1.19 2000/05/27 00:40:44 sommerfeld Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -160,7 +160,7 @@ hpux_sys_netioctl(p, v, retval)
(error = copyin((caddr_t)args, (caddr_t)uap, (u_int)i))) {
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code + MINBSDIPCCODE,
ktrsyscall(p, code + MINBSDIPCCODE,
hpuxtobsdipc[code].nargs,
(register_t *)uap);
#endif
@ -168,7 +168,7 @@ hpux_sys_netioctl(p, v, retval)
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
ktrsyscall(p->p_tracep, code + MINBSDIPCCODE,
ktrsyscall(p, code + MINBSDIPCCODE,
hpuxtobsdipc[code].nargs,
(register_t *)uap);
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_netbsd.c,v 1.25 2000/03/30 11:27:18 augustss Exp $ */
/* $NetBSD: netbsd32_netbsd.c,v 1.26 2000/05/27 00:40:44 sommerfeld Exp $ */
/*
* Copyright (c) 1998 Matthew R. Green
@ -1179,8 +1179,8 @@ recvit32(p, s, mp, iov, namelenp, retsize)
#ifdef KTRACE
if (ktriov != NULL) {
if (error == 0)
ktrgenio(p->p_tracep, s, UIO_READ,
ktriov, len - auio.uio_resid, error);
ktrgenio(p, s, UIO_READ, ktriov,
len - auio.uio_resid, error);
FREE(ktriov, M_TEMP);
}
#endif
@ -2031,7 +2031,7 @@ netbsd32_execve(p, v, retval)
#ifdef KTRACE
if (KTRPOINT(p, KTR_EMUL))
ktremul(p->p_tracep, p, p->p_emul->e_name);
ktremul(p);
#endif
return (EJUSTRETURN);
@ -2998,7 +2998,7 @@ dofilereadv32(p, fd, fp, iovp, iovcnt, offset, flags, retval)
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO))
if (error == 0) {
ktrgenio(p->p_tracep, fd, UIO_READ, ktriov, cnt,
ktrgenio(p, fd, UIO_READ, ktriov, cnt,
error);
FREE(ktriov, M_TEMP);
}
@ -3113,7 +3113,7 @@ dofilewritev32(p, fd, fp, iovp, iovcnt, offset, flags, retval)
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO))
if (error == 0) {
ktrgenio(p->p_tracep, fd, UIO_WRITE, ktriov, cnt,
ktrgenio(p, fd, UIO_WRITE, ktriov, cnt,
error);
FREE(ktriov, M_TEMP);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_exec.c,v 1.109 2000/05/26 02:24:37 simonb Exp $ */
/* $NetBSD: kern_exec.c,v 1.110 2000/05/27 00:40:45 sommerfeld Exp $ */
/*-
* Copyright (C) 1993, 1994, 1996 Christopher G. Demetriou
@ -499,7 +499,7 @@ sys_execve(p, v, retval)
#ifdef KTRACE
if (KTRPOINT(p, KTR_EMUL))
ktremul(p->p_tracep, p, p->p_emul->e_name);
ktremul(p);
#endif
return (EJUSTRETURN);

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_ktrace.c,v 1.41 2000/05/26 21:20:30 thorpej Exp $ */
/* $NetBSD: kern_ktrace.c,v 1.42 2000/05/27 00:40:45 sommerfeld Exp $ */
/*
* Copyright (c) 1989, 1993
@ -49,50 +49,40 @@
#include <sys/malloc.h>
#include <sys/syslog.h>
#include <sys/filedesc.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
int ktrace_common __P((struct proc *, int, int, int, struct file *));
void ktrinitheader __P((struct ktr_header *, struct proc *, int));
int ktrops __P((struct proc *, struct proc *, int, int, void *));
int ktrsetchildren __P((struct proc *, struct proc *, int, int, void *));
int ktrwrite __P((struct proc *, void *, struct ktr_header *));
int ktrops __P((struct proc *, struct proc *, int, int, struct file *));
int ktrsetchildren __P((struct proc *, struct proc *, int, int,
struct file *));
int ktrwrite __P((struct proc *, struct ktr_header *));
int ktrcanset __P((struct proc *, struct proc *));
void
ktrderef(p)
struct proc *p;
{
if (p->p_tracep == NULL)
return;
if (p->p_traceflag & KTRFAC_FD) {
struct file *fp = p->p_tracep;
FILE_USE(fp);
closef(fp, NULL);
} else {
struct vnode *vp = p->p_tracep;
vrele(vp);
}
p->p_tracep = NULL;
struct file *fp = p->p_tracep;
p->p_traceflag = 0;
if (fp == NULL)
return;
FILE_USE(fp);
closef(fp, NULL);
p->p_tracep = NULL;
}
void
ktradref(p)
struct proc *p;
{
if (p->p_traceflag & KTRFAC_FD) {
struct file *fp = p->p_tracep;
struct file *fp = p->p_tracep;
fp->f_count++;
} else {
struct vnode *vp = p->p_tracep;
VREF(vp);
}
fp->f_count++;
}
void
@ -110,15 +100,14 @@ ktrinitheader(kth, p, type)
}
void
ktrsyscall(v, code, argsize, args)
void *v;
ktrsyscall(p, code, argsize, args)
struct proc *p;
register_t code;
size_t argsize;
register_t args[];
{
struct ktr_header kth;
struct ktr_syscall *ktp;
struct proc *p = curproc; /* XXX */
register_t *argp;
size_t len = sizeof(struct ktr_syscall) + argsize;
int i;
@ -133,21 +122,20 @@ ktrsyscall(v, code, argsize, args)
*argp++ = args[i];
kth.ktr_buf = (caddr_t)ktp;
kth.ktr_len = len;
(void) ktrwrite(p, v, &kth);
(void) ktrwrite(p, &kth);
free(ktp, M_TEMP);
p->p_traceflag &= ~KTRFAC_ACTIVE;
}
void
ktrsysret(v, code, error, retval)
void *v;
ktrsysret(p, code, error, retval)
struct proc *p;
register_t code;
int error;
register_t retval;
{
struct ktr_header kth;
struct ktr_sysret ktp;
struct proc *p = curproc; /* XXX */
p->p_traceflag |= KTRFAC_ACTIVE;
ktrinitheader(&kth, p, KTR_SYSRET);
@ -159,47 +147,45 @@ ktrsysret(v, code, error, retval)
kth.ktr_buf = (caddr_t)&ktp;
kth.ktr_len = sizeof(struct ktr_sysret);
(void) ktrwrite(p, v, &kth);
(void) ktrwrite(p, &kth);
p->p_traceflag &= ~KTRFAC_ACTIVE;
}
void
ktrnamei(v, path)
void *v;
ktrnamei(p, path)
struct proc *p;
char *path;
{
struct ktr_header kth;
struct proc *p = curproc; /* XXX */
p->p_traceflag |= KTRFAC_ACTIVE;
ktrinitheader(&kth, p, KTR_NAMEI);
kth.ktr_len = strlen(path);
kth.ktr_buf = path;
(void) ktrwrite(p, v, &kth);
(void) ktrwrite(p, &kth);
p->p_traceflag &= ~KTRFAC_ACTIVE;
}
void
ktremul(v, p, emul)
void *v;
ktremul(p)
struct proc *p;
char *emul;
{
struct ktr_header kth;
char *emul = p->p_emul->e_name;
p->p_traceflag |= KTRFAC_ACTIVE;
ktrinitheader(&kth, p, KTR_EMUL);
kth.ktr_len = strlen(emul);
kth.ktr_buf = emul;
(void) ktrwrite(p, v, &kth);
(void) ktrwrite(p, &kth);
p->p_traceflag &= ~KTRFAC_ACTIVE;
}
void
ktrgenio(v, fd, rw, iov, len, error)
void *v;
ktrgenio(p, fd, rw, iov, len, error)
struct proc *p;
int fd;
enum uio_rw rw;
struct iovec *iov;
@ -209,7 +195,6 @@ ktrgenio(v, fd, rw, iov, len, error)
struct ktr_genio *ktp;
caddr_t cp;
int resid = len, cnt;
struct proc *p = curproc; /* XXX */
int buflen;
if (error)
@ -241,7 +226,7 @@ ktrgenio(v, fd, rw, iov, len, error)
kth.ktr_len = cnt + sizeof(struct ktr_genio);
if (__predict_false(ktrwrite(p, v, &kth) != 0))
if (__predict_false(ktrwrite(p, &kth) != 0))
break;
iov->iov_base = (caddr_t)iov->iov_base + cnt;
@ -258,8 +243,8 @@ ktrgenio(v, fd, rw, iov, len, error)
}
void
ktrpsig(v, sig, action, mask, code)
void *v;
ktrpsig(p, sig, action, mask, code)
struct proc *p;
int sig;
sig_t action;
sigset_t *mask;
@ -267,7 +252,6 @@ ktrpsig(v, sig, action, mask, code)
{
struct ktr_header kth;
struct ktr_psig kp;
struct proc *p = curproc; /* XXX */
p->p_traceflag |= KTRFAC_ACTIVE;
ktrinitheader(&kth, p, KTR_PSIG);
@ -278,18 +262,17 @@ ktrpsig(v, sig, action, mask, code)
kth.ktr_buf = (caddr_t)&kp;
kth.ktr_len = sizeof(struct ktr_psig);
(void) ktrwrite(p, v, &kth);
(void) ktrwrite(p, &kth);
p->p_traceflag &= ~KTRFAC_ACTIVE;
}
void
ktrcsw(v, out, user)
void *v;
ktrcsw(p, out, user)
struct proc *p;
int out, user;
{
struct ktr_header kth;
struct ktr_csw kc;
struct proc *p = curproc; /* XXX */
p->p_traceflag |= KTRFAC_ACTIVE;
ktrinitheader(&kth, p, KTR_CSW);
@ -298,47 +281,28 @@ ktrcsw(v, out, user)
kth.ktr_buf = (caddr_t)&kc;
kth.ktr_len = sizeof(struct ktr_csw);
(void) ktrwrite(p, v, &kth);
(void) ktrwrite(p, &kth);
p->p_traceflag &= ~KTRFAC_ACTIVE;
}
/* Interface and common routines */
/*
* ktrace system call
*/
/* ARGSUSED */
int
sys_fktrace(curp, v, retval)
ktrace_common (curp, ops, facs, pid, fp)
struct proc *curp;
void *v;
register_t *retval;
int ops, facs, pid;
struct file *fp;
{
struct sys_fktrace_args /* {
syscallarg(int) fd;
syscallarg(int) ops;
syscallarg(int) facs;
syscallarg(int) pid;
} */ *uap = v;
struct file *fp = NULL;
struct proc *p;
struct filedesc *fdp = curp->p_fd;
struct pgrp *pg;
int facs;
int ops;
int descend;
int ret = 0;
int error = 0;
int one = 1;
int descend;
struct proc *p;
struct pgrp *pg;
if (((u_int)SCARG(uap, fd)) >= fdp->fd_nfiles ||
(fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL ||
(fp->f_flag & FWRITE) == 0)
return (EBADF);
ops = KTROP(SCARG(uap, ops)) | KTRFLAG_FD;
descend = SCARG(uap, ops) & KTRFLAG_DESCEND;
facs = SCARG(uap, facs) & ~((unsigned) KTRFAC_ROOT);
curp->p_traceflag |= KTRFAC_ACTIVE;
descend = ops & KTRFLAG_DESCEND;
facs = facs & ~((unsigned) KTRFAC_ROOT);
/*
* Clear all uses of the tracefile
@ -357,6 +321,15 @@ sys_fktrace(curp, v, retval)
proclist_unlock_read();
goto done;
}
/*
* Mark fp non-blocking, to avoid problems from possible deadlocks.
*/
fp->f_flag |= FNONBLOCK;
(*fp->f_ops->fo_ioctl)(fp, FIONBIO, (caddr_t)&one, curp);
/*
* need something to (un)trace (XXX - why is this here?)
*/
@ -367,11 +340,11 @@ sys_fktrace(curp, v, retval)
/*
* do it
*/
if (SCARG(uap, pid) < 0) {
if (pid < 0) {
/*
* by process group
*/
pg = pgfind(-SCARG(uap, pid));
pg = pgfind(-pid);
if (pg == NULL) {
error = ESRCH;
goto done;
@ -388,7 +361,7 @@ sys_fktrace(curp, v, retval)
/*
* by pid
*/
p = pfind(SCARG(uap, pid));
p = pfind(pid);
if (p == NULL) {
error = ESRCH;
goto done;
@ -405,6 +378,34 @@ done:
return (error);
}
/*
* ktrace system call
*/
/* ARGSUSED */
int
sys_fktrace(curp, v, retval)
struct proc *curp;
void *v;
register_t *retval;
{
struct sys_fktrace_args /* {
syscallarg(int) fd;
syscallarg(int) ops;
syscallarg(int) facs;
syscallarg(int) pid;
} */ *uap = v;
struct file *fp = NULL;
struct filedesc *fdp = curp->p_fd;
if (((u_int)SCARG(uap, fd)) >= fdp->fd_nfiles ||
(fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL ||
(fp->f_flag & FWRITE) == 0)
return (EBADF);
return ktrace_common(curp, SCARG(uap, ops),
SCARG(uap, facs), SCARG(uap, pid), fp);
}
/*
* ktrace system call
*/
@ -422,15 +423,14 @@ sys_ktrace(curp, v, retval)
syscallarg(int) pid;
} */ *uap = v;
struct vnode *vp = NULL;
struct proc *p;
struct pgrp *pg;
int facs = SCARG(uap, facs) & ~((unsigned) KTRFAC_ROOT);
int ops = KTROP(SCARG(uap, ops));
int descend = SCARG(uap, ops) & KTRFLAG_DESCEND;
int ret = 0;
struct file *fp = NULL;
int fd;
int ops = SCARG(uap, ops);
int error = 0;
struct nameidata nd;
ops = KTROP(ops) | (ops & KTRFLAG_DESCEND);
curp->p_traceflag |= KTRFAC_ACTIVE;
if (ops != KTROP_CLEAR) {
/*
@ -449,89 +449,54 @@ sys_ktrace(curp, v, retval)
curp->p_traceflag &= ~KTRFAC_ACTIVE;
return (EACCES);
}
}
/*
* Clear all uses of the tracefile
*/
if (KTROP(ops) == KTROP_CLEARFILE) {
proclist_lock_read();
for (p = LIST_FIRST(&allproc); p != NULL;
p = LIST_NEXT(p, p_list)) {
if (p->p_tracep == vp &&
!ktrops(curp, p, KTROP_CLEAR, ~0, vp))
error = EPERM;
}
proclist_unlock_read();
goto done;
}
/*
* need something to (un)trace (XXX - why is this here?)
*/
if (!facs) {
error = EINVAL;
goto done;
}
/*
* do it
*/
if (SCARG(uap, pid) < 0) {
/*
* by process group
* XXX This uses up a file descriptor slot in the
* tracing process for the duration of this syscall.
* This is not expected to be a problem. If
* falloc(NULL, ...) DTRT we could skip that part, but
* that would require changing its interface to allow
* the caller to pass in a ucred..
*
* This will FILE_USE the fp it returns, if any.
* Keep it in use until we return.
*/
pg = pgfind(-SCARG(uap, pid));
if (pg == NULL) {
error = ESRCH;
if ((error = falloc(curp, &fp, &fd)) != 0)
goto done;
}
for (p = LIST_FIRST(&pg->pg_members); p != NULL;
p = LIST_NEXT(p, p_pglist)) {
if (descend)
ret |= ktrsetchildren(curp, p, ops, facs, vp);
else
ret |= ktrops(curp, p, ops, facs, vp);
}
} else {
/*
* by pid
*/
p = pfind(SCARG(uap, pid));
if (p == NULL) {
error = ESRCH;
goto done;
}
if (descend)
ret |= ktrsetchildren(curp, p, ops, facs, vp);
else
ret |= ktrops(curp, p, ops, facs, vp);
fp->f_flag = FWRITE|FAPPEND;
fp->f_type = DTYPE_VNODE;
fp->f_ops = &vnops;
fp->f_data = (caddr_t)vp;
vp = NULL;
}
if (!ret)
error = EPERM;
done:
error = ktrace_common(curp, SCARG(uap, ops), SCARG(uap, facs),
SCARG(uap, pid), fp);
done:
if (vp != NULL)
(void) vn_close(vp, FWRITE, curp->p_ucred, curp);
curp->p_traceflag &= ~KTRFAC_ACTIVE;
if (fp != NULL) {
fdrelease(curp, fd); /* release fd table slot */
FILE_UNUSE(fp, curp); /* release file */
}
return (error);
}
int
ktrops(curp, p, ops, facs, v)
ktrops(curp, p, ops, facs, fp)
struct proc *p, *curp;
int ops, facs;
void *v;
struct file *fp;
{
if (!ktrcanset(curp, p))
return (0);
if (KTROP(ops) == KTROP_SET) {
if (p->p_tracep != v) {
if (p->p_tracep != fp) {
/*
* if trace file already in use, relinquish
*/
ktrderef(p);
if (ops & KTRFLAG_FD)
p->p_traceflag = KTRFAC_FD;
p->p_tracep = v;
p->p_tracep = fp;
ktradref(p);
}
p->p_traceflag |= facs;
@ -550,23 +515,23 @@ ktrops(curp, p, ops, facs, v)
* change/attach request.
*/
if (KTRPOINT(p, KTR_EMUL))
ktremul(p->p_tracep, p, p->p_emul->e_name);
ktremul(p);
return (1);
}
int
ktrsetchildren(curp, top, ops, facs, v)
ktrsetchildren(curp, top, ops, facs, fp)
struct proc *curp, *top;
int ops, facs;
void *v;
struct file *fp;
{
struct proc *p;
int ret = 0;
p = top;
for (;;) {
ret |= ktrops(curp, p, ops, facs, v);
ret |= ktrops(curp, p, ops, facs, fp);
/*
* If this process has children, descend to them next,
* otherwise do any siblings, and if done with this level,
@ -588,17 +553,18 @@ ktrsetchildren(curp, top, ops, facs, v)
}
int
ktrwrite(p, v, kth)
ktrwrite(p, kth)
struct proc *p;
void *v;
struct ktr_header *kth;
{
struct uio auio;
struct iovec aiov[2];
int error;
int error, tries;
struct file *fp = p->p_tracep;
if (v == NULL)
return (0);
if (fp == NULL)
return 0;
auio.uio_iov = &aiov[0];
auio.uio_offset = 0;
auio.uio_segflg = UIO_SYSSPACE;
@ -614,21 +580,19 @@ ktrwrite(p, v, kth)
aiov[1].iov_len = kth->ktr_len;
auio.uio_resid += kth->ktr_len;
}
if (p->p_traceflag & KTRFAC_FD) {
struct file *fp = v;
FILE_USE(fp);
FILE_USE(fp);
tries = 0;
do {
error = (*fp->f_ops->fo_write)(fp, &fp->f_offset, &auio,
fp->f_cred, FOF_UPDATE_OFFSET);
FILE_UNUSE(fp, NULL);
}
else {
struct vnode *vp = v;
tries++;
if (error == EWOULDBLOCK)
yield();
} while ((error == EWOULDBLOCK) && (tries < 3));
FILE_UNUSE(fp, NULL);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_WRITE(vp, &auio, IO_UNIT|IO_APPEND, p->p_ucred);
VOP_UNLOCK(vp, 0);
}
if (__predict_true(error == 0))
return (0);
/*
@ -641,7 +605,7 @@ ktrwrite(p, v, kth)
error);
proclist_lock_read();
for (p = LIST_FIRST(&allproc); p != NULL; p = LIST_NEXT(p, p_list)) {
if (p->p_tracep == v)
if (p->p_tracep == fp)
ktrderef(p);
}
proclist_unlock_read();

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_proc.c,v 1.40 2000/05/08 20:07:37 thorpej Exp $ */
/* $NetBSD: kern_proc.c,v 1.41 2000/05/27 00:40:45 sommerfeld Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -293,14 +293,15 @@ chgproccnt(uid, diff)
}
/*
* Is p an inferior of the current process?
* Is p an inferior of q?
*/
int
inferior(p)
inferior(p, q)
struct proc *p;
struct proc *q;
{
for (; p != curproc; p = p->p_pptr)
for (; p != q; p = p->p_pptr)
if (p->p_pid == 0)
return (0);
return (1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_prot.c,v 1.57 2000/04/21 16:15:39 minoura Exp $ */
/* $NetBSD: kern_prot.c,v 1.58 2000/05/27 00:40:46 sommerfeld Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993
@ -287,7 +287,8 @@ sys_setpgid(curp, v, retval)
return (EINVAL);
if (SCARG(uap, pid) != 0 && SCARG(uap, pid) != curp->p_pid) {
if ((targp = pfind(SCARG(uap, pid))) == 0 || !inferior(targp))
if ((targp = pfind(SCARG(uap, pid))) == 0
|| !inferior(targp, curp))
return (ESRCH);
if (targp->p_session != curp->p_session)
return (EPERM);

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_sig.c,v 1.99 2000/05/26 00:36:52 thorpej Exp $ */
/* $NetBSD: kern_sig.c,v 1.100 2000/05/27 00:40:46 sommerfeld Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
@ -80,7 +80,7 @@
void stop __P((struct proc *p));
void killproc __P((struct proc *, char *));
static int build_corename __P((char *));
static int build_corename __P((struct proc *, char *));
#if COMPAT_NETBSD32
static int coredump32 __P((struct proc *, struct vnode *));
#endif
@ -717,7 +717,7 @@ trapsignal(p, signum, code)
p->p_stats->p_ru.ru_nsignals++;
#ifdef KTRACE
if (KTRPOINT(p, KTR_PSIG))
ktrpsig(p->p_tracep, signum,
ktrpsig(p, signum,
ps->ps_sigact[signum].sa_handler, &p->p_sigmask,
code);
#endif
@ -1029,7 +1029,7 @@ issignal(p)
psignal(p->p_pptr, SIGCHLD);
do {
stop(p);
mi_switch();
mi_switch(p);
} while (!trace_req(p) && p->p_flag & P_TRACED);
/*
@ -1090,7 +1090,7 @@ issignal(p)
if ((p->p_pptr->p_flag & P_NOCLDSTOP) == 0)
psignal(p->p_pptr, SIGCHLD);
stop(p);
mi_switch();
mi_switch(p);
break;
} else if (prop & SA_IGNORE) {
/*
@ -1166,7 +1166,7 @@ postsig(signum)
action = ps->ps_sigact[signum].sa_handler;
#ifdef KTRACE
if (KTRPOINT(p, KTR_PSIG))
ktrpsig(p->p_tracep,
ktrpsig(p,
signum, action, ps->ps_flags & SAS_OLDMASK ?
&ps->ps_oldmask : &p->p_sigmask, 0);
#endif
@ -1324,7 +1324,7 @@ coredump(p)
(vp->v_mount->mnt_flag & MNT_NOCOREDUMP) != 0)
return (EPERM);
error = build_corename(name);
error = build_corename(p, name);
if (error)
return error;
@ -1510,32 +1510,33 @@ sys_nosys(p, v, retval)
}
static int
build_corename(dst)
build_corename(p, dst)
struct proc *p;
char *dst;
{
const char *s;
char *d;
int len, i;
for (s = curproc->p_limit->pl_corename, len = 0, d = dst;
for (s = p->p_limit->pl_corename, len = 0, d = dst;
*s != '\0'; s++) {
if (*s == '%') {
switch (*(s+1)) {
case 'n':
i = snprintf(d,MAXPATHLEN - 1 - len, "%s",
curproc->p_comm);
p->p_comm);
break;
case 'p':
i = snprintf(d, MAXPATHLEN - 1 - len, "%d",
curproc->p_pid);
p->p_pid);
break;
case 'u':
i = snprintf(d, MAXPATHLEN - 1 - len, "%s",
curproc->p_pgrp->pg_session->s_login);
p->p_pgrp->pg_session->s_login);
break;
case 't':
i = snprintf(d, MAXPATHLEN - 1 - len, "%ld",
curproc->p_stats->p_start.tv_sec);
p->p_stats->p_start.tv_sec);
break;
default:
goto copy;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_synch.c,v 1.73 2000/05/26 21:20:31 thorpej Exp $ */
/* $NetBSD: kern_synch.c,v 1.74 2000/05/27 00:40:46 sommerfeld Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@ -369,7 +369,7 @@ tsleep(ident, priority, wmesg, timo)
#ifdef KTRACE
if (KTRPOINT(p, KTR_CSW))
ktrcsw(p->p_tracep, 1, 0);
ktrcsw(p, 1, 0);
#endif
s = splhigh();
@ -418,7 +418,7 @@ tsleep(ident, priority, wmesg, timo)
sig = 0;
p->p_stat = SSLEEP;
p->p_stats->p_ru.ru_nvcsw++;
mi_switch();
mi_switch(p);
#ifdef DDB
/* handy breakpoint location after process "wakes" */
asm(".globl bpendtsleep ; bpendtsleep:");
@ -432,7 +432,7 @@ resume:
if (sig == 0) {
#ifdef KTRACE
if (KTRPOINT(p, KTR_CSW))
ktrcsw(p->p_tracep, 0, 0);
ktrcsw(p, 0, 0);
#endif
return (EWOULDBLOCK);
}
@ -441,7 +441,7 @@ resume:
if (catch && (sig != 0 || (sig = CURSIG(p)) != 0)) {
#ifdef KTRACE
if (KTRPOINT(p, KTR_CSW))
ktrcsw(p->p_tracep, 0, 0);
ktrcsw(p, 0, 0);
#endif
if ((p->p_sigacts->ps_sigact[sig].sa_flags & SA_RESTART) == 0)
return (EINTR);
@ -449,7 +449,7 @@ resume:
}
#ifdef KTRACE
if (KTRPOINT(p, KTR_CSW))
ktrcsw(p->p_tracep, 0, 0);
ktrcsw(p, 0, 0);
#endif
return (0);
}
@ -528,16 +528,16 @@ sleep(ident, priority)
p->p_stats->p_ru.ru_nvcsw++;
#ifdef KTRACE
if (KTRPOINT(p, KTR_CSW))
ktrcsw(p->p_tracep, 1, 0);
ktrcsw(p, 1, 0);
#endif
mi_switch();
mi_switch(p);
#ifdef DDB
/* handy breakpoint location after process "wakes" */
asm(".globl bpendsleep ; bpendsleep:");
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_CSW))
ktrcsw(p->p_tracep, 0, 0);
ktrcsw(p, 0, 0);
#endif
curcpu()->ci_schedstate.spc_curpriority = p->p_usrpri;
splx(s);
@ -703,7 +703,7 @@ yield()
p->p_stat = SRUN;
setrunqueue(p);
p->p_stats->p_ru.ru_nvcsw++;
mi_switch();
mi_switch(p);
splx(s);
}
@ -731,7 +731,7 @@ preempt(newp)
p->p_stat = SRUN;
setrunqueue(p);
p->p_stats->p_ru.ru_nivcsw++;
mi_switch();
mi_switch(p);
splx(s);
}
@ -740,9 +740,9 @@ preempt(newp)
* Must be called at splstatclock() or higher.
*/
void
mi_switch()
mi_switch(p)
struct proc *p;
{
struct proc *p = curproc; /* XXX */
struct schedstate_percpu *spc = &curcpu()->ci_schedstate;
struct rlimit *rlim;
long s, u;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sys_generic.c,v 1.47 2000/03/30 09:27:13 augustss Exp $ */
/* $NetBSD: sys_generic.c,v 1.48 2000/05/27 00:40:47 sommerfeld Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -150,7 +150,7 @@ dofileread(p, fd, fp, buf, nbyte, offset, flags, retval)
cnt -= auio.uio_resid;
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO) && error == 0)
ktrgenio(p->p_tracep, fd, UIO_READ, &ktriov, cnt, error);
ktrgenio(p, fd, UIO_READ, &ktriov, cnt, error);
#endif
*retval = cnt;
out:
@ -268,8 +268,7 @@ dofilereadv(p, fd, fp, iovp, iovcnt, offset, flags, retval)
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO))
if (error == 0) {
ktrgenio(p->p_tracep, fd, UIO_READ, ktriov, cnt,
error);
ktrgenio(p, fd, UIO_READ, ktriov, cnt, error);
FREE(ktriov, M_TEMP);
}
#endif
@ -369,7 +368,7 @@ dofilewrite(p, fd, fp, buf, nbyte, offset, flags, retval)
cnt -= auio.uio_resid;
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO) && error == 0)
ktrgenio(p->p_tracep, fd, UIO_WRITE, &ktriov, cnt, error);
ktrgenio(p, fd, UIO_WRITE, &ktriov, cnt, error);
#endif
*retval = cnt;
out:
@ -488,8 +487,7 @@ dofilewritev(p, fd, fp, iovp, iovcnt, offset, flags, retval)
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO))
if (error == 0) {
ktrgenio(p->p_tracep, fd, UIO_WRITE, ktriov, cnt,
error);
ktrgenio(p, fd, UIO_WRITE, ktriov, cnt, error);
FREE(ktriov, M_TEMP);
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: uipc_syscalls.c,v 1.51 2000/03/30 09:27:14 augustss Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.52 2000/05/27 00:40:47 sommerfeld Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1990, 1993
@ -571,8 +571,7 @@ sendit(p, s, mp, flags, retsize)
#ifdef KTRACE
if (ktriov != NULL) {
if (error == 0)
ktrgenio(p->p_tracep, s, UIO_WRITE,
ktriov, *retsize, error);
ktrgenio(p, s, UIO_WRITE, ktriov, *retsize, error);
FREE(ktriov, M_TEMP);
}
#endif
@ -740,8 +739,8 @@ recvit(p, s, mp, namelenp, retsize)
#ifdef KTRACE
if (ktriov != NULL) {
if (error == 0)
ktrgenio(p->p_tracep, s, UIO_READ,
ktriov, len - auio.uio_resid, error);
ktrgenio(p, s, UIO_READ, ktriov,
len - auio.uio_resid, error);
FREE(ktriov, M_TEMP);
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_lookup.c,v 1.33 2000/03/30 09:27:15 augustss Exp $ */
/* $NetBSD: vfs_lookup.c,v 1.34 2000/05/27 00:40:47 sommerfeld Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -129,7 +129,7 @@ namei(ndp)
#ifdef KTRACE
if (KTRPOINT(cnp->cn_proc, KTR_NAMEI))
ktrnamei(cnp->cn_proc->p_tracep, cnp->cn_pnbuf);
ktrnamei(cnp->cn_proc, cnp->cn_pnbuf);
#endif
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: ktrace.h,v 1.18 1999/08/06 00:11:02 thorpej Exp $ */
/* $NetBSD: ktrace.h,v 1.19 2000/05/27 00:40:48 sommerfeld Exp $ */
/*
* Copyright (c) 1988, 1993
@ -50,7 +50,6 @@
* flags (ORed in with operation)
*/
#define KTRFLAG_DESCEND 4 /* perform op on all children too */
#define KTRFLAG_FD 8 /* flag indicating fd - kernel only */
/*
* ktrace record header
@ -158,7 +157,6 @@ struct ktr_csw {
#define KTRFAC_ROOT 0x80000000 /* root set this trace */
#define KTRFAC_INHERIT 0x40000000 /* pass trace flags to children */
#define KTRFAC_ACTIVE 0x20000000 /* ktrace logging in progress, ignore */
#define KTRFAC_FD 0x10000000 /* vp is a file pointer, not vnode */
#ifndef _KERNEL
@ -171,13 +169,13 @@ __END_DECLS
#else
void ktrcsw __P((void *, int, int));
void ktremul __P((void *, struct proc *, char *));
void ktrgenio __P((void *, int, enum uio_rw, struct iovec *, int, int));
void ktrnamei __P((void *, char *));
void ktrpsig __P((void *, int, sig_t, sigset_t *, int));
void ktrsyscall __P((void *, register_t, size_t, register_t []));
void ktrsysret __P((void *, register_t, int, register_t));
void ktrcsw __P((struct proc *, int, int));
void ktremul __P((struct proc *));
void ktrgenio __P((struct proc *, int, enum uio_rw, struct iovec *, int, int));
void ktrnamei __P((struct proc *, char *));
void ktrpsig __P((struct proc *, int, sig_t, sigset_t *, int));
void ktrsyscall __P((struct proc *, register_t, size_t, register_t []));
void ktrsysret __P((struct proc *, register_t, int, register_t));
void ktrderef __P((struct proc *));
void ktradref __P((struct proc *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: proc.h,v 1.93 2000/05/26 21:20:32 thorpej Exp $ */
/* $NetBSD: proc.h,v 1.94 2000/05/27 00:40:48 sommerfeld Exp $ */
/*-
* Copyright (c) 1986, 1989, 1991, 1993
@ -170,7 +170,7 @@ struct proc {
u_quad_t p_iticks; /* Statclock hits processing intr. */
int p_traceflag; /* Kernel trace points. */
void *p_tracep; /* Trace to vnode or file */
struct file *p_tracep; /* Trace to file */
sigset_t p_siglist; /* Signals arrived but not delivered. */
char p_sigcheck; /* May have deliverable signals. */
@ -372,11 +372,11 @@ struct pgrp *pgfind __P((pid_t)); /* Find process group by id. */
int chgproccnt __P((uid_t uid, int diff));
int enterpgrp __P((struct proc *p, pid_t pgid, int mksess));
void fixjobc __P((struct proc *p, struct pgrp *pgrp, int entering));
int inferior __P((struct proc *p));
int inferior __P((struct proc *p, struct proc *q));
int leavepgrp __P((struct proc *p));
void yield __P((void));
void preempt __P((struct proc *));
void mi_switch __P((void));
void mi_switch __P((struct proc *));
void pgdelete __P((struct pgrp *pgrp));
void procinit __P((void));
void remrunqueue __P((struct proc *));