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