1 | /*************************************************************************** |
---|
2 | * |
---|
3 | * Copyright (C) 2001 International Business Machines |
---|
4 | * All rights reserved. |
---|
5 | * |
---|
6 | * This file is part of the GPFS mmfslinux kernel module. |
---|
7 | * |
---|
8 | * Redistribution and use in source and binary forms, with or without |
---|
9 | * modification, are permitted provided that the following conditions |
---|
10 | * are met: |
---|
11 | * |
---|
12 | * 1. Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
15 | * notice, this list of conditions and the following disclaimer in the |
---|
16 | * documentation and/or other materials provided with the distribution. |
---|
17 | * 3. The name of the author may not be used to endorse or promote products |
---|
18 | * derived from this software without specific prior written |
---|
19 | * permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
---|
22 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
---|
23 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
---|
24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
---|
27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
---|
30 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
31 | * |
---|
32 | *************************************************************************** */ |
---|
33 | /* @(#)02 1.23.1.1 src/avs/fs/mmfs/ts/kernext/ibm-kxi/Trace.h, mmfs, avs_rgpfs24, rgpfs24s007a 10/8/06 03:17:47 */ |
---|
34 | /* |
---|
35 | * Definition of macros and symbols to control trace generation. Define |
---|
36 | * the symbol NTRACE at compile time to remove all trace code. |
---|
37 | * |
---|
38 | * Conventions for assigning trace levels: |
---|
39 | * - Trace levels are always non-negative. |
---|
40 | * - Larger trace levels produce more trace output |
---|
41 | * - Trace level == 0 produces no output. |
---|
42 | * - Trace level == 1 produces one line of output for the operation |
---|
43 | * being traced, usually just a description of what is being called |
---|
44 | * and its arguments. |
---|
45 | * - Trace level >= 10 are for testing only; they are disabled |
---|
46 | * in the product code (controlled by VERBOSETRACE define). |
---|
47 | * |
---|
48 | */ |
---|
49 | #ifndef _h_Trace |
---|
50 | #define _h_Trace |
---|
51 | |
---|
52 | /* Include the code generated by the mktrace utility to marshall trace |
---|
53 | arguments for all traces in this source directory */ |
---|
54 | #include <trcid.h> |
---|
55 | |
---|
56 | /* Include the platform-specific trace macros */ |
---|
57 | #include <Trace-plat.h> |
---|
58 | |
---|
59 | |
---|
60 | /* Define macros to build xxx_ToString calls. Used within xxx_id2name |
---|
61 | macros. */ |
---|
62 | #ifdef GPFS_PRINTF |
---|
63 | # define I2N(n,i) n##ToString((int)i) |
---|
64 | # define E2N(n,i) n##ToString(i) |
---|
65 | #else |
---|
66 | # define I2N(n,i) ((int)(i)) |
---|
67 | # define E2N(n,i) ((int)(i)) |
---|
68 | #endif |
---|
69 | |
---|
70 | |
---|
71 | /* Trace categories */ |
---|
72 | #define TRACE_ALLOC 0 /* Disk space allocation */ |
---|
73 | #define TRACE_ALLOCMGR 1 /* Allocation manager trace */ |
---|
74 | #define TRACE_BASIC 2 /* "basic" classes */ |
---|
75 | #define TRACE_BRL 3 /* byte range locks */ |
---|
76 | #define TRACE_CLEANUP 4 /* cleanup routines */ |
---|
77 | #define TRACE_CMD 5 /* TS commands */ |
---|
78 | #define TRACE_DEFRAG 6 /* defragmentation */ |
---|
79 | #define TRACE_DFS 7 /* DFS Export interaction */ |
---|
80 | #define TRACE_DISK 8 /* physical disk I/O */ |
---|
81 | #define TRACE_DMAPI 9 /* Data Management */ |
---|
82 | #define TRACE_DS 10 /* data shipping */ |
---|
83 | #define TRACE_ERRLOG 11 /* error logging */ |
---|
84 | #define TRACE_FS 12 /* file system */ |
---|
85 | #define TRACE_FSCK 13 /* online multinode fsck */ |
---|
86 | #define TRACE_ENTRYEXIT 14 /* routine entry/exit tracing */ |
---|
87 | #define TRACE_IO 15 /* physical I/O (formerly TRACE_RTPERF) */ |
---|
88 | #define TRACE_KLOCKL 16 /* low-level locks in VFS code */ |
---|
89 | #define TRACE_KSVFS 17 /* generic VFS kernel stuff */ |
---|
90 | #define TRACE_LOCK 18 /* interprocess locking */ |
---|
91 | #define TRACE_LOG 19 /* recovery log */ |
---|
92 | #define TRACE_MALLOC 20 /* MemoryPool alloc and dealloc */ |
---|
93 | #define TRACE_MB 21 /* mailbox message handling */ |
---|
94 | #define TRACE_MEMMGR 22 /* memory manager traces */ |
---|
95 | #define TRACE_MNODE 23 /* metanode operations */ |
---|
96 | #define TRACE_MSG 24 /* calls to routines in SharkMsg.h */ |
---|
97 | #define TRACE_MUTEX 25 /* mutexes and condition variables */ |
---|
98 | #define TRACE_PERFMON 26 /* trace performance monitor code */ |
---|
99 | #define TRACE_PGALLOC 27 /* page allocator tracing */ |
---|
100 | #define TRACE_PIN 28 /* pinning to real memory */ |
---|
101 | #define TRACE_PIT 29 /* Parallel Inode Traversal */ |
---|
102 | #define TRACE_QUOTA 30 /* quota management */ |
---|
103 | #define TRACE_SP 31 /* SP message handling */ |
---|
104 | #define TRACE_TASKING 32 /* tasking system but not Thread operations */ |
---|
105 | #define TRACE_THREAD 33 /* operations in Thread class */ |
---|
106 | #define TRACE_TSTM 34 /* token manager (formerly TRACE_CETM) */ |
---|
107 | #define TRACE_TS 35 /* Tiger Shark specific code. */ |
---|
108 | #define TRACE_USER1 36 /* Used for miscellaneous tracing and */ |
---|
109 | #define TRACE_USER2 37 /* debugging purposes. */ |
---|
110 | #define TRACE_VNODE 38 /* vnode layer of VFS kernel support */ |
---|
111 | #define TRACE_VNOP 39 /* one line per VNOP with all important info */ |
---|
112 | #define TRACE_BOPS 40 /* block_operations */ |
---|
113 | #define TRACE_DOPS 41 /* dentry_operations */ |
---|
114 | #define TRACE_IALLOC 42 /* inode allocation */ |
---|
115 | #define TRACE_FOPS 43 /* file_operations */ |
---|
116 | #define TRACE_SOPS 44 /* super_operations */ |
---|
117 | #define TRACE_SHARED 45 /* shared memory */ |
---|
118 | #define TRACE_NSD 46 /* network shared disk */ |
---|
119 | #define TRACE_DLEASE 47 /* disk lease */ |
---|
120 | #define TRACE_SMB 48 /* SMB Open and Op Locks */ |
---|
121 | #define TRACE_EEXP 49 /* events exporter. */ |
---|
122 | #define TRACE_SEC 50 /* Cluster Security Specific Trace */ |
---|
123 | #define TRACE_SANERGY 51 /* SANergy */ |
---|
124 | #define TRACE_KERNEL 52 /* kernel */ |
---|
125 | #define TRACE_MMPMON 53 /* mmpmon. */ |
---|
126 | |
---|
127 | /* Add new trace classes above here. When adding new trace classes, be |
---|
128 | sure to update the table below containing character string names for the |
---|
129 | trace classes. The maximum number of trace classes is given by |
---|
130 | MAX_TRACE_CLASSES. */ |
---|
131 | |
---|
132 | |
---|
133 | /* Table of trace class names, indexed by TRACE_... constants above. |
---|
134 | The generation of this table is controlled by the #define variable |
---|
135 | DEFINE_TRACE_CLASS_NAME_TABLE, which is generally only set in the module |
---|
136 | that parses commands to change trace settings. */ |
---|
137 | struct TraceNameTableEntry |
---|
138 | { |
---|
139 | char *name; |
---|
140 | char *desc; |
---|
141 | }; |
---|
142 | |
---|
143 | |
---|
144 | #ifndef _KERNEL |
---|
145 | extern const struct TraceNameTableEntry TraceNamesP[MAX_TRACE_CLASSES + 1]; |
---|
146 | |
---|
147 | # ifdef DEFINE_TRACE_CLASS_NAME_TABLE |
---|
148 | const TraceNameTableEntry TraceNamesP[MAX_TRACE_CLASSES + 1] = |
---|
149 | { |
---|
150 | /* 0 */ { "alloc", "disk space allocation" }, |
---|
151 | /* 1 */ { "allocmgr", "allocation manager" }, |
---|
152 | /* 2 */ { "basic", "'basic' classes" }, |
---|
153 | /* 3 */ { "brl", "byte range locks" }, |
---|
154 | /* 4 */ { "cleanup", "cleanup routines" }, |
---|
155 | /* 5 */ { "cmd", "TS commands" }, |
---|
156 | /* 6 */ { "defrag", "defragmentation" }, |
---|
157 | /* 7 */ { "dfs", "DFS export" }, |
---|
158 | /* 8 */ { "disk", "physical disk I/O" }, |
---|
159 | /* 9 */ { "dmapi", "data management" }, |
---|
160 | /* 10 */ { "ds", "data shipping" }, |
---|
161 | /* 11 */ { "errlog", "error logging" }, |
---|
162 | /* 12 */ { "fs", "file system" }, |
---|
163 | /* 13 */ { "fsck", "online multinode fsck" }, |
---|
164 | /* 14 */ { "entryexit", "routine entry/exit" }, |
---|
165 | /* 15 */ { "io", "physical I/O" }, |
---|
166 | /* 16 */ { "klockl", "low-level VFS locking" }, |
---|
167 | /* 17 */ { "ksvfs", "generic kernel VFS stuff" }, |
---|
168 | /* 18 */ { "lock", "interprocess locking" }, |
---|
169 | /* 19 */ { "log", "recovery log" }, |
---|
170 | /* 20 */ { "malloc", "malloc/free in shared segment" }, |
---|
171 | /* 21 */ { "mb", "mailbox message handling" }, |
---|
172 | /* 22 */ { "memmgr", "memory manager" }, |
---|
173 | /* 23 */ { "mnode", "mnode operations" }, |
---|
174 | /* 24 */ { "msg", "calls to routines in SharkMsg.h" }, |
---|
175 | /* 25 */ { "mutex", "mutexes and condition variables" }, |
---|
176 | /* 26 */ { "perfmon", "performance monitors" }, |
---|
177 | /* 27 */ { "pgalloc", "page allocator tracing" }, |
---|
178 | /* 28 */ { "pin", "pinning to real memory" }, |
---|
179 | /* 29 */ { "pit", "parallel inode traversal" }, |
---|
180 | /* 30 */ { "quota", "quota management" }, |
---|
181 | /* 31 */ { "sp", "SP message handling" }, |
---|
182 | /* 32 */ { "tasking", "tasking system but not Thread operations" }, |
---|
183 | /* 33 */ { "thread", "operations in Thread class" }, |
---|
184 | /* 34 */ { "tm", "token manager" }, |
---|
185 | /* 35 */ { "ts", "Tiger Shark specific code" }, |
---|
186 | /* 36 */ { "user1", "Used for miscellaneous tracing and" }, |
---|
187 | /* 37 */ { "user2", "debugging purposes" }, |
---|
188 | /* 38 */ { "vnode", "vnode layer of VFS kernel support" }, |
---|
189 | /* 39 */ { "vnop", "concise vnop description" }, |
---|
190 | /* 40 */ { "block", "block_operations" }, |
---|
191 | /* 41 */ { "dentry", "dentry_operations" }, |
---|
192 | /* 42 */ { "ialloc", "inode allocation" }, |
---|
193 | /* 43 */ { "file", "file_operations" }, |
---|
194 | /* 44 */ { "super", "super_operations" }, |
---|
195 | /* 45 */ { "shared", "shared memory" }, |
---|
196 | /* 46 */ { "nsd", "network shared disk"}, |
---|
197 | /* 47 */ { "disklease", "disk lease"}, |
---|
198 | /* 48 */ { "smb", "SMB Locks"}, |
---|
199 | /* 49 */ { "eventsExporter", "Events Exporter"}, |
---|
200 | /* 50 */ { "sec", "Cluster Security Specific Trace"}, |
---|
201 | /* 51 */ { "sanergy", "SANergy"}, |
---|
202 | /* 52 */ { "kernel", "kernel"}, |
---|
203 | /* 53 */ { "mmpmon", "mmpmon"}, |
---|
204 | /* Add new trace class names above here. */ |
---|
205 | /* DO NOT ifdef TRACE CLASS DEFINITIONS! */ |
---|
206 | { 0, 0 } |
---|
207 | }; |
---|
208 | # endif /* of ifdef DEFINE_TRACE_CLASS_NAME_TABLE */ |
---|
209 | #endif /* not _KERNEL */ |
---|
210 | |
---|
211 | |
---|
212 | /* Define the TRCOPTCODE and/or KTRCOPTCODE macro here to temporarily insert |
---|
213 | debugging code into each enabled TRACE macro expansion. TRCOPTCODE is |
---|
214 | inserted into code that is compiled with _KERNEL *not* defined, while |
---|
215 | KTRCOPTCODE is inserted into code compiled with -D_KERNEL */ |
---|
216 | #define TRCOPTCODE |
---|
217 | #define KTRCOPTCODE |
---|
218 | |
---|
219 | |
---|
220 | /* Define a macro that does nothing. Used for dummy else clauses. */ |
---|
221 | #ifndef NOOP |
---|
222 | # define NOOP ((void)0) |
---|
223 | #endif |
---|
224 | |
---|
225 | |
---|
226 | /* Define SHARKHOOKID word. GPFS default hookid is 307, but we use a |
---|
227 | different hookid in certain directories, as defined in DirIds.h. */ |
---|
228 | #if LOCAL_BASE == DIR_ID_TM |
---|
229 | # define SHARKHOOKID 0x30600000 |
---|
230 | #elif LOCAL_BASE == DIR_ID_TASKING |
---|
231 | # define SHARKHOOKID 0x30800000 |
---|
232 | #elif LOCAL_BASE == DIR_ID_KERNEXT |
---|
233 | # define SHARKHOOKID 0x30900000 |
---|
234 | #else |
---|
235 | # define SHARKHOOKID 0x30700000 |
---|
236 | #endif |
---|
237 | |
---|
238 | /* Convert the id of a particular trace to the hookword stored in the |
---|
239 | trace buffer */ |
---|
240 | #define _HOOKWORD(_id) ((_id) | SHARKHOOKID) |
---|
241 | |
---|
242 | /* Define the routines that handle traces that include strings (_STrace) |
---|
243 | and arbitrary traces (_XTrace) */ |
---|
244 | #ifdef __cplusplus |
---|
245 | extern "C" |
---|
246 | { |
---|
247 | #endif |
---|
248 | void _STrace(int hookword, int nArgs, int pos, ...); |
---|
249 | void _XTrace(int hookword, char *fmt, ...); |
---|
250 | #ifdef GPFS_AIX /* AIX doesn't have nor need non blocking trace calls */ |
---|
251 | #define _STraceNB _STrace |
---|
252 | #define _XTraceNB _XTrace |
---|
253 | #else |
---|
254 | void _STraceNB(int hookword, int nArgs, int pos, ...); |
---|
255 | void _XTraceNB(int hookword, char *fmt, ...); |
---|
256 | #endif |
---|
257 | #ifdef __cplusplus |
---|
258 | } |
---|
259 | #endif |
---|
260 | |
---|
261 | |
---|
262 | #ifdef NTRACE |
---|
263 | /* disable all traces */ |
---|
264 | # define _TRACE_MACRO(_c, _l, _ktrc) NOOP |
---|
265 | # define _TRACE_IS_ON(_c, _l) (0) |
---|
266 | #else /* not NTRACE */ |
---|
267 | |
---|
268 | /* Define the test to check whether tracing for given level is enabled. |
---|
269 | Unless VERBOSETRACE is defined, tracing is always disabled for trace |
---|
270 | calls with trace level 10 or higher. */ |
---|
271 | # ifdef VERBOSETRACE |
---|
272 | # define _TRACE_IS_ON(_c,_l) (_GBL_TRC_IS_ON && (signed char)TraceFlagsP[_c] >= (_l)) |
---|
273 | # else |
---|
274 | # define _TRACE_IS_ON(_c,_l) (_GBL_TRC_IS_ON && (_l)<10 && \ |
---|
275 | (signed char) TraceFlagsP[_c] >= (_l)) |
---|
276 | # endif |
---|
277 | |
---|
278 | |
---|
279 | /* Define _TRACE_MACRO(_c, _l, _ktrc) macro. Used to define the actual |
---|
280 | TRACExx macros. Macro parameters: |
---|
281 | _c trace class |
---|
282 | _l trace level |
---|
283 | _ktrc code to execute if kernel tracing is selected */ |
---|
284 | # ifndef _KERNEL |
---|
285 | # define _TRACE_MACRO(_c, _l, _ktrc) \ |
---|
286 | if (_TRACE_IS_ON(_c, _l)) \ |
---|
287 | { _TR_BEFORE; _ktrc; TRCOPTCODE; _TR_AFTER; } else NOOP |
---|
288 | # else /* _KERNEL */ |
---|
289 | # define _TRACE_MACRO(_c, _l, _ktrc) \ |
---|
290 | if (_TRACE_IS_ON(_c, _l)) \ |
---|
291 | { _TR_BEFORE; _ktrc; KTRCOPTCODE; _TR_AFTER; } else NOOP |
---|
292 | # endif /* KERNEL */ |
---|
293 | |
---|
294 | #endif /* not NTRACE */ |
---|
295 | |
---|
296 | |
---|
297 | /* Non blocking versions of trace calls. The succeeding 'N' is |
---|
298 | * significant to mktrcid only and thus these versions are merely |
---|
299 | * redefined to be the real macro. |
---|
300 | */ |
---|
301 | #define TRACE0N TRACE0 |
---|
302 | #define TRACE1N TRACE1 |
---|
303 | #define TRACE2N TRACE2 |
---|
304 | #define TRACE3N TRACE3 |
---|
305 | #define TRACE4N TRACE4 |
---|
306 | #define TRACE5N TRACE5 |
---|
307 | #define TRACE6N TRACE6 |
---|
308 | #define TRACE7N TRACE7 |
---|
309 | #define TRACE8N TRACE8 |
---|
310 | #define TRACE9N TRACE9 |
---|
311 | #define TRACE10N TRACE10 |
---|
312 | #define TRACE11N TRACE11 |
---|
313 | #define TRACE12N TRACE12 |
---|
314 | |
---|
315 | /* General trace macros */ |
---|
316 | #ifndef GPFS_PRINTF |
---|
317 | |
---|
318 | #define TRACE0(_c, _l, id, fmt) \ |
---|
319 | _TRACE_MACRO(_c, _l, TRACE_##id##_CALL) |
---|
320 | #define TRACE1(_c, _l, id, fmt, a1) \ |
---|
321 | _TRACE_MACRO(_c, _l, TRACE_##id##_CALL) |
---|
322 | #define TRACE2(_c, _l, id, fmt, a1, a2) \ |
---|
323 | _TRACE_MACRO(_c, _l, TRACE_##id##_CALL) |
---|
324 | #define TRACE3(_c, _l, id, fmt, a1, a2, a3) \ |
---|
325 | _TRACE_MACRO(_c, _l, TRACE_##id##_CALL) |
---|
326 | #define TRACE4(_c, _l, id, fmt, a1, a2, a3, a4) \ |
---|
327 | _TRACE_MACRO(_c, _l, TRACE_##id##_CALL) |
---|
328 | #define TRACE5(_c, _l, id, fmt, a1, a2, a3, a4, a5) \ |
---|
329 | _TRACE_MACRO(_c, _l, TRACE_##id##_CALL) |
---|
330 | #define TRACE6(_c, _l, id, fmt, a1, a2, a3, a4, a5, a6) \ |
---|
331 | _TRACE_MACRO(_c, _l, TRACE_##id##_CALL) |
---|
332 | #define TRACE7(_c, _l, id, fmt, a1, a2, a3, a4, a5, a6, a7) \ |
---|
333 | _TRACE_MACRO(_c, _l, TRACE_##id##_CALL) |
---|
334 | #define TRACE8(_c, _l, id, fmt, a1, a2, a3, a4, a5, a6, a7, a8) \ |
---|
335 | _TRACE_MACRO(_c, _l, TRACE_##id##_CALL) |
---|
336 | #define TRACE9(_c, _l, id, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9) \ |
---|
337 | _TRACE_MACRO(_c, _l, TRACE_##id##_CALL) |
---|
338 | #define TRACE10(_c, _l, id, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \ |
---|
339 | _TRACE_MACRO(_c, _l, TRACE_##id##_CALL) |
---|
340 | #define TRACE11(_c, _l, id, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) \ |
---|
341 | _TRACE_MACRO(_c, _l, TRACE_##id##_CALL) |
---|
342 | #define TRACE12(_c, _l, id, fmt, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) \ |
---|
343 | _TRACE_MACRO(_c, _l, TRACE_##id##_CALL) |
---|
344 | |
---|
345 | #else /* GPFS_PRINTF */ |
---|
346 | |
---|
347 | #define TRACE0(_c,_l,_id,_fmt) \ |
---|
348 | PDEBUG((_c),(_l),_fmt,1) |
---|
349 | #define TRACE1(_c,_l,_id,_fmt,a1) \ |
---|
350 | PDEBUG((_c),(_l),_fmt,a1) |
---|
351 | #define TRACE2(_c,_l,_id,_fmt,a1,a2) \ |
---|
352 | PDEBUG((_c),(_l),_fmt,a1,a2) |
---|
353 | #define TRACE3(_c,_l,_id,_fmt,a1,a2,a3) \ |
---|
354 | PDEBUG((_c),(_l),_fmt,a1,a2,a3) |
---|
355 | #define TRACE4(_c,_l,_id,_fmt,a1,a2,a3,a4) \ |
---|
356 | PDEBUG((_c),(_l),_fmt,a1,a2,a3,a4) |
---|
357 | #define TRACE5(_c,_l,_id,_fmt,a1,a2,a3,a4,a5) \ |
---|
358 | PDEBUG((_c),(_l),_fmt,a1,a2,a3,a4,a5) |
---|
359 | #define TRACE6(_c,_l,_id,_fmt,a1,a2,a3,a4,a5,a6) \ |
---|
360 | PDEBUG((_c),(_l),_fmt,a1,a2,a3,a4,a5,a6) |
---|
361 | #define TRACE7(_c,_l,_id,_fmt,a1,a2,a3,a4,a5,a6,a7) \ |
---|
362 | PDEBUG((_c),(_l),_fmt,a1,a2,a3,a4,a5,a6,a7) |
---|
363 | #define TRACE8(_c,_l,_id,_fmt,a1,a2,a3,a4,a5,a6,a7,a8) \ |
---|
364 | PDEBUG((_c),(_l),_fmt,a1,a2,a3,a4,a5,a6,a7,a8) |
---|
365 | #define TRACE9(_c,_l,_id,_fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9) \ |
---|
366 | PDEBUG((_c),(_l),_fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9) |
---|
367 | #define TRACE10(_c,_l,_id,_fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \ |
---|
368 | PDEBUG((_c),(_l),_fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) |
---|
369 | #define TRACE11(_c,_l,_id,_fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \ |
---|
370 | PDEBUG((_c),(_l),_fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) |
---|
371 | #define TRACE12(_c,_l,_id,_fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \ |
---|
372 | PDEBUG((_c),(_l),_fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) |
---|
373 | |
---|
374 | |
---|
375 | #endif /* GPFS_PRINTF */ |
---|
376 | |
---|
377 | |
---|
378 | /* Subroutine for setting traces given a string of trace names and values */ |
---|
379 | extern int traceCommand(char *args); |
---|
380 | |
---|
381 | |
---|
382 | /* Routine entry/exit tracing: |
---|
383 | |
---|
384 | In C code, place the macro ENTER(level) at the point of the first |
---|
385 | executable statement of the routine. This will generate a call to |
---|
386 | cxiTraceEntry that will trace the call by function name and source line |
---|
387 | if TRACE_ENTEREXIT is set high enough. Optionally, place the macro |
---|
388 | EXIT(level) at exits from the routine. |
---|
389 | |
---|
390 | In C++ code, place the macro ENTER(level) as the first declaration in |
---|
391 | the routine. This will create an object of type EntryExitTracer, |
---|
392 | whose constructor will call cxiTraceEntry to trace routine entry, and |
---|
393 | whose destructor will call cxiTraceExit to trace routine exit. The |
---|
394 | EXIT macro may appear, but will be ignored. |
---|
395 | |
---|
396 | The trace levels that appear in the ENTER and EXIT macros are interpreted |
---|
397 | relative to a base trace level. Setting the TRACE_ENTEREXIT level < |
---|
398 | BASE_ENTEREXIT_LEVEL disables all enter/exit tracing. To see enter/exit |
---|
399 | traces from daemon code, set the TRACE_ENTEREXIT level to at least |
---|
400 | BASE_ENTEREXIT_LEVEL+DAEMON_ENTEREXIT_TRACING. |
---|
401 | |
---|
402 | Kernel stack depth checking is only supported on Linux, since we do |
---|
403 | not know how to compute the current stack usage on AIX. |
---|
404 | */ |
---|
405 | #ifdef KSTACK_CHECK |
---|
406 | # ifndef GPFS_LINUX |
---|
407 | # error "KSTACK_CHECK is only supported on Linux" |
---|
408 | # endif |
---|
409 | #endif |
---|
410 | |
---|
411 | #if defined(ENTRYEXIT_TRACE) || defined(KSTACK_CHECK) |
---|
412 | # define BASE_ENTEREXIT_LEVEL 6 |
---|
413 | # define DAEMON_ENTEREXIT_TRACING 2 |
---|
414 | # ifdef __cplusplus |
---|
415 | extern "C" void cxiTraceEntry(int level, const char * funcnameP, |
---|
416 | const char * filenameP, int lineNum); |
---|
417 | extern "C" void cxiTraceExit(int level, const char * funcnameP); |
---|
418 | extern "C" void cxiTraceExitRC(int level, const char * funcnameP, int rc); |
---|
419 | class EntryExitTracer |
---|
420 | { |
---|
421 | private: |
---|
422 | /* Trace level */ |
---|
423 | int level; |
---|
424 | |
---|
425 | /* Pointer to routine name */ |
---|
426 | const char * funcnameP; |
---|
427 | |
---|
428 | public: |
---|
429 | /* Constructor: trace routine entry and remember trace level and |
---|
430 | routine name */ |
---|
431 | inline EntryExitTracer(int level, const char * funcnameP, |
---|
432 | const char * filenameP, int lineNum) |
---|
433 | { |
---|
434 | cxiTraceEntry(level, funcnameP, filenameP, lineNum); |
---|
435 | this->level = level; |
---|
436 | this->funcnameP = funcnameP; |
---|
437 | } |
---|
438 | |
---|
439 | /* Destructor: trace routine exit */ |
---|
440 | inline ~EntryExitTracer() |
---|
441 | { |
---|
442 | cxiTraceExit(level, funcnameP); |
---|
443 | } |
---|
444 | }; |
---|
445 | |
---|
446 | # define ENTER(_level) \ |
---|
447 | EntryExitTracer _eet(_level, __FUNCTION__, __FILE__, __LINE__) |
---|
448 | # define EXIT(_level) |
---|
449 | # define EXIT_RC(_level, rc) |
---|
450 | # else |
---|
451 | extern void cxiTraceEntry(int level, const char * funcnameP, |
---|
452 | const char * filenameP, int lineNum); |
---|
453 | extern void cxiTraceExit(int level, const char * funcnameP); |
---|
454 | extern void cxiTraceExitRC(int level, const char * funcnameP, int rc); |
---|
455 | # define ENTER(_level) cxiTraceEntry(_level, __FUNCTION__, __FILE__, __LINE__) |
---|
456 | # define EXIT(_level) cxiTraceExit(_level, __FUNCTION__) |
---|
457 | # define EXIT_RC(_level, rc) cxiTraceExitRC(_level, __FUNCTION__, rc) |
---|
458 | # endif /* __cplusplus */ |
---|
459 | |
---|
460 | #else /* ENTRYEXIT_TRACE and KSTACK_CHECK disabled */ |
---|
461 | # define ENTER(_level) |
---|
462 | # define EXIT(_level) |
---|
463 | # define EXIT_RC(_level, rc) |
---|
464 | #endif /* defined(ENTRYEXIT_TRACE) || defined(KSTACK_CHECK) */ |
---|
465 | |
---|
466 | |
---|
467 | #endif /* _h_Trace */ |
---|