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.h81
1 files changed, 51 insertions, 30 deletions
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index e747ecd48e1c..0564e3c39882 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,
@@ -44,29 +37,57 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
44 37
45#if defined(CONFIG_DYNAMIC_DEBUG) 38#if defined(CONFIG_DYNAMIC_DEBUG)
46extern int ddebug_remove_module(const char *mod_name); 39extern int ddebug_remove_module(const char *mod_name);
47extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) 40extern __printf(2, 3)
48 __attribute__ ((format (printf, 2, 3))); 41int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...);
49 42
50#define dynamic_pr_debug(fmt, ...) do { \ 43struct device;
51 static struct _ddebug descriptor \ 44
52 __used \ 45extern __printf(3, 4)
53 __attribute__((section("__verbose"), aligned(8))) = \ 46int __dynamic_dev_dbg(struct _ddebug *descriptor, const struct device *dev,
54 { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \ 47 const char *fmt, ...);
55 _DPRINTK_FLAGS_DEFAULT }; \ 48
56 if (unlikely(descriptor.enabled)) \ 49struct net_device;
57 __dynamic_pr_debug(&descriptor, pr_fmt(fmt), ##__VA_ARGS__); \ 50
58 } while (0) 51extern __printf(3, 4)
59 52int __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
63 __used \ 56#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \
64 __attribute__((section("__verbose"), aligned(8))) = \ 57 static struct _ddebug __used __aligned(8) \
65 { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__, \ 58 __attribute__((section("__verbose"))) name = { \
66 _DPRINTK_FLAGS_DEFAULT }; \ 59 .modname = KBUILD_MODNAME, \
67 if (unlikely(descriptor.enabled)) \ 60 .function = __func__, \
68 dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ 61 .filename = __FILE__, \
69 } while (0) 62 .format = (fmt), \
63 .lineno = __LINE__, \
64 .flags = _DPRINTK_FLAGS_DEFAULT, \
65 .enabled = false, \
66 }
67
68#define dynamic_pr_debug(fmt, ...) \
69do { \
70 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
71 if (unlikely(descriptor.enabled)) \
72 __dynamic_pr_debug(&descriptor, pr_fmt(fmt), \
73 ##__VA_ARGS__); \
74} while (0)
75
76#define dynamic_dev_dbg(dev, fmt, ...) \
77do { \
78 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
79 if (unlikely(descriptor.enabled)) \
80 __dynamic_dev_dbg(&descriptor, dev, fmt, \
81 ##__VA_ARGS__); \
82} while (0)
83
84#define dynamic_netdev_dbg(dev, fmt, ...) \
85do { \
86 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
87 if (unlikely(descriptor.enabled)) \
88 __dynamic_netdev_dbg(&descriptor, dev, fmt, \
89 ##__VA_ARGS__); \
90} while (0)
70 91
71#else 92#else
72 93