aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/dynamic_debug.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/dynamic_debug.h')
-rw-r--r--include/linux/dynamic_debug.h76
1 files changed, 49 insertions, 27 deletions
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index e747ecd48e1c..13aae8087b56 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -1,13 +1,6 @@
1#ifndef _DYNAMIC_DEBUG_H 1#ifndef _DYNAMIC_DEBUG_H
2#define _DYNAMIC_DEBUG_H 2#define _DYNAMIC_DEBUG_H
3 3
4/* dynamic_printk_enabled, and dynamic_printk_enabled2 are bitmasks in which
5 * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They
6 * use independent hash functions, to reduce the chance of false positives.
7 */
8extern long long dynamic_debug_enabled;
9extern long long dynamic_debug_enabled2;
10
11/* 4/*
12 * An instance of this structure is created in a special 5 * An instance of this structure is created in a special
13 * ELF section at every dynamic debug callsite. At runtime, 6 * ELF section at every dynamic debug callsite. At runtime,
@@ -47,26 +40,55 @@ extern int ddebug_remove_module(const char *mod_name);
47extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) 40extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
48 __attribute__ ((format (printf, 2, 3))); 41 __attribute__ ((format (printf, 2, 3)));
49 42
50#define dynamic_pr_debug(fmt, ...) do { \ 43struct device;
51 static struct _ddebug descriptor \ 44
52 __used \ 45extern int __dynamic_dev_dbg(struct _ddebug *descriptor,
53 __attribute__((section("__verbose"), aligned(8))) = \ 46 const struct device *dev,
54 { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \ 47 const char *fmt, ...)
55 _DPRINTK_FLAGS_DEFAULT }; \ 48 __attribute__ ((format (printf, 3, 4)));
56 if (unlikely(descriptor.enabled)) \ 49
57 __dynamic_pr_debug(&descriptor, pr_fmt(fmt), ##__VA_ARGS__); \ 50struct net_device;
58 } while (0) 51
59 52extern int __dynamic_netdev_dbg(struct _ddebug *descriptor,
60 53 const struct net_device *dev,
61#define dynamic_dev_dbg(dev, fmt, ...) do { \ 54 const char *fmt, ...)
62 static struct _ddebug descriptor \ 55 __attribute__ ((format (printf, 3, 4)));
63 __used \ 56
64 __attribute__((section("__verbose"), aligned(8))) = \ 57#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \
65 { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \ 58 static struct _ddebug __used __aligned(8) \
66 _DPRINTK_FLAGS_DEFAULT }; \ 59 __attribute__((section("__verbose"))) name = { \
67 if (unlikely(descriptor.enabled)) \ 60 .modname = KBUILD_MODNAME, \
68 dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ 61 .function = __func__, \
69 } while (0) 62 .filename = __FILE__, \
63 .format = (fmt), \
64 .lineno = __LINE__, \
65 .flags = _DPRINTK_FLAGS_DEFAULT, \
66 .enabled = false, \
67 }
68
69#define dynamic_pr_debug(fmt, ...) \
70do { \
71 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
72 if (unlikely(descriptor.enabled)) \
73 __dynamic_pr_debug(&descriptor, pr_fmt(fmt), \
74 ##__VA_ARGS__); \
75} while (0)
76
77#define dynamic_dev_dbg(dev, fmt, ...) \
78do { \
79 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
80 if (unlikely(descriptor.enabled)) \
81 __dynamic_dev_dbg(&descriptor, dev, fmt, \
82 ##__VA_ARGS__); \
83} while (0)
84
85#define dynamic_netdev_dbg(dev, fmt, ...) \
86do { \
87 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
88 if (unlikely(descriptor.enabled)) \
89 __dynamic_netdev_dbg(&descriptor, dev, fmt, \
90 ##__VA_ARGS__); \
91} while (0)
70 92
71#else 93#else
72 94