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