Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Enable tracing of out of line data sent with Mach message
details: https://anonhg.NetBSD.org/src/rev/4c118656636d
branches: trunk
changeset: 555660:4c118656636d
user: manu <manu%NetBSD.org@localhost>
date: Mon Nov 24 16:51:33 2003 +0000
description:
Enable tracing of out of line data sent with Mach message
diffstat:
sys/compat/mach/mach_iokit.c | 23 +++++++++++++----------
sys/compat/mach/mach_task.c | 25 ++++++++++++-------------
sys/kern/kern_ktrace.c | 33 +++++++++++++++++++++++++++++++--
sys/sys/ktrace.h | 15 ++++++++++++++-
4 files changed, 70 insertions(+), 26 deletions(-)
diffs (246 lines):
diff -r dbdf00315203 -r 4c118656636d sys/compat/mach/mach_iokit.c
--- a/sys/compat/mach/mach_iokit.c Mon Nov 24 16:05:10 2003 +0000
+++ b/sys/compat/mach/mach_iokit.c Mon Nov 24 16:51:33 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mach_iokit.c,v 1.25 2003/11/13 13:40:39 manu Exp $ */
+/* $NetBSD: mach_iokit.c,v 1.26 2003/11/24 16:51:33 manu Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -36,9 +36,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include "opt_ktrace.h"
#include "opt_compat_darwin.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_iokit.c,v 1.25 2003/11/13 13:40:39 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_iokit.c,v 1.26 2003/11/24 16:51:33 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -47,6 +48,7 @@
#include <sys/signal.h>
#include <sys/mount.h>
#include <sys/proc.h>
+#include <sys/ktrace.h>
#include <sys/device.h>
#include <uvm/uvm_extern.h>
@@ -761,10 +763,6 @@
UVM_INH_COPY, UVM_ADV_NORMAL, UVM_FLAG_COPYONW))) != 0)
return mach_msg_error(args, error);
-#ifdef DEBUG_MACH
- printf("pid %d.%d: copyout iokit properties at %p\n",
- l->l_proc->p_pid, l->l_lid, (void *)va);
-#endif
if ((error = copyout(mid->mid_properties, (void *)va, size)) != 0) {
#ifdef DEBUG_MACH
printf("pid %d.%d: copyout iokit properties failed\n",
@@ -772,6 +770,11 @@
#endif
}
+#ifdef KTRACE
+ if (KTRPOINT(l->l_proc, KTR_MOOL) && error == 0)
+ ktrmool(l->l_proc, mid->mid_properties, size, (void *)va);
+#endif
+
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
@@ -849,10 +852,6 @@
UVM_INH_COPY, UVM_ADV_NORMAL, UVM_FLAG_COPYONW))) != 0)
return mach_msg_error(args, error);
-#ifdef DEBUG_MACH
- printf("pid %d.%d: copyout iokit property at %p\n",
- l->l_proc->p_pid, l->l_lid, (void *)va);
-#endif
if ((error = copyout(mip->mip_value, (void *)va, size)) != 0) {
#ifdef DEBUG_MACH
printf("pid %d.%d: copyout iokit property failed\n",
@@ -860,6 +859,10 @@
#endif
}
+#ifdef KTRACE
+ if (KTRPOINT(l->l_proc, KTR_MOOL) && error == 0)
+ ktrmool(l->l_proc, mip->mip_value, size, (void *)va);
+#endif
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
diff -r dbdf00315203 -r 4c118656636d sys/compat/mach/mach_task.c
--- a/sys/compat/mach/mach_task.c Mon Nov 24 16:05:10 2003 +0000
+++ b/sys/compat/mach/mach_task.c Mon Nov 24 16:51:33 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mach_task.c,v 1.39 2003/11/24 14:31:40 manu Exp $ */
+/* $NetBSD: mach_task.c,v 1.40 2003/11/24 16:51:33 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@@ -36,16 +36,18 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include "opt_ktrace.h"
#include "opt_compat_darwin.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_task.c,v 1.39 2003/11/24 14:31:40 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_task.c,v 1.40 2003/11/24 16:51:33 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/exec.h>
#include <sys/systm.h>
#include <sys/proc.h>
+#include <sys/ktrace.h>
#include <sys/resourcevar.h>
#include <sys/malloc.h>
@@ -101,11 +103,6 @@
case MACH_TASK_BOOTSTRAP_PORT:
mr = mach_right_get(med->med_bootstrap,
l, MACH_PORT_TYPE_SEND, 0);
-#ifdef DEBUG_MACH
- printf("*** get bootstrap right %p, port %p, recv %p [%p]\n",
- mr, mr->mr_port, mr->mr_port->mp_recv,
- mr->mr_port->mp_recv->mr_sethead);
-#endif
break;
case MACH_TASK_WIRED_LEDGER_PORT:
@@ -179,18 +176,16 @@
mr = mach_right_get(med->med_bootstrap, l, MACH_PORT_TYPE_SEND, 0);
mnp[MACH_TASK_BOOTSTRAP_PORT] = mr->mr_name;
-#ifdef DEBUG_MACH
- printf("mach_ports_lookup: kernel %08x, host %08x, boostrap %08x\n",
- mnp[MACH_TASK_KERNEL_PORT],
- mnp[MACH_TASK_HOST_PORT],
- mnp[MACH_TASK_BOOTSTRAP_PORT]);
-#endif
/*
* On Darwin, the data seems always null...
*/
if ((error = copyout(mnp, (void *)va, sizeof(mnp))) != 0)
return mach_msg_error(args, error);
+#ifdef KTRACE
+ if (KTRPOINT(l->l_proc, KTR_MOOL) && error == 0)
+ ktrmool(l->l_proc, mnp, sizeof(mnp), (void *)va);
+#endif
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
@@ -349,6 +344,10 @@
}
free(mnp, M_TEMP);
+#ifdef KTRACE
+ if (KTRPOINT(l->l_proc, KTR_MOOL) && error == 0)
+ ktrmool(l->l_proc, mnp, size, (void *)va);
+#endif
rep->rep_msgh.msgh_bits =
MACH_MSGH_REPLY_LOCAL_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE) |
MACH_MSGH_BITS_COMPLEX;
diff -r dbdf00315203 -r 4c118656636d sys/kern/kern_ktrace.c
--- a/sys/kern/kern_ktrace.c Mon Nov 24 16:05:10 2003 +0000
+++ b/sys/kern/kern_ktrace.c Mon Nov 24 16:51:33 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_ktrace.c,v 1.82 2003/11/12 21:07:38 dsl Exp $ */
+/* $NetBSD: kern_ktrace.c,v 1.83 2003/11/24 16:51:33 manu Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.82 2003/11/12 21:07:38 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.83 2003/11/24 16:51:33 manu Exp $");
#include "opt_ktrace.h"
#include "opt_compat_mach.h"
@@ -403,6 +403,35 @@
p->p_traceflag &= ~KTRFAC_ACTIVE;
}
+void
+ktrmool(p, kaddr, size, uaddr)
+ struct proc *p;
+ const void *kaddr;
+ size_t size;
+ const void *uaddr;
+{
+ struct ktr_header kth;
+ struct ktr_mool *kp;
+ struct ktr_mool *buf;
+
+ p->p_traceflag |= KTRFAC_ACTIVE;
+ ktrinitheader(&kth, p, KTR_MOOL);
+
+ kp = malloc(size + sizeof(*kp), M_TEMP, M_WAITOK);
+ kp->uaddr = uaddr;
+ kp->size = size;
+ buf = kp + 1; /* Skip uaddr and size */
+ memcpy(buf, kaddr, size);
+
+ kth.ktr_buf = (caddr_t)kp;
+ kth.ktr_len = size + sizeof(*kp);
+ (void) ktrwrite(p, &kth);
+ free(kp, M_TEMP);
+
+ p->p_traceflag &= ~KTRFAC_ACTIVE;
+}
+
+
/* Interface and common routines */
int
diff -r dbdf00315203 -r 4c118656636d sys/sys/ktrace.h
--- a/sys/sys/ktrace.h Mon Nov 24 16:05:10 2003 +0000
+++ b/sys/sys/ktrace.h Mon Nov 24 16:51:33 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ktrace.h,v 1.34 2003/09/25 21:58:12 christos Exp $ */
+/* $NetBSD: ktrace.h,v 1.35 2003/11/24 16:51:33 manu Exp $ */
/*
* Copyright (c) 1988, 1993
@@ -180,6 +180,16 @@
/* record contains arg/env string */
/*
+ * KTR_MOOL - Mach Out Of Line data
+ */
+#define KTR_MOOL 12
+struct ktr_mool {
+ const void *uaddr; /* User address */
+ size_t size; /* Data len */
+ /* Followed by size bytes of data */
+};
+
+/*
* kernel trace points (in p_traceflag)
*/
#define KTRFAC_MASK 0x00ffffff
@@ -194,6 +204,8 @@
#define KTRFAC_MMSG (1<<KTR_MMSG)
#define KTRFAC_EXEC_ARG (1<<KTR_EXEC_ARG)
#define KTRFAC_EXEC_ENV (1<<KTR_EXEC_ENV)
+#define KTRFAC_MOOL (1<<KTR_MOOL)
+
/*
* trace flags (also in p_traceflags)
*/
@@ -226,6 +238,7 @@
void ktrkmem(struct proc *, int, const void *, size_t);
void ktrderef(struct proc *);
void ktradref(struct proc *);
+void ktrmool(struct proc *, const void *, size_t, const void *);
#endif /* !_KERNEL */
Home |
Main Index |
Thread Index |
Old Index