2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
14 #if !defined(OPENAFS_DEBUG_H)
15 #define OPENAFS_DEBUG_H
18 * Define debugging levels, from 1 being lowest priority and 7 being
19 * highest priority. DEBUG_LEVEL_0 and DEBUG_FORCE_PRINT mean to
20 * print the message regardless of the current setting.
22 #define DEBUG_LEVEL_0 0
23 #define DEBUG_LEVEL_1 01
24 #define DEBUG_LEVEL_2 03
25 #define DEBUG_LEVEL_3 07
26 #define DEBUG_LEVEL_4 017
27 #define DEBUG_LEVEL_5 037
28 #define DEBUG_LEVEL_6 077
29 #define DEBUG_LEVEL_7 0177
31 #define DEBUG_FORCE_PRINT DEBUG_LEVEL_0
33 #if defined(AFS_DEBUG)
39 * In user space call abort();
44 if(!(x)) { printf("assertion failed: line %d, file %s\n",\
45 __LINE__,__FILE__); osi_Panic("assert"); }
50 #define CM_DEBUG 0 /* Cache Manager */
51 #define EX_DEBUG 1 /* Protocol Exporter */
52 #define HS_DEBUG 2 /* Host Module */
53 #define VL_DEBUG 3 /* Volume Module */
55 #define AG_DEBUG 4 /* Aggregate Module */
56 #define VR_DEBUG 5 /* Volume Registry Module */
57 #define RX_DEBUG 6 /* RPC/Rx Module */
58 #define XVFS_DEBUG 7 /* Xvnode Module */
60 #define NFSTR_DEBUG 8 /* NFS/AFS Translator Module */
61 #define XCRED_DEBUG 9 /* Extended Credential Module */
62 #define FP_DEBUG 10 /* Free Pool Module */
63 #define ACL_DEBUG 11 /* ACL Module */
64 #define FSHS_DEBUG 12 /* File server host module */
66 #define MAXMODS_DEBUG 20
68 #ifdef AFSDEBUG_DECLARE
70 * Should get here only once per kernel instance!
72 char afsdebug[MAXMODS_DEBUG] =
73 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
78 * Compare the given debugging level against the setting of the particular
79 * index into the afsdebug char array. If there are bits in common, or else
80 * if if the level is DEBUG_FORCE_PRINT, then produce debugging output with
81 * the rest of the arguments provided.
83 * NOTE: This should become a macro!
85 AFSLOG(index, level, a, b, c, d, e, f, g, h, i, j, k, l, m, n)
86 char index, level, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j, *k, *l, *m,
89 if ((afsdebug[index] & level) || !level)
90 osi_dp(a, b, c, d, e, f, g, h, i, j, k, l, m, n);
93 extern char afsdebug[20];
94 #endif /* AFSDEBUG_DECLARE */
98 if(!(x)) { fprintf(stderr, "assertion failed: line %d, file %s\n",\
99 __LINE__,__FILE__); fflush(stderr); abort(); }
102 #else /* AFS_DEBUG */
106 #endif /* AFS_DEBUG */
109 * Debugging macro package. The actual variables should be declared in
113 #if defined(AFS_DEBUG)
115 #define afs_dprintf(flag, str) printf str
116 #define dlprintf(flag, level, str) printf str
117 #define dmprintf(flag, bit, str) printf str
119 #define afs_dprintf(flag, str) \
121 ( osi_dp str, osi_dp("\t%s, %d\n", __FILE__, __LINE__)):0)
122 #define dlprintf(flag, level, str) afs_dprintf(((flag) >= (level)), str)
123 #define dmprintf(flag, bit, str) afs_dprintf(((flag)&(1<<((bit)-1))), str)
127 #else /* AFS_DEBUG */
129 #define afs_dprintf(flag, str)
130 #define dlprintf(flag, level,str)
131 #define dmprintf(flag, bit, str)
133 #endif /* AFS_DEBUG */
135 #endif /* OPENAFS_DEBUG_H */