* [RFC v2 0/2] hexdump dynamic debug @ 2011-03-01 5:06 Bing Zhao 2011-03-01 5:06 ` [RFC v2 1/2] dynamic debug: add dynamic_hexdump_debug macro Bing Zhao 2011-03-01 5:06 ` [RFC v2 2/2] printk: add hexdump_debug macro Bing Zhao 0 siblings, 2 replies; 5+ messages in thread From: Bing Zhao @ 2011-03-01 5:06 UTC (permalink / raw) To: linux-kernel Cc: linux-wireless, John W. Linville, Johannes Berg, Amitkumar Karwar, Kiran Divekar, Frank Huang, Bing Zhao This patchset adds hexdump macros utilizing dynamic debug. v2: rebase against linux-next.git tree and split into 2 patches Bing Zhao (2): dynamic debug: add dynamic_hexdump_debug macro printk: add hexdump_debug macro include/linux/dynamic_debug.h | 22 ++++++++++++++++++++++ include/linux/printk.h | 14 ++++++++++++++ 2 files changed, 36 insertions(+), 0 deletions(-) ^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC v2 1/2] dynamic debug: add dynamic_hexdump_debug macro 2011-03-01 5:06 [RFC v2 0/2] hexdump dynamic debug Bing Zhao @ 2011-03-01 5:06 ` Bing Zhao 2011-03-01 5:25 ` Joe Perches 2011-03-01 5:06 ` [RFC v2 2/2] printk: add hexdump_debug macro Bing Zhao 1 sibling, 1 reply; 5+ messages in thread From: Bing Zhao @ 2011-03-01 5:06 UTC (permalink / raw) To: linux-kernel Cc: linux-wireless, John W. Linville, Johannes Berg, Amitkumar Karwar, Kiran Divekar, Frank Huang, Bing Zhao dynamic_hexdump_debug(str, buf, len) str: "subject string" buf: buffer pointer len: length of the buffer being printed Signed-off-by: Bing Zhao <bzhao@marvell.com> --- include/linux/dynamic_debug.h | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 0c9653f..429a176 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -70,6 +70,19 @@ extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ } while (0) +#define dynamic_hexdump_debug(str, buf, len) \ +do { \ + static struct _ddebug descriptor \ + __used \ + __attribute__((section("__verbose"), aligned(8))) = \ + { KBUILD_MODNAME, __func__, __FILE__, str, __LINE__, \ + _DPRINTK_FLAGS_DEFAULT }; \ + if (unlikely(descriptor.enabled)) { \ + printk(KERN_DEBUG str); \ + print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, len); \ + } \ +} while (0) + #else static inline int ddebug_remove_module(const char *mod) @@ -81,6 +94,15 @@ static inline int ddebug_remove_module(const char *mod) do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0) #define dynamic_dev_dbg(dev, fmt, ...) \ do { if (0) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); } while (0) + +#define dynamic_hexdump_debug(str, buf, len) \ +do { \ + if (0) { \ + printk(KERN_DEBUG str); \ + print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, len); \ + } \ +} while (0) + #endif #endif -- 1.6.2.5 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC v2 1/2] dynamic debug: add dynamic_hexdump_debug macro 2011-03-01 5:06 ` [RFC v2 1/2] dynamic debug: add dynamic_hexdump_debug macro Bing Zhao @ 2011-03-01 5:25 ` Joe Perches 2011-03-01 19:33 ` Bing Zhao 0 siblings, 1 reply; 5+ messages in thread From: Joe Perches @ 2011-03-01 5:25 UTC (permalink / raw) To: Bing Zhao Cc: linux-kernel, linux-wireless, John W. Linville, Johannes Berg, Amitkumar Karwar, Kiran Divekar, Frank Huang On Mon, 2011-02-28 at 21:06 -0800, Bing Zhao wrote: > dynamic_hexdump_debug(str, buf, len) > diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h > +#define dynamic_hexdump_debug(str, buf, len) \ > +do { \ > + static struct _ddebug descriptor \ > + __used \ > + __attribute__((section("__verbose"), aligned(8))) = \ > + { KBUILD_MODNAME, __func__, __FILE__, str, __LINE__, \ > + _DPRINTK_FLAGS_DEFAULT }; \ > + if (unlikely(descriptor.enabled)) { \ > + printk(KERN_DEBUG str); \ > + print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, len); \ Perhaps print_hex_dump(str, DUMP_PREFIX_OFFSET, buf, len); ^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [RFC v2 1/2] dynamic debug: add dynamic_hexdump_debug macro 2011-03-01 5:25 ` Joe Perches @ 2011-03-01 19:33 ` Bing Zhao 0 siblings, 0 replies; 5+ messages in thread From: Bing Zhao @ 2011-03-01 19:33 UTC (permalink / raw) To: Joe Perches Cc: linux-kernel, linux-wireless, John W. Linville, Johannes Berg, Amitkumar Karwar, Kiran Divekar, Frank Huang [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1983 bytes --] Hi Joe, > -----Original Message----- > From: Joe Perches [mailto:joe@perches.com] > Sent: Monday, February 28, 2011 9:26 PM > To: Bing Zhao > Cc: linux-kernel@vger.kernel.org; linux-wireless@vger.kernel.org; John W. Linville; Johannes Berg; > Amitkumar Karwar; Kiran Divekar; Frank Huang > Subject: Re: [RFC v2 1/2] dynamic debug: add dynamic_hexdump_debug macro > > On Mon, 2011-02-28 at 21:06 -0800, Bing Zhao wrote: > > dynamic_hexdump_debug(str, buf, len) > > > diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h > > +#define dynamic_hexdump_debug(str, buf, len) \ > > +do { \ > > + static struct _ddebug descriptor \ > > + __used \ > > + __attribute__((section("__verbose"), aligned(8))) = \ > > + { KBUILD_MODNAME, __func__, __FILE__, str, __LINE__, \ > > + _DPRINTK_FLAGS_DEFAULT }; \ > > + if (unlikely(descriptor.enabled)) { \ > > + printk(KERN_DEBUG str); \ > > + print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, len); \ > > Perhaps > print_hex_dump(str, DUMP_PREFIX_OFFSET, buf, len); I wanted to print the "str" as a subject line, like this: mwifiex data: tx_buf: 00000000: 34 8c 24 a0 ff ff ff ff 36 72 24 a0 ff ff ff ff 4.$.....6r$..... 00000010: d7 7f 24 a0 ff ff ff ff 80 8e 24 a0 ff ff ff ff ..$.......$..... 00000020: df 7d 24 a0 ff ff .}$... The "str" will serve as the prefix strings if we use print_hex_dump(KERN_DEBUG, str, DUMP_PREFIX_OFFSET, 16, 1, buf, len, true); mwifiex data: tx_buf:00000000: 34 8c 24 a0 ff ff ff ff 36 72 24 a0 ff ff ff ff 4.$.....6r$..... mwifiex data: tx_buf:00000010: d7 7f 24 a0 ff ff ff ff 80 8e 24 a0 ff ff ff ff ..$.......$..... mwifiex data: tx_buf:00000020: df 7d 24 a0 ff ff .}$... I'm okay with this format too. Thanks, Bing ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥ ^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC v2 2/2] printk: add hexdump_debug macro 2011-03-01 5:06 [RFC v2 0/2] hexdump dynamic debug Bing Zhao 2011-03-01 5:06 ` [RFC v2 1/2] dynamic debug: add dynamic_hexdump_debug macro Bing Zhao @ 2011-03-01 5:06 ` Bing Zhao 1 sibling, 0 replies; 5+ messages in thread From: Bing Zhao @ 2011-03-01 5:06 UTC (permalink / raw) To: linux-kernel Cc: linux-wireless, John W. Linville, Johannes Berg, Amitkumar Karwar, Kiran Divekar, Frank Huang, Bing Zhao hexdump_debug(str, buf, len) str: "subject string" buf: buffer pointer len: length of the buffer being printed usage: hexdump_debug("mwifiex data: tx_buf:\n", tx_buf, 32); Signed-off-by: Bing Zhao <bzhao@marvell.com> --- include/linux/printk.h | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/include/linux/printk.h b/include/linux/printk.h index ee048e7..c758131 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -299,4 +299,18 @@ static inline void print_hex_dump_bytes(const char *prefix_str, int prefix_type, #endif +#if defined(DEBUG) +#define hexdump_debug(str, buf, len) \ +do { \ + printk(KERN_DEBUG str); \ + print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, len); \ +} while (0) +#elif defined(CONFIG_DYNAMIC_DEBUG) +#define hexdump_debug(str, buf, len) \ + dynamic_hexdump_debug(str, buf, len) +#else +#define hexdump_debug(str, buf, len) \ + no_printk(KERN_DEBUG str) +#endif + #endif -- 1.6.2.5 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-03-01 19:34 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-03-01 5:06 [RFC v2 0/2] hexdump dynamic debug Bing Zhao 2011-03-01 5:06 ` [RFC v2 1/2] dynamic debug: add dynamic_hexdump_debug macro Bing Zhao 2011-03-01 5:25 ` Joe Perches 2011-03-01 19:33 ` Bing Zhao 2011-03-01 5:06 ` [RFC v2 2/2] printk: add hexdump_debug macro Bing Zhao
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®