Source-Changes-HG archive

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

[src/trunk]: src Added support for dumping mach messages in ktrace/kdump. Whi...



details:   https://anonhg.NetBSD.org/src/rev/80d1d66125d5
branches:  trunk
changeset: 540323:80d1d66125d5
user:      manu <manu%NetBSD.org@localhost>
date:      Mon Dec 09 21:29:20 2002 +0000

description:
Added support for dumping mach messages in ktrace/kdump. While we are
there, KNFify a few functions.

diffstat:

 sys/compat/mach/mach_bootstrap.c   |   15 +---
 sys/compat/mach/mach_clock.c       |   13 +--
 sys/compat/mach/mach_errno.c       |   14 +--
 sys/compat/mach/mach_errno.h       |    8 +-
 sys/compat/mach/mach_host.c        |   32 +-------
 sys/compat/mach/mach_message.c     |   57 +++++++++++++++-
 sys/compat/mach/mach_message.h     |   10 ++-
 sys/compat/mach/mach_port.c        |   40 +---------
 sys/compat/mach/mach_syscall.h     |    2 +-
 sys/compat/mach/mach_syscallargs.h |    2 +-
 sys/compat/mach/mach_syscalls.c    |    4 +-
 sys/compat/mach/mach_sysent.c      |    4 +-
 sys/compat/mach/mach_task.c        |   24 +-----
 sys/compat/mach/mach_thread.c      |   13 +--
 sys/compat/mach/mach_vm.c          |   56 +++-----------
 sys/kern/kern_ktrace.c             |  132 ++++++++++++++++++++++++++++++------
 sys/sys/ktrace.h                   |   51 ++++++++++---
 usr.bin/kdump/kdump.c              |   61 +++++++++++++++-
 usr.bin/ktrace/ktrace.1            |    7 +-
 usr.bin/ktrace/ktrace.c            |   12 +-
 usr.bin/ktrace/ktrace.h            |    5 +-
 usr.bin/ktrace/subr.c              |    7 +-
 22 files changed, 340 insertions(+), 229 deletions(-)

diffs (truncated from 1309 to 300 lines):

diff -r ca47693ded2b -r 80d1d66125d5 sys/compat/mach/mach_bootstrap.c
--- a/sys/compat/mach/mach_bootstrap.c  Mon Dec 09 18:59:07 2002 +0000
+++ b/sys/compat/mach/mach_bootstrap.c  Mon Dec 09 21:29:20 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_bootstrap.c,v 1.1 2002/12/07 21:23:03 manu Exp $ */
+/*     $NetBSD: mach_bootstrap.c,v 1.2 2002/12/09 21:29:22 manu Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_bootstrap.c,v 1.1 2002/12/07 21:23:03 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_bootstrap.c,v 1.2 2002/12/09 21:29:22 manu Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -67,8 +67,6 @@
        if ((error = copyin(msgh, &req, sizeof(req))) != 0)
                return error;
 
-       DPRINTF(("mach_sys_bootstrap_look_up();\n"));
-
        bzero(&rep, sizeof(rep));
 
        /* The trailer is word aligned  */
@@ -89,13 +87,6 @@
        /* XXX This is the trailer. We should find something better */
        rep.rep_service_name[service_name_len + 7] = 8;
 
-       if (msglen > maxlen)
-               return EMSGSIZE;
-       if (dst != NULL)
-               msgh = dst;
-
-       if ((error = copyout(&rep, msgh, msglen)) != 0)
-               return error;
-       return 0;
+       return MACH_MSG_RETURN(p, &rep, msgh, msglen, maxlen, dst);
 }
 
diff -r ca47693ded2b -r 80d1d66125d5 sys/compat/mach/mach_clock.c
--- a/sys/compat/mach/mach_clock.c      Mon Dec 09 18:59:07 2002 +0000
+++ b/sys/compat/mach/mach_clock.c      Mon Dec 09 21:29:20 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_clock.c,v 1.3 2002/11/29 17:08:16 manu Exp $ */
+/*     $NetBSD: mach_clock.c,v 1.4 2002/12/09 21:29:23 manu Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_clock.c,v 1.3 2002/11/29 17:08:16 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_clock.c,v 1.4 2002/12/09 21:29:23 manu Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -155,13 +155,6 @@
        rep.rep_cur_time.tv_nsec = tv.tv_usec * 1000; 
        rep.rep_trailer.msgh_trailer_size = 8;
 
-       if (sizeof(rep) > maxlen)
-               return EMSGSIZE;
-       if (dst != NULL)
-               msgh = dst;
-
-       if ((error = copyout(&rep, msgh, sizeof(rep))) != 0)
-               return error;
-       return 0;
+       return MACH_MSG_RETURN(p, &rep, msgh, sizeof(rep), maxlen, dst);
 }
 
diff -r ca47693ded2b -r 80d1d66125d5 sys/compat/mach/mach_errno.c
--- a/sys/compat/mach/mach_errno.c      Mon Dec 09 18:59:07 2002 +0000
+++ b/sys/compat/mach/mach_errno.c      Mon Dec 09 21:29:20 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_errno.c,v 1.5 2002/12/04 22:55:11 manu Exp $ */
+/*     $NetBSD: mach_errno.c,v 1.6 2002/12/09 21:29:23 manu Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_errno.c,v 1.5 2002/12/04 22:55:11 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_errno.c,v 1.6 2002/12/09 21:29:23 manu Exp $");
 
 #include <sys/types.h>
 #include <sys/systm.h>
@@ -138,7 +138,8 @@
 };
 
 int
-mach_msg_error(msgh, req, rep, error, maxlen, dst)
+mach_msg_error(p, msgh, req, rep, error, maxlen, dst)
+       struct proc *p;
        mach_msg_header_t *msgh;
        mach_msg_header_t *req;
        mach_error_reply_t *rep;
@@ -158,10 +159,5 @@
 
        DPRINTF(("mach_msg_error: error = %d\n", error));
 
-       if (sizeof(*rep) > maxlen)
-               return EMSGSIZE;
-       if (dst != NULL)
-               msgh = dst;
-
-       return copyout(rep, msgh, sizeof(*rep));
+       return MACH_MSG_RETURN(p, rep, msgh, sizeof(*rep), maxlen, dst);
 }
diff -r ca47693ded2b -r 80d1d66125d5 sys/compat/mach/mach_errno.h
--- a/sys/compat/mach/mach_errno.h      Mon Dec 09 18:59:07 2002 +0000
+++ b/sys/compat/mach/mach_errno.h      Mon Dec 09 21:29:20 2002 +0000
@@ -1,4 +1,4 @@
-       /*      $NetBSD: mach_errno.h,v 1.3 2002/11/28 21:21:32 manu Exp $ */
+       /*      $NetBSD: mach_errno.h,v 1.4 2002/12/09 21:29:23 manu Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -99,12 +99,12 @@
        mach_msg_trailer_t rep_trailer;
 } mach_error_reply_t;
 
-#define MACH_MSG_ERROR(msgh,req,rep,error,maxlen,dst) \
-    mach_msg_error((msgh), (mach_msg_header_t *)(req), \
+#define MACH_MSG_ERROR(p,msgh,req,rep,error,maxlen,dst) \
+    mach_msg_error((p), (msgh), (mach_msg_header_t *)(req), \
     (mach_error_reply_t *)(rep), (error), (maxlen), \
     (mach_msg_header_t *)(dst))
 
-int mach_msg_error(mach_msg_header_t *, mach_msg_header_t *, 
+int mach_msg_error(struct proc *, mach_msg_header_t *, mach_msg_header_t *, 
     mach_error_reply_t *, int, size_t, mach_msg_header_t *);
 
 #endif /* _MACH_ERRNO_H_ */
diff -r ca47693ded2b -r 80d1d66125d5 sys/compat/mach/mach_host.c
--- a/sys/compat/mach/mach_host.c       Mon Dec 09 18:59:07 2002 +0000
+++ b/sys/compat/mach/mach_host.c       Mon Dec 09 21:29:20 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_host.c,v 1.13 2002/11/28 21:21:32 manu Exp $ */
+/*     $NetBSD: mach_host.c,v 1.14 2002/12/09 21:29:24 manu Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_host.c,v 1.13 2002/11/28 21:21:32 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_host.c,v 1.14 2002/12/09 21:29:24 manu Exp $");
 
 #include <sys/types.h>
 #include <sys/malloc.h>
@@ -137,15 +137,7 @@
                break;
        }
 
-       if (msglen > maxlen)
-               return EMSGSIZE;
-       if (dst != NULL)
-               msgh = dst;
-
-       if ((error = copyout(&rep, msgh, msglen)) != 0)
-               return error;
-
-       return 0;
+       return MACH_MSG_RETURN(p, &rep, msgh, msglen, maxlen, dst);
 }
 
 
@@ -175,14 +167,7 @@
        rep.rep_page_size = PAGE_SIZE;
        rep.rep_trailer.msgh_trailer_size = 8;
        
-       if (sizeof(rep) > maxlen)
-               return EMSGSIZE;
-       if (dst != NULL)
-               msgh = dst;
-
-       if ((error = copyout(&rep, msgh, sizeof(rep))) != 0)
-               return error;
-       return 0;
+       return MACH_MSG_RETURN(p, &rep, msgh, sizeof(rep), maxlen, dst);
 }
 
 int
@@ -214,14 +199,7 @@
        rep.rep_clock_serv.disposition = 0x11; /* XXX */
        rep.rep_trailer.msgh_trailer_size = 8;
 
-       if (sizeof(rep) > maxlen)
-               return EMSGSIZE;
-       if (dst != NULL)
-               msgh = dst;
-
-       if ((error = copyout(&rep, msgh, sizeof(rep))) != 0)
-               return error;
-       return 0;
+       return MACH_MSG_RETURN(p, &rep, msgh, sizeof(rep), maxlen, dst);
 }
 
 void
diff -r ca47693ded2b -r 80d1d66125d5 sys/compat/mach/mach_message.c
--- a/sys/compat/mach/mach_message.c    Mon Dec 09 18:59:07 2002 +0000
+++ b/sys/compat/mach/mach_message.c    Mon Dec 09 21:29:20 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_message.c,v 1.1 2002/11/28 21:21:32 manu Exp $ */
+/*     $NetBSD: mach_message.c,v 1.2 2002/12/09 21:29:24 manu Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,13 +37,19 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_message.c,v 1.1 2002/11/28 21:21:32 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_message.c,v 1.2 2002/12/09 21:29:24 manu Exp $");
+
+#include "opt_ktrace.h"
+#include "opt_compat_mach.h" /* For COMPAT_MACH in <sys/ktrace.h> */
 
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/signal.h>
 #include <sys/proc.h>
+#ifdef KTRACE
+#include <sys/ktrace.h>
+#endif 
 
 #include <compat/mach/mach_types.h>
 #include <compat/mach/mach_message.h>
@@ -115,6 +121,14 @@
        int error;
        struct mach_subsystem_namemap *namemap;
 
+       if ((SCARG(uap, send_size) > MACH_MAX_MSG_LEN)
+           || (SCARG(uap, rcv_size) > MACH_MAX_MSG_LEN))
+               return E2BIG;
+#ifdef KTRACE
+       if (KTRPOINT(p, KTR_MMSG))
+               ktrmmsg(p, (char *)SCARG(uap, msg), SCARG(uap, send_size)); 
+#endif
+
        switch (SCARG(uap, option)) {
        case MACH_SEND_MSG|MACH_RCV_MSG:
                if (SCARG(uap, msg)) {
@@ -132,6 +146,9 @@
 #endif /* DEBUG_MACH */
                                break;
                        }
+#ifdef KTRACE
+                       ktruser(p, namemap->map_name, NULL, 0, 0);
+#endif
                        return (*namemap->map_handler)(p, SCARG(uap, msg), 
                            SCARG(uap, rcv_size), SCARG(uap, rcv_msg));
                }
@@ -162,6 +179,14 @@
        int error;
        struct mach_subsystem_namemap *namemap;
 
+       if ((SCARG(uap, send_size) > MACH_MAX_MSG_LEN)
+           || (SCARG(uap, rcv_size) > MACH_MAX_MSG_LEN))
+               return E2BIG;
+#ifdef KTRACE
+       if (KTRPOINT(p, KTR_MMSG))
+               ktrmmsg(p, (char *)SCARG(uap, msg), SCARG(uap, send_size)); 
+#endif
+
        switch (SCARG(uap, option)) {
        case MACH_SEND_MSG|MACH_RCV_MSG:
                if (SCARG(uap, msg)) {
@@ -179,6 +204,9 @@
 #endif /* DEBUG_MACH */
                                break;
                        }
+#ifdef KTRACE
+                       ktruser(p, namemap->map_name, NULL, 0, 0);
+#endif
                        return (*namemap->map_handler)(p, SCARG(uap, msg),
                            SCARG(uap, rcv_size), NULL);
                }
@@ -191,3 +219,28 @@
        return 0;
 }
 
+int 
+mach_msg_return(p, rep, msgh, msglen, maxlen, dst)
+       struct proc *p;
+       mach_msg_header_t *rep;
+       mach_msg_header_t *msgh;  
+       size_t msglen;
+       size_t maxlen;
+       mach_msg_header_t *dst;
+{



Home | Main Index | Thread Index | Old Index