Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys * Split sys/kern/sys_process.c into three parts:
details: https://anonhg.NetBSD.org/src/rev/df68872c267c
branches: trunk
changeset: 818814:df68872c267c
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Wed Nov 02 00:11:59 2016 +0000
description:
* Split sys/kern/sys_process.c into three parts:
1 - ptrace(2) syscall for native emulation
2 - common ptrace(2) syscall code (shared with compat_netbsd32)
3 - support routines that are shared with PROCFS and/or KTRACE
* Add module glue for #1 and #2. Both modules will be built-in to the
kernel if "options PTRACE" is included in the config file (this is
the default, defined in sys/conf/std).
* Mark the ptrace(2) syscall as modular in syscalls.master (generated
files will be committed shortly).
* Conditionalize all remaining portions of PTRACE code on a new kernel
option PTRACE_HOOKS.
XXX Instead of PROCFS depending on 'options PTRACE', we should probably
just add a procfs attribute to the sys/kern/sys_process.c file's
entry in files.kern, and add PROCFS to the "#if defineds" for
process_domem(). It's really confusing to have two different ways
of requiring this file.
diffstat:
sys/arch/i386/conf/INSTALL_FLOPPY | 3 +-
sys/arch/i386/i386/process_machdep.c | 8 +-
sys/arch/sh3/include/userret.h | 6 +-
sys/arch/sh3/sh3/exception_vector.S | 8 +-
sys/arch/sh3/sh3/process_machdep.c | 12 +-
sys/arch/sh3/sh3/sh3_machdep.c | 6 +-
sys/compat/netbsd32/netbsd32_ptrace.c | 8 +-
sys/conf/files | 4 +-
sys/conf/std | 5 +-
sys/kern/files.kern | 6 +-
sys/kern/init_main.c | 12 +-
sys/kern/kern_stub.c | 13 +-
sys/kern/sys_process.c | 1010 +----------------------------
sys/kern/sys_ptrace.c | 296 ++++++++
sys/kern/sys_ptrace_common.c | 1171 +++++++++++++++++++++++++++++++++
sys/kern/syscalls.master | 7 +-
sys/miscfs/procfs/files.procfs | 4 +-
sys/modules/Makefile | 4 +-
sys/modules/ptrace/Makefile | 12 +
sys/modules/ptrace_common/Makefile | 12 +
sys/sys/ptrace.h | 6 +-
21 files changed, 1556 insertions(+), 1057 deletions(-)
diffs (truncated from 2976 to 300 lines):
diff -r 85a9866ea6fd -r df68872c267c sys/arch/i386/conf/INSTALL_FLOPPY
--- a/sys/arch/i386/conf/INSTALL_FLOPPY Tue Nov 01 22:54:33 2016 +0000
+++ b/sys/arch/i386/conf/INSTALL_FLOPPY Wed Nov 02 00:11:59 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL_FLOPPY,v 1.29 2015/09/26 11:16:12 maxv Exp $
+# $NetBSD: INSTALL_FLOPPY,v 1.30 2016/11/02 00:11:59 pgoyette Exp $
#
# INSTALL - Installation kernel.
#
@@ -64,6 +64,7 @@
no options EXEC_AOUT
no options RFC2292 # Previous version of Adv. Sockets API for IPv6
+no options PTRACE_HOOKS
no options PTRACE # Include ptrace(2)
# Diagnostic/debugging support options
diff -r 85a9866ea6fd -r df68872c267c sys/arch/i386/i386/process_machdep.c
--- a/sys/arch/i386/i386/process_machdep.c Tue Nov 01 22:54:33 2016 +0000
+++ b/sys/arch/i386/i386/process_machdep.c Wed Nov 02 00:11:59 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: process_machdep.c,v 1.85 2014/02/19 21:23:01 dsl Exp $ */
+/* $NetBSD: process_machdep.c,v 1.86 2016/11/02 00:11:59 pgoyette Exp $ */
/*-
* Copyright (c) 1998, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.85 2014/02/19 21:23:01 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.86 2016/11/02 00:11:59 pgoyette Exp $");
#include "opt_vm86.h"
#include "opt_ptrace.h"
@@ -129,7 +129,7 @@
return 0;
}
-#ifdef PTRACE
+#ifdef PTRACE_HOOKS
int
process_write_regs(struct lwp *l, const struct reg *regs)
{
@@ -336,4 +336,4 @@
return (i386_use_fxsave);
}
#endif /* __HAVE_PTRACE_MACHDEP */
-#endif /* PTRACE */
+#endif /* PTRACE_HOOKS */
diff -r 85a9866ea6fd -r df68872c267c sys/arch/sh3/include/userret.h
--- a/sys/arch/sh3/include/userret.h Tue Nov 01 22:54:33 2016 +0000
+++ b/sys/arch/sh3/include/userret.h Wed Nov 02 00:11:59 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: userret.h,v 1.13 2012/07/08 20:14:11 dsl Exp $ */
+/* $NetBSD: userret.h,v 1.14 2016/11/02 00:11:59 pgoyette Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -54,7 +54,7 @@
/* Invoke MI userret code */
mi_userret(l);
-#ifdef PTRACE
+#ifdef PTRACE_HOOKS
/* Check if lwp is being PT_STEP'ed */
if (l->l_md.md_flags & MDL_SSTEP) {
struct trapframe *tf = l->l_md.md_regs;
@@ -75,7 +75,7 @@
}
#endif
}
-#endif /* PTRACE */
+#endif /* PTRACE_HOOKS */
}
#endif /* !_SH3_USERRET_H_ */
diff -r 85a9866ea6fd -r df68872c267c sys/arch/sh3/sh3/exception_vector.S
--- a/sys/arch/sh3/sh3/exception_vector.S Tue Nov 01 22:54:33 2016 +0000
+++ b/sys/arch/sh3/sh3/exception_vector.S Wed Nov 02 00:11:59 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: exception_vector.S,v 1.49 2011/02/04 04:14:25 uwe Exp $ */
+/* $NetBSD: exception_vector.S,v 1.50 2016/11/02 00:11:59 pgoyette Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
#define _ALIGN_TEXT .align 5
#include <sh3/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: exception_vector.S,v 1.49 2011/02/04 04:14:25 uwe Exp $")
+__KERNEL_RCSID(0, "$NetBSD: exception_vector.S,v 1.50 2016/11/02 00:11:59 pgoyette Exp $")
/*
@@ -98,7 +98,7 @@
/* general_exception(curlwp, tf, TEA); */
1: mov r4, r8
-#if defined(PTRACE) || defined(DDB)
+#if defined(PTRACE_HOOKS) || defined(DDB)
mov #0, r2
MOV (BBRA, r1)
mov.l r2, @(TF_UBC, r14) /* clear tf->tf_ubc */
@@ -115,7 +115,7 @@
jsr @r0
mov r14, r5
-#if defined(PTRACE) || defined(DDB)
+#if defined(PTRACE_HOOKS) || defined(DDB)
mov.l @(TF_UBC, r14), r2
tst r2, r2 ! single-step == 0?
bt .Lg_return_from_exception
diff -r 85a9866ea6fd -r df68872c267c sys/arch/sh3/sh3/process_machdep.c
--- a/sys/arch/sh3/sh3/process_machdep.c Tue Nov 01 22:54:33 2016 +0000
+++ b/sys/arch/sh3/sh3/process_machdep.c Wed Nov 02 00:11:59 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: process_machdep.c,v 1.20 2012/07/08 20:14:12 dsl Exp $ */
+/* $NetBSD: process_machdep.c,v 1.21 2016/11/02 00:11:59 pgoyette Exp $ */
/*
* Copyright (c) 1993 The Regents of the University of California.
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.20 2012/07/08 20:14:12 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.21 2016/11/02 00:11:59 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -101,7 +101,7 @@
#endif /* COMPAT_40 */
-#if defined(PTRACE) || defined(COREDUMP)
+#if defined(PTRACE_HOOKS) || defined(COREDUMP)
static inline struct trapframe *
process_frame(struct lwp *l)
@@ -141,10 +141,10 @@
return (0);
}
-#endif /* PTRACE || COREDUMP */
+#endif /* PTRACE_HOOKS || COREDUMP */
-#ifdef PTRACE
+#ifdef PTRACE_HOOKS
int
process_write_regs(struct lwp *l, const struct reg *regs)
@@ -360,4 +360,4 @@
return (0);
}
-#endif /* PTRACE */
+#endif /* PTRACE_HOOKS */
diff -r 85a9866ea6fd -r df68872c267c sys/arch/sh3/sh3/sh3_machdep.c
--- a/sys/arch/sh3/sh3/sh3_machdep.c Tue Nov 01 22:54:33 2016 +0000
+++ b/sys/arch/sh3/sh3/sh3_machdep.c Wed Nov 02 00:11:59 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sh3_machdep.c,v 1.103 2015/11/22 18:44:25 tsutsui Exp $ */
+/* $NetBSD: sh3_machdep.c,v 1.104 2016/11/02 00:11:59 pgoyette Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2002 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sh3_machdep.c,v 1.103 2015/11/22 18:44:25 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sh3_machdep.c,v 1.104 2016/11/02 00:11:59 pgoyette Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -194,7 +194,7 @@
uvm_setpagesize();
/* setup UBC channel A for single-stepping */
-#if defined(PTRACE) || defined(DDB)
+#if defined(PTRACE_HOOKS) || defined(DDB)
_reg_write_2(SH_(BBRA), 0); /* disable channel A */
_reg_write_2(SH_(BBRB), 0); /* disable channel B */
diff -r 85a9866ea6fd -r df68872c267c sys/compat/netbsd32/netbsd32_ptrace.c
--- a/sys/compat/netbsd32/netbsd32_ptrace.c Tue Nov 01 22:54:33 2016 +0000
+++ b/sys/compat/netbsd32/netbsd32_ptrace.c Wed Nov 02 00:11:59 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_ptrace.c,v 1.1 2016/10/19 09:44:01 skrll Exp $ */
+/* $NetBSD: netbsd32_ptrace.c,v 1.2 2016/11/02 00:11:59 pgoyette Exp $ */
/*
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_ptrace.c,v 1.1 2016/10/19 09:44:01 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_ptrace.c,v 1.2 2016/11/02 00:11:59 pgoyette Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ptrace.h"
@@ -193,7 +193,9 @@
{ 0, 0, NULL },
};
-MODULE(MODULE_CLASS_EXEC, compat_netbsd32_ptrace, "compat_netbsd32");
+#define DEPS "compat_netbsd32,ptrace_common"
+
+MODULE(MODULE_CLASS_EXEC, compat_netbsd32_ptrace, DEPS);
static int
compat_netbsd32_ptrace_modcmd(modcmd_t cmd, void *arg)
diff -r 85a9866ea6fd -r df68872c267c sys/conf/files
--- a/sys/conf/files Tue Nov 01 22:54:33 2016 +0000
+++ b/sys/conf/files Wed Nov 02 00:11:59 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files,v 1.1165 2016/11/01 22:54:33 pgoyette Exp $
+# $NetBSD: files,v 1.1166 2016/11/02 00:11:59 pgoyette Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
version 20150846
@@ -21,7 +21,7 @@
defflag INSECURE
defflag KTRACE
defflag MBUFTRACE
-defflag PTRACE
+defflag opt_ptrace.h PTRACE PTRACE_HOOKS
defflag COREDUMP
defflag opt_modular.h MODULAR
defflag opt_modular.h MODULAR_DEFAULT_AUTOLOAD
diff -r 85a9866ea6fd -r df68872c267c sys/conf/std
--- a/sys/conf/std Tue Nov 01 22:54:33 2016 +0000
+++ b/sys/conf/std Wed Nov 02 00:11:59 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: std,v 1.21 2015/11/14 07:31:13 pgoyette Exp $
+# $NetBSD: std,v 1.22 2016/11/02 00:11:59 pgoyette Exp $
#
# standard MI 'options'
#
@@ -27,7 +27,8 @@
options BUFQ_FCFS # First-come First-serve strategy
options BUFQ_DISKSORT # Traditional min seek sort strategy
options RFC2292 # Previous version of Adv. Sockets API for IPv6
-options PTRACE # Include ptrace(2)
+options PTRACE # Include ptrace(2) syscall
+options PTRACE_HOOKS # Include ptrace hooks
options COREDUMP # allow processes to coredump.
options AIO # POSIX asynchronous I/O
options MQUEUE # POSIX message queues
diff -r 85a9866ea6fd -r df68872c267c sys/kern/files.kern
--- a/sys/kern/files.kern Tue Nov 01 22:54:33 2016 +0000
+++ b/sys/kern/files.kern Wed Nov 02 00:11:59 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.kern,v 1.12 2016/09/16 03:10:45 pgoyette Exp $
+# $NetBSD: files.kern,v 1.13 2016/11/02 00:11:59 pgoyette Exp $
#
# kernel sources
@@ -144,7 +144,9 @@
file kern/sys_lwp.c kern
file kern/sys_pipe.c !pipe_socketpair
file kern/sys_pmc.c kern
-file kern/sys_process.c ptrace | ktrace
+file kern/sys_process.c ptrace_hooks | ktrace
+file kern/sys_ptrace.c ptrace
+file kern/sys_ptrace_common.c ptrace
file kern/sys_pset.c kern
file kern/sys_select.c kern
file kern/sys_sig.c kern
diff -r 85a9866ea6fd -r df68872c267c sys/kern/init_main.c
--- a/sys/kern/init_main.c Tue Nov 01 22:54:33 2016 +0000
+++ b/sys/kern/init_main.c Wed Nov 02 00:11:59 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_main.c,v 1.483 2016/09/17 12:09:22 maxv Exp $ */
+/* $NetBSD: init_main.c,v 1.484 2016/11/02 00:11:59 pgoyette Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.483 2016/09/17 12:09:22 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.484 2016/11/02 00:11:59 pgoyette Exp $");
#include "opt_ddb.h"
#include "opt_inet.h"
@@ -190,9 +190,6 @@
#endif
#include <sys/kauth.h>
#include <net80211/ieee80211_netbsd.h>
-#ifdef PTRACE
-#include <sys/ptrace.h>
-#endif /* PTRACE */
#include <sys/cprng.h>
#include <sys/syscall.h>
Home |
Main Index |
Thread Index |
Old Index