]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ipc/mig_log.c
564fb7a4bf7951217a1b49ae2fed82b162323ba8
[apple/xnu.git] / osfmk / ipc / mig_log.c
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /*
24 * @OSF_COPYRIGHT@
25 */
26 /*
27 * HISTORY
28 *
29 * Revision 1.1.1.1 1998/09/22 21:05:29 wsanchez
30 * Import of Mac OS X kernel (~semeria)
31 *
32 * Revision 1.1.1.1 1998/03/07 02:26:16 wsanchez
33 * Import of OSF Mach kernel (~mburg)
34 *
35 * Revision 1.2.6.1 1994/09/23 02:14:23 ezf
36 * change marker to not FREE
37 * [1994/09/22 21:31:33 ezf]
38 *
39 * Revision 1.2.2.4 1993/08/03 18:29:18 gm
40 * CR9596: Change KERNEL to MACH_KERNEL.
41 * [1993/08/02 16:11:07 gm]
42 *
43 * Revision 1.2.2.3 1993/07/22 16:18:15 rod
44 * Add ANSI prototypes. CR #9523.
45 * [1993/07/22 13:34:22 rod]
46 *
47 * Revision 1.2.2.2 1993/06/09 02:33:38 gm
48 * Added to OSF/1 R1.3 from NMK15.0.
49 * [1993/06/02 21:11:41 jeffc]
50 *
51 * Revision 1.2 1993/04/19 16:23:26 devrcs
52 * Untyped ipc merge:
53 * Support for logging and tracing within the MIG stubs
54 * [1993/02/24 14:49:29 travos]
55 *
56 * $EndLog$
57 */
58
59 #ifdef MACH_KERNEL
60 #include <mig_debug.h>
61 #endif
62
63 #include <mach/message.h>
64 #include <mach/mig_log.h>
65
66 int mig_tracing, mig_errors, mig_full_tracing;
67
68 /*
69 * Tracing facilities for MIG generated stubs.
70 *
71 * At the moment, there is only a printf, which is
72 * activated through the runtime switch:
73 * mig_tracing to call MigEventTracer
74 * mig_errors to call MigEventErrors
75 * For this to work, MIG has to run with the -L option,
76 * and the mig_debug flags has to be selected
77 *
78 * In the future, it will be possible to collect infos
79 * on the use of MACH IPC with an application similar
80 * to netstat.
81 *
82 * A new option will be generated accordingly to the
83 * kernel configuration rules, e.g
84 * #include <mig_log.h>
85 */
86
87 void
88 MigEventTracer(
89 mig_who_t who,
90 mig_which_event_t what,
91 mach_msg_id_t msgh_id,
92 unsigned int size,
93 unsigned int kpd,
94 unsigned int retcode,
95 unsigned int ports,
96 unsigned int oolports,
97 unsigned int ool,
98 char *file,
99 unsigned int line)
100 {
101 printf("%d|%d|%d", who, what, msgh_id);
102 if (mig_full_tracing)
103 printf(" -- sz%d|kpd%d|ret(0x%x)|p%d|o%d|op%d|%s, %d",
104 size, kpd, retcode, ports, oolports, ool, file, line);
105 printf("\n");
106 }
107
108 void
109 MigEventErrors(
110 mig_who_t who,
111 mig_which_error_t what,
112 void *par,
113 char *file,
114 unsigned int line)
115 {
116 if (what == MACH_MSG_ERROR_UNKNOWN_ID)
117 printf("%d|%d|%d -- %s %d\n", who, what, *(int *)par, file, line);
118 else
119 printf("%d|%d|%s -- %s %d\n", who, what, (char *)par, file, line);
120 }