Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Group more syscall related routines together (kern_...
details: https://anonhg.NetBSD.org/src/rev/e1924ba803a8
branches: trunk
changeset: 325161:e1924ba803a8
user: pooka <pooka%NetBSD.org@localhost>
date: Mon Dec 09 16:49:43 2013 +0000
description:
Group more syscall related routines together (kern_subr -> kern_syscall)
diffstat:
sys/kern/kern_subr.c | 87 +----------------------------------------------
sys/kern/kern_syscall.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 89 insertions(+), 87 deletions(-)
diffs (231 lines):
diff -r 13b2e461f517 -r e1924ba803a8 sys/kern/kern_subr.c
--- a/sys/kern/kern_subr.c Mon Dec 09 16:45:23 2013 +0000
+++ b/sys/kern/kern_subr.c Mon Dec 09 16:49:43 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_subr.c,v 1.213 2012/06/10 17:05:18 mlelstv Exp $ */
+/* $NetBSD: kern_subr.c,v 1.214 2013/12/09 16:49:43 pooka Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@@ -79,13 +79,10 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.213 2012/06/10 17:05:18 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.214 2013/12/09 16:49:43 pooka Exp $");
#include "opt_ddb.h"
#include "opt_md.h"
-#include "opt_syscall_debug.h"
-#include "opt_ktrace.h"
-#include "opt_ptrace.h"
#include "opt_tftproot.h"
#include <sys/param.h>
@@ -98,8 +95,6 @@
#include <sys/disk.h>
#include <sys/disklabel.h>
#include <sys/queue.h>
-#include <sys/ktrace.h>
-#include <sys/ptrace.h>
#include <sys/fcntl.h>
#include <sys/kauth.h>
#include <sys/stat.h>
@@ -656,81 +651,3 @@
*cp = c;
return (dv);
}
-
-/*
- * Return true if system call tracing is enabled for the specified process.
- */
-bool
-trace_is_enabled(struct proc *p)
-{
-#ifdef SYSCALL_DEBUG
- return (true);
-#endif
-#ifdef KTRACE
- if (ISSET(p->p_traceflag, (KTRFAC_SYSCALL | KTRFAC_SYSRET)))
- return (true);
-#endif
-#ifdef PTRACE
- if (ISSET(p->p_slflag, PSL_SYSCALL))
- return (true);
-#endif
-
- return (false);
-}
-
-/*
- * Start trace of particular system call. If process is being traced,
- * this routine is called by MD syscall dispatch code just before
- * a system call is actually executed.
- */
-int
-trace_enter(register_t code, const register_t *args, int narg)
-{
- int error = 0;
-
-#ifdef SYSCALL_DEBUG
- scdebug_call(code, args);
-#endif /* SYSCALL_DEBUG */
-
- ktrsyscall(code, args, narg);
-
-#ifdef PTRACE
- if ((curlwp->l_proc->p_slflag & (PSL_SYSCALL|PSL_TRACED)) ==
- (PSL_SYSCALL|PSL_TRACED)) {
- process_stoptrace();
- if (curlwp->l_proc->p_slflag & PSL_SYSCALLEMU) {
- /* tracer will emulate syscall for us */
- error = EJUSTRETURN;
- }
- }
-#endif
- return error;
-}
-
-/*
- * End trace of particular system call. If process is being traced,
- * this routine is called by MD syscall dispatch code just after
- * a system call finishes.
- * MD caller guarantees the passed 'code' is within the supported
- * system call number range for emulation the process runs under.
- */
-void
-trace_exit(register_t code, register_t rval[], int error)
-{
-#ifdef PTRACE
- struct proc *p = curlwp->l_proc;
-#endif
-
-#ifdef SYSCALL_DEBUG
- scdebug_ret(code, error, rval);
-#endif /* SYSCALL_DEBUG */
-
- ktrsysret(code, error, rval);
-
-#ifdef PTRACE
- if ((p->p_slflag & (PSL_SYSCALL|PSL_TRACED|PSL_SYSCALLEMU)) ==
- (PSL_SYSCALL|PSL_TRACED))
- process_stoptrace();
- CLR(p->p_slflag, PSL_SYSCALLEMU);
-#endif
-}
diff -r 13b2e461f517 -r e1924ba803a8 sys/kern/kern_syscall.c
--- a/sys/kern/kern_syscall.c Mon Dec 09 16:45:23 2013 +0000
+++ b/sys/kern/kern_syscall.c Mon Dec 09 16:49:43 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_syscall.c,v 1.7 2012/05/05 19:37:37 christos Exp $ */
+/* $NetBSD: kern_syscall.c,v 1.8 2013/12/09 16:49:43 pooka Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,9 +30,14 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_syscall.c,v 1.7 2012/05/05 19:37:37 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_syscall.c,v 1.8 2013/12/09 16:49:43 pooka Exp $");
+#ifdef _KERNEL_OPT
#include "opt_modular.h"
+#include "opt_syscall_debug.h"
+#include "opt_ktrace.h"
+#include "opt_ptrace.h"
+#endif
/* XXX To get syscall prototypes. */
#define SYSVSHM
@@ -47,6 +52,8 @@
#include <sys/syscallvar.h>
#include <sys/systm.h>
#include <sys/xcall.h>
+#include <sys/ktrace.h>
+#include <sys/ptrace.h>
int
sys_nomodule(struct lwp *l, const void *v, register_t *retval)
@@ -334,3 +341,81 @@
return 0;
}
+
+/*
+ * Return true if system call tracing is enabled for the specified process.
+ */
+bool
+trace_is_enabled(struct proc *p)
+{
+#ifdef SYSCALL_DEBUG
+ return (true);
+#endif
+#ifdef KTRACE
+ if (ISSET(p->p_traceflag, (KTRFAC_SYSCALL | KTRFAC_SYSRET)))
+ return (true);
+#endif
+#ifdef PTRACE
+ if (ISSET(p->p_slflag, PSL_SYSCALL))
+ return (true);
+#endif
+
+ return (false);
+}
+
+/*
+ * Start trace of particular system call. If process is being traced,
+ * this routine is called by MD syscall dispatch code just before
+ * a system call is actually executed.
+ */
+int
+trace_enter(register_t code, const register_t *args, int narg)
+{
+ int error = 0;
+
+#ifdef SYSCALL_DEBUG
+ scdebug_call(code, args);
+#endif /* SYSCALL_DEBUG */
+
+ ktrsyscall(code, args, narg);
+
+#ifdef PTRACE
+ if ((curlwp->l_proc->p_slflag & (PSL_SYSCALL|PSL_TRACED)) ==
+ (PSL_SYSCALL|PSL_TRACED)) {
+ process_stoptrace();
+ if (curlwp->l_proc->p_slflag & PSL_SYSCALLEMU) {
+ /* tracer will emulate syscall for us */
+ error = EJUSTRETURN;
+ }
+ }
+#endif
+ return error;
+}
+
+/*
+ * End trace of particular system call. If process is being traced,
+ * this routine is called by MD syscall dispatch code just after
+ * a system call finishes.
+ * MD caller guarantees the passed 'code' is within the supported
+ * system call number range for emulation the process runs under.
+ */
+void
+trace_exit(register_t code, register_t rval[], int error)
+{
+#ifdef PTRACE
+ struct proc *p = curlwp->l_proc;
+#endif
+
+#ifdef SYSCALL_DEBUG
+ scdebug_ret(code, error, rval);
+#endif /* SYSCALL_DEBUG */
+
+ ktrsysret(code, error, rval);
+
+#ifdef PTRACE
+ if ((p->p_slflag & (PSL_SYSCALL|PSL_TRACED|PSL_SYSCALLEMU)) ==
+ (PSL_SYSCALL|PSL_TRACED))
+ process_stoptrace();
+ CLR(p->p_slflag, PSL_SYSCALLEMU);
+#endif
+}
Home |
Main Index |
Thread Index |
Old Index