Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Put ptrace_read_lwpstatus() and process_read_lwpstatus()...



details:   https://anonhg.NetBSD.org/src/rev/8884ac0312bd
branches:  trunk
changeset: 967884:8884ac0312bd
user:      kamil <kamil%NetBSD.org@localhost>
date:      Thu Dec 26 08:52:38 2019 +0000

description:
Put ptrace_read_lwpstatus() and process_read_lwpstatus() to a new file

Fixes "no PTRACE" kernel build, in particular zaurus kernel=INSTALL_C700.

diffstat:

 sys/kern/files.kern             |   3 +-
 sys/kern/sys_ptrace_common.c    |  36 +-----------------
 sys/kern/sys_ptrace_lwpstatus.c |  81 +++++++++++++++++++++++++++++++++++++++++
 sys/sys/ptrace.h                |   4 +-
 4 files changed, 88 insertions(+), 36 deletions(-)

diffs (177 lines):

diff -r 5e920c888354 -r 8884ac0312bd sys/kern/files.kern
--- a/sys/kern/files.kern       Thu Dec 26 08:48:53 2019 +0000
+++ b/sys/kern/files.kern       Thu Dec 26 08:52:38 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.kern,v 1.40 2019/12/20 21:20:09 ad Exp $
+#      $NetBSD: files.kern,v 1.41 2019/12/26 08:52:38 kamil Exp $
 
 #
 # kernel sources
@@ -163,6 +163,7 @@
 file   kern/sys_process.c              ptrace_hooks | ktrace
 file   kern/sys_ptrace.c               ptrace
 file   kern/sys_ptrace_common.c        ptrace
+file   kern/sys_ptrace_lwpstatus.c     kern
 file   kern/sys_pset.c                 kern
 file   kern/sys_select.c               kern
 file   kern/sys_sig.c                  kern
diff -r 5e920c888354 -r 8884ac0312bd sys/kern/sys_ptrace_common.c
--- a/sys/kern/sys_ptrace_common.c      Thu Dec 26 08:48:53 2019 +0000
+++ b/sys/kern/sys_ptrace_common.c      Thu Dec 26 08:52:38 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_ptrace_common.c,v 1.75 2019/12/25 15:54:02 kamil Exp $     */
+/*     $NetBSD: sys_ptrace_common.c,v 1.76 2019/12/26 08:52:38 kamil Exp $     */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.75 2019/12/25 15:54:02 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.76 2019/12/26 08:52:38 kamil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -790,38 +790,6 @@
        return copyout(&pl, addr, sizeof(pl));
 }
 
-static void
-ptrace_read_lwpstatus(struct lwp *l, struct ptrace_lwpstatus *pls)
-{
-
-       KASSERT(l->l_lid == pls->pl_lwpid);
-
-       memcpy(&pls->pl_sigmask, &l->l_sigmask, sizeof(pls->pl_sigmask));
-       memcpy(&pls->pl_sigpend, &l->l_sigpend.sp_set, sizeof(pls->pl_sigpend));
-
-       if (l->l_name == NULL)
-               memset(&pls->pl_name, 0, PL_LNAMELEN);
-       else {
-               KASSERT(strlen(l->l_name) < PL_LNAMELEN);
-               strncpy(pls->pl_name, l->l_name, PL_LNAMELEN);
-       }
-
-#ifdef PTRACE_LWP_GETPRIVATE
-       pls->pl_private = (void *)(intptr_t)PTRACE_LWP_GETPRIVATE(l);
-#else
-       pls->pl_private = l->l_private;
-#endif
-}
-
-void
-process_read_lwpstatus(struct lwp *l, struct ptrace_lwpstatus *pls)
-{
-
-       pls->pl_lwpid = l->l_lid;
-
-       ptrace_read_lwpstatus(l, pls);
-}
-
 static int
 ptrace_lwpstatus(struct proc *t, struct ptrace_methods *ptm, struct lwp **lt,
     void *addr, size_t data, bool next)
diff -r 5e920c888354 -r 8884ac0312bd sys/kern/sys_ptrace_lwpstatus.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/kern/sys_ptrace_lwpstatus.c   Thu Dec 26 08:52:38 2019 +0000
@@ -0,0 +1,81 @@
+/*     $NetBSD: sys_ptrace_lwpstatus.c,v 1.1 2019/12/26 08:52:38 kamil Exp $   */
+
+/*-
+ * Copyright (c) 2019 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_lwpstatus.c,v 1.1 2019/12/26 08:52:38 kamil Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_ptrace.h"
+#include "opt_ktrace.h"
+#include "opt_pax.h"
+#include "opt_compat_netbsd32.h"
+#endif
+
+#if defined(__HAVE_COMPAT_NETBSD32) && !defined(COMPAT_NETBSD32) \
+    && !defined(_RUMPKERNEL)
+#define COMPAT_NETBSD32
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/errno.h>
+#include <sys/lwp.h>
+#include <sys/ptrace.h>
+
+
+void
+ptrace_read_lwpstatus(struct lwp *l, struct ptrace_lwpstatus *pls)
+{
+
+       KASSERT(l->l_lid == pls->pl_lwpid);
+
+       memcpy(&pls->pl_sigmask, &l->l_sigmask, sizeof(pls->pl_sigmask));
+       memcpy(&pls->pl_sigpend, &l->l_sigpend.sp_set, sizeof(pls->pl_sigpend));
+
+       if (l->l_name == NULL)
+               memset(&pls->pl_name, 0, PL_LNAMELEN);
+       else {
+               KASSERT(strlen(l->l_name) < PL_LNAMELEN);
+               strncpy(pls->pl_name, l->l_name, PL_LNAMELEN);
+       }
+
+#ifdef PTRACE_LWP_GETPRIVATE
+       pls->pl_private = (void *)(intptr_t)PTRACE_LWP_GETPRIVATE(l);
+#else
+       pls->pl_private = l->l_private;
+#endif
+}
+
+void
+process_read_lwpstatus(struct lwp *l, struct ptrace_lwpstatus *pls)
+{
+
+       pls->pl_lwpid = l->l_lid;
+
+       ptrace_read_lwpstatus(l, pls);
+}
diff -r 5e920c888354 -r 8884ac0312bd sys/sys/ptrace.h
--- a/sys/sys/ptrace.h  Thu Dec 26 08:48:53 2019 +0000
+++ b/sys/sys/ptrace.h  Thu Dec 26 08:52:38 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ptrace.h,v 1.68 2019/12/24 14:50:59 kamil Exp $        */
+/*     $NetBSD: ptrace.h,v 1.69 2019/12/26 08:52:38 kamil Exp $        */
 
 /*-
  * Copyright (c) 1984, 1993
@@ -260,6 +260,8 @@
 int    do_ptrace(struct ptrace_methods *, struct lwp *, int, pid_t, void *,
            int, register_t *);
 
+void   ptrace_read_lwpstatus(struct lwp *, struct ptrace_lwpstatus *);
+
 void   process_read_lwpstatus(struct lwp *, struct ptrace_lwpstatus *);
 #ifndef process_read_lwpstatus32
 #define process_read_lwpstatus32 process_read_lwpstatus



Home | Main Index | Thread Index | Old Index