xref: /OK3568_Linux_fs/kernel/include/linux/ceph/ceph_debug.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _FS_CEPH_DEBUG_H
3*4882a593Smuzhiyun #define _FS_CEPH_DEBUG_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #include <linux/string.h>
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #ifdef CONFIG_CEPH_LIB_PRETTYDEBUG
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun /*
12*4882a593Smuzhiyun  * wrap pr_debug to include a filename:lineno prefix on each line.
13*4882a593Smuzhiyun  * this incurs some overhead (kernel size and execution time) due to
14*4882a593Smuzhiyun  * the extra function call at each call site.
15*4882a593Smuzhiyun  */
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun # if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
18*4882a593Smuzhiyun #  define dout(fmt, ...)						\
19*4882a593Smuzhiyun 	pr_debug("%.*s %12.12s:%-4d : " fmt,				\
20*4882a593Smuzhiyun 		 8 - (int)sizeof(KBUILD_MODNAME), "    ",		\
21*4882a593Smuzhiyun 		 kbasename(__FILE__), __LINE__, ##__VA_ARGS__)
22*4882a593Smuzhiyun # else
23*4882a593Smuzhiyun /* faux printk call just to see any compiler warnings. */
24*4882a593Smuzhiyun #  define dout(fmt, ...)	do {				\
25*4882a593Smuzhiyun 		if (0)						\
26*4882a593Smuzhiyun 			printk(KERN_DEBUG fmt, ##__VA_ARGS__);	\
27*4882a593Smuzhiyun 	} while (0)
28*4882a593Smuzhiyun # endif
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun #else
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun /*
33*4882a593Smuzhiyun  * or, just wrap pr_debug
34*4882a593Smuzhiyun  */
35*4882a593Smuzhiyun # define dout(fmt, ...)	pr_debug(" " fmt, ##__VA_ARGS__)
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun #endif
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun #endif
40