diff options
author | Allan Stephens <Allan.Stephens@windriver.com> | 2010-12-31 13:59:28 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-01-01 16:57:54 -0500 |
commit | 6e7e309c62ab584348e0fef90c8e3e48f634dba1 (patch) | |
tree | feb74fd531cc6244e706bb6ee76403590cb1cdc4 /net/tipc | |
parent | 8d64a5ba58157dedc61f3f1f51e1c5d66f32a484 (diff) |
tipc: Finish streamlining of debugging code
Completes the simplification of TIPC's debugging capabilities. By default
TIPC includes no debugging code, and any debugging code added by developers
that calls the dbg() and dbg_macros() is compiled out. If debugging support
is enabled, TIPC prints out some additional data about its internal state
when certain abnormal conditions occur, and any developer-added calls to the
TIPC debug macros are compiled in.
Signed-off-by: Allan Stephens <Allan.Stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/Kconfig | 11 | ||||
-rw-r--r-- | net/tipc/core.h | 47 | ||||
-rw-r--r-- | net/tipc/log.c | 4 | ||||
-rw-r--r-- | net/tipc/msg.c | 1 |
4 files changed, 18 insertions, 45 deletions
diff --git a/net/tipc/Kconfig b/net/tipc/Kconfig index c02d3e9c156d..0e7ce30fd567 100644 --- a/net/tipc/Kconfig +++ b/net/tipc/Kconfig | |||
@@ -67,12 +67,15 @@ config TIPC_LOG | |||
67 | managed remotely via TIPC. | 67 | managed remotely via TIPC. |
68 | 68 | ||
69 | config TIPC_DEBUG | 69 | config TIPC_DEBUG |
70 | bool "Enable debug messages" | 70 | bool "Enable debugging support" |
71 | default n | 71 | default n |
72 | help | 72 | help |
73 | This enables debugging of TIPC. | 73 | Saying Y here enables TIPC debugging capabilities used by developers. |
74 | Most users do not need to bother; if unsure, just say N. | ||
74 | 75 | ||
75 | Only say Y here if you are having trouble with TIPC. It will | 76 | Enabling debugging support causes TIPC to display data about its |
76 | enable the display of detailed information about what is going on. | 77 | internal state when certain abnormal conditions occur. It also |
78 | makes it easy for developers to capture additional information of | ||
79 | interest using the dbg() or msg_dbg() macros. | ||
77 | 80 | ||
78 | endif # TIPC | 81 | endif # TIPC |
diff --git a/net/tipc/core.h b/net/tipc/core.h index 3af0b36e3f1a..997158546e25 100644 --- a/net/tipc/core.h +++ b/net/tipc/core.h | |||
@@ -83,6 +83,7 @@ struct print_buf; /* log.h */ | |||
83 | * user-defined buffers can be configured to do the same thing. | 83 | * user-defined buffers can be configured to do the same thing. |
84 | */ | 84 | */ |
85 | extern struct print_buf *const TIPC_NULL; | 85 | extern struct print_buf *const TIPC_NULL; |
86 | extern struct print_buf *const TIPC_CONS; | ||
86 | extern struct print_buf *const TIPC_LOG; | 87 | extern struct print_buf *const TIPC_LOG; |
87 | 88 | ||
88 | void tipc_printf(struct print_buf *, const char *fmt, ...); | 89 | void tipc_printf(struct print_buf *, const char *fmt, ...); |
@@ -95,56 +96,26 @@ void tipc_printf(struct print_buf *, const char *fmt, ...); | |||
95 | #define TIPC_OUTPUT TIPC_LOG | 96 | #define TIPC_OUTPUT TIPC_LOG |
96 | #endif | 97 | #endif |
97 | 98 | ||
98 | /* | ||
99 | * TIPC can be configured to send system messages to TIPC_OUTPUT | ||
100 | * or to the system console only. | ||
101 | */ | ||
102 | |||
103 | #ifdef CONFIG_TIPC_DEBUG | ||
104 | |||
105 | #define err(fmt, arg...) tipc_printf(TIPC_OUTPUT, \ | 99 | #define err(fmt, arg...) tipc_printf(TIPC_OUTPUT, \ |
106 | KERN_ERR "TIPC: " fmt, ## arg) | 100 | KERN_ERR "TIPC: " fmt, ## arg) |
107 | #define warn(fmt, arg...) tipc_printf(TIPC_OUTPUT, \ | 101 | #define warn(fmt, arg...) tipc_printf(TIPC_OUTPUT, \ |
108 | KERN_WARNING "TIPC: " fmt, ## arg) | 102 | KERN_WARNING "TIPC: " fmt, ## arg) |
109 | #define info(fmt, arg...) tipc_printf(TIPC_OUTPUT, \ | 103 | #define info(fmt, arg...) tipc_printf(TIPC_OUTPUT, \ |
110 | KERN_NOTICE "TIPC: " fmt, ## arg) | 104 | KERN_NOTICE "TIPC: " fmt, ## arg) |
111 | |||
112 | #else | ||
113 | 105 | ||
114 | #define err(fmt, arg...) printk(KERN_ERR "TIPC: " fmt , ## arg) | 106 | #ifdef CONFIG_TIPC_DEBUG |
115 | #define info(fmt, arg...) printk(KERN_INFO "TIPC: " fmt , ## arg) | ||
116 | #define warn(fmt, arg...) printk(KERN_WARNING "TIPC: " fmt , ## arg) | ||
117 | |||
118 | #endif | ||
119 | 107 | ||
120 | /* | 108 | /* |
121 | * DBG_OUTPUT is the destination print buffer for debug messages. | 109 | * DBG_OUTPUT is the destination print buffer for debug messages. |
122 | * It defaults to the the null print buffer, but can be redefined | ||
123 | * (typically in the individual .c files being debugged) to allow | ||
124 | * selected debug messages to be generated where needed. | ||
125 | */ | 110 | */ |
126 | 111 | ||
127 | #ifndef DBG_OUTPUT | 112 | #ifndef DBG_OUTPUT |
128 | #define DBG_OUTPUT TIPC_NULL | 113 | #define DBG_OUTPUT TIPC_LOG |
129 | #endif | 114 | #endif |
130 | 115 | ||
131 | /* | 116 | #define dbg(fmt, arg...) tipc_printf(DBG_OUTPUT, KERN_DEBUG fmt, ## arg); |
132 | * TIPC can be configured to send debug messages to the specified print buffer | ||
133 | * (typically DBG_OUTPUT) or to suppress them entirely. | ||
134 | */ | ||
135 | |||
136 | #ifdef CONFIG_TIPC_DEBUG | ||
137 | 117 | ||
138 | #define dbg(fmt, arg...) \ | 118 | #define msg_dbg(msg, txt) tipc_msg_dbg(DBG_OUTPUT, msg, txt); |
139 | do { \ | ||
140 | if (DBG_OUTPUT != TIPC_NULL) \ | ||
141 | tipc_printf(DBG_OUTPUT, fmt, ## arg); \ | ||
142 | } while (0) | ||
143 | #define msg_dbg(msg, txt) \ | ||
144 | do { \ | ||
145 | if (DBG_OUTPUT != TIPC_NULL) \ | ||
146 | tipc_msg_dbg(DBG_OUTPUT, msg, txt); \ | ||
147 | } while (0) | ||
148 | 119 | ||
149 | void tipc_msg_dbg(struct print_buf *, struct tipc_msg *, const char *); | 120 | void tipc_msg_dbg(struct print_buf *, struct tipc_msg *, const char *); |
150 | 121 | ||
@@ -153,7 +124,7 @@ void tipc_msg_dbg(struct print_buf *, struct tipc_msg *, const char *); | |||
153 | #define dbg(fmt, arg...) do {} while (0) | 124 | #define dbg(fmt, arg...) do {} while (0) |
154 | #define msg_dbg(msg, txt) do {} while (0) | 125 | #define msg_dbg(msg, txt) do {} while (0) |
155 | 126 | ||
156 | #define tipc_msg_dbg(...) do {} while (0) | 127 | #define tipc_msg_dbg(buf, msg, txt) do {} while (0) |
157 | 128 | ||
158 | #endif | 129 | #endif |
159 | 130 | ||
diff --git a/net/tipc/log.c b/net/tipc/log.c index 2796044f9941..952c39f643e6 100644 --- a/net/tipc/log.c +++ b/net/tipc/log.c | |||
@@ -52,7 +52,7 @@ static struct print_buf null_buf = { NULL, 0, NULL, 0 }; | |||
52 | struct print_buf *const TIPC_NULL = &null_buf; | 52 | struct print_buf *const TIPC_NULL = &null_buf; |
53 | 53 | ||
54 | static struct print_buf cons_buf = { NULL, 0, NULL, 1 }; | 54 | static struct print_buf cons_buf = { NULL, 0, NULL, 1 }; |
55 | static struct print_buf *const TIPC_CONS = &cons_buf; | 55 | struct print_buf *const TIPC_CONS = &cons_buf; |
56 | 56 | ||
57 | static struct print_buf log_buf = { NULL, 0, NULL, 1 }; | 57 | static struct print_buf log_buf = { NULL, 0, NULL, 1 }; |
58 | struct print_buf *const TIPC_LOG = &log_buf; | 58 | struct print_buf *const TIPC_LOG = &log_buf; |
@@ -76,8 +76,6 @@ struct print_buf *const TIPC_LOG = &log_buf; | |||
76 | static char print_string[TIPC_PB_MAX_STR]; | 76 | static char print_string[TIPC_PB_MAX_STR]; |
77 | static DEFINE_SPINLOCK(print_lock); | 77 | static DEFINE_SPINLOCK(print_lock); |
78 | 78 | ||
79 | static void tipc_printbuf_reset(struct print_buf *pb); | ||
80 | static int tipc_printbuf_empty(struct print_buf *pb); | ||
81 | static void tipc_printbuf_move(struct print_buf *pb_to, | 79 | static void tipc_printbuf_move(struct print_buf *pb_to, |
82 | struct print_buf *pb_from); | 80 | struct print_buf *pb_from); |
83 | 81 | ||
diff --git a/net/tipc/msg.c b/net/tipc/msg.c index ee6b4c68d4a4..a029cdc2df6d 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c | |||
@@ -138,6 +138,7 @@ int tipc_msg_build(struct tipc_msg *hdr, | |||
138 | void tipc_msg_dbg(struct print_buf *buf, struct tipc_msg *msg, const char *str) | 138 | void tipc_msg_dbg(struct print_buf *buf, struct tipc_msg *msg, const char *str) |
139 | { | 139 | { |
140 | u32 usr = msg_user(msg); | 140 | u32 usr = msg_user(msg); |
141 | tipc_printf(buf, KERN_DEBUG); | ||
141 | tipc_printf(buf, str); | 142 | tipc_printf(buf, str); |
142 | 143 | ||
143 | switch (usr) { | 144 | switch (usr) { |