Module Name: src
Committed By: christos
Date: Sun Dec 15 16:26:56 UTC 2024
Modified Files:
src/sys/kern: sys_ptrace_common.c
src/sys/sys: ptrace.h
Log Message:
Complete ptrace strings array and add some more debugging.
To generate a diff of this commit:
cvs rdiff -u -r1.92 -r1.93 src/sys/kern/sys_ptrace_common.c
cvs rdiff -u -r1.75 -r1.76 src/sys/sys/ptrace.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/sys_ptrace_common.c
diff -u src/sys/kern/sys_ptrace_common.c:1.92 src/sys/kern/sys_ptrace_common.c:1.93
--- src/sys/kern/sys_ptrace_common.c:1.92 Mon Aug 9 16:49:10 2021
+++ src/sys/kern/sys_ptrace_common.c Sun Dec 15 11:26:56 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_ptrace_common.c,v 1.92 2021/08/09 20:49:10 andvar Exp $ */
+/* $NetBSD: sys_ptrace_common.c,v 1.93 2024/12/15 16:26:56 christos Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -107,7 +107,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.92 2021/08/09 20:49:10 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.93 2024/12/15 16:26:56 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_ptrace.h"
@@ -143,11 +143,12 @@ __KERNEL_RCSID(0, "$NetBSD: sys_ptrace_c
#include <machine/reg.h>
-# ifdef PTRACE_DEBUG
-# define DPRINTF(a) uprintf a
-# else
-# define DPRINTF(a)
-# endif
+#ifdef PTRACE_DEBUG
+# define DPRINTF(a) uprintf a
+static const char *pt_strings[] = { PT_STRINGS };
+#else
+# define DPRINTF(a)
+#endif
static kauth_listener_t ptrace_listener;
static int process_auxv_offset(struct proc *, struct uio *);
@@ -812,8 +813,9 @@ ptrace_lwpstatus(struct proc *t, struct
ptrace_read_lwpstatus(l, &pls);
out:
- DPRINTF(("%s: lwp=%d sigpend=%02x%02x%02x%02x sigmask=%02x%02x%02x%02x "
- "name='%s' private=%p\n", __func__, pls.pl_lwpid,
+ DPRINTF(("%s: lwp=%d sigpend=%02x%02x%02x%02x "
+ "sigmask=%02x%02x%02x%02x name='%s' private=%p\n",
+ __func__, pls.pl_lwpid,
pls.pl_sigpend.__bits[0], pls.pl_sigpend.__bits[1],
pls.pl_sigpend.__bits[2], pls.pl_sigpend.__bits[3],
pls.pl_sigmask.__bits[0], pls.pl_sigmask.__bits[1],
@@ -1089,6 +1091,10 @@ do_ptrace(struct ptrace_methods *ptm, st
bool locked;
error = 0;
+ DPRINTF(("%s: tracer=%d tracee=%d req=%s(%d) addr=%p data=%d\n",
+ __func__, p->p_pid, pid,
+ (u_int)req < __arraycount(pt_strings) ? pt_strings[req] : "???",
+ req, addr, data));
/*
* If attaching or detaching, we need to get a write hold on the
* proclist lock so that we can re-parent the target process.
Index: src/sys/sys/ptrace.h
diff -u src/sys/sys/ptrace.h:1.75 src/sys/sys/ptrace.h:1.76
--- src/sys/sys/ptrace.h:1.75 Wed Jun 8 19:12:27 2022
+++ src/sys/sys/ptrace.h Sun Dec 15 11:26:56 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.75 2022/06/08 23:12:27 andvar Exp $ */
+/* $NetBSD: ptrace.h,v 1.76 2024/12/15 16:26:56 christos Exp $ */
/*-
* Copyright (c) 1984, 1993
@@ -68,6 +68,9 @@
#define PT_FIRSTMACH 32 /* for machine-specific requests */
#include <machine/ptrace.h> /* machine-specific requests, if any */
+#ifndef PT_MACHDEP_STRINGS
+# define PT_MACHDEP_STRINGS
+#endif
#define PT_STRINGS \
/* 0 */ "PT_TRACE_ME", \
@@ -97,7 +100,12 @@
/* 24 */ "PT_LWPSTATUS", \
/* 25 */ "PT_LWPNEXT", \
/* 26 */ "PT_SET_SIGPASS", \
-/* 27 */ "PT_GET_SIGPASS"
+/* 27 */ "PT_GET_SIGPASS", \
+/* 28 */ "*PT_INVALID_28", \
+/* 29 */ "*PT_INVALID_29", \
+/* 30 */ "*PT_INVALID_30", \
+/* 31 */ "*PT_INVALID_31", \
+PT_MACHDEP_STRINGS
/* PT_{G,S}EVENT_MASK */
typedef struct ptrace_event {