From 7a555613eb77c69eb6e48b61bc5f72dd42fa1780 Mon Sep 17 00:00:00 2001 From: Vladimir Kondratiev Date: Wed, 5 Dec 2012 16:48:27 -0500 Subject: dynamic_debug: dynamic hex dump Introduce print_hex_dump_debug() that can be dynamically controlled, similar to pr_debug. Also, make print_hex_dump_bytes() dynamically controlled Implement only 'p' flag (_DPRINTK_FLAGS_PRINT) to keep it simple since hex dump prints multiple lines and long prefix would impact readability. To provide line/file etc. information, use pr_debug or similar before/after print_hex_dump_debug() Signed-off-by: Vladimir Kondratiev Signed-off-by: Jason Baron Signed-off-by: Greg Kroah-Hartman --- include/linux/printk.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include/linux/printk.h') diff --git a/include/linux/printk.h b/include/linux/printk.h index 9afc01e5a0a6..02c95cf872cd 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -321,8 +321,13 @@ extern void hex_dump_to_buffer(const void *buf, size_t len, extern void print_hex_dump(const char *level, const char *prefix_str, int prefix_type, int rowsize, int groupsize, const void *buf, size_t len, bool ascii); +#if defined(CONFIG_DYNAMIC_DEBUG) +#define print_hex_dump_bytes(prefix_str, prefix_type, buf, len) \ + dynamic_hex_dump(prefix_str, prefix_type, 16, 1, buf, len, true) +#else extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type, const void *buf, size_t len); +#endif /* defined(CONFIG_DYNAMIC_DEBUG) */ #else static inline void print_hex_dump(const char *level, const char *prefix_str, int prefix_type, int rowsize, int groupsize, @@ -336,4 +341,16 @@ static inline void print_hex_dump_bytes(const char *prefix_str, int prefix_type, #endif +#if defined(CONFIG_DYNAMIC_DEBUG) +#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \ + groupsize, buf, len, ascii) \ + dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ + groupsize, buf, len, ascii) +#else +#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \ + groupsize, buf, len, ascii) \ + print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize, \ + groupsize, buf, len, ascii) +#endif /* defined(CONFIG_DYNAMIC_DEBUG) */ + #endif -- cgit v1.2.3-59-g8ed1b