Skip to contentSkip to conversation

scsi: add __print_hex() to ftrace

PATCH Superseded Kei Tokunaga 3 participants 3 messages Jan 20, 2010

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 scsi: add __print_hex() to ftrace

From: Li Zefan <[email protected]>

__print_hex() prints values in an array in hex (w/o '0x') (space separated) EX) 92 33 32 f3 ee 4d

---

 linux-2.6.33-rc4-trace-kei/include/linux/ftrace_event.h |    3 +++
 linux-2.6.33-rc4-trace-kei/include/trace/ftrace.h       |    3 +++
 linux-2.6.33-rc4-trace-kei/kernel/trace/trace_output.c  |   15 +++++++++++++++
 3 files changed, 21 insertions(+)
include/linux/ftrace_event.h renamed from include/linux/ftrace_event.h~ftrace_print_hex +3 -0
diff -puN include/linux/ftrace_event.h~ftrace_print_hex include/linux/ftrace_event.h
@@ -24,6 +24,9 @@ const char *ftrace_print_flags_seq(struc
 const char *ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val,
 				     const struct trace_print_flags *symbol_array);
 
+const char *ftrace_print_hex_seq(struct trace_seq *p,
+				 const unsigned char *buf, int len);
+
 /*
  * The trace entry - the most basic unit of tracing. This is what
  * is printed in the end as a single line in the trace output, such as:
kernel/trace/trace_output.c renamed from kernel/trace/trace_output.c~ftrace_print_hex +15 -0
diff -puN kernel/trace/trace_output.c~ftrace_print_hex kernel/trace/trace_output.c
@@ -355,6 +355,21 @@ ftrace_print_symbols_seq(struct trace_se
 }
 EXPORT_SYMBOL(ftrace_print_symbols_seq);
 
+const char *
+ftrace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len)
+{
+	int i;
+	const char *ret = p->buffer + p->len;
+
+	for (i = 0; i < buf_len; i++)
+		trace_seq_printf(p, "%s%2.2x", i == 0 ? "" : " ", buf[i]);
+
+	trace_seq_putc(p, 0);
+
+	return ret;
+}
+EXPORT_SYMBOL(ftrace_print_hex_seq);
+
 #ifdef CONFIG_KRETPROBES
 static inline const char *kretprobed(const char *name)
 {
include/trace/ftrace.h renamed from include/trace/ftrace.h~ftrace_print_hex +3 -0
diff -puN include/trace/ftrace.h~ftrace_print_hex include/trace/ftrace.h
@@ -321,6 +321,9 @@ ftrace_format_##name(struct ftrace_event
 		ftrace_print_symbols_seq(p, value, symbols);		\
 	})
 
+#undef __print_hex
+#define __print_hex(buf, buf_len) ftrace_print_hex_seq(p, buf, buf_len)
+
 #undef DECLARE_EVENT_CLASS
 #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
 static enum print_line_t						\

_

#1 lore raw
Quoted 7 lines · Kei Tokunaga

diff -puN kernel/trace/trace_output.c~ftrace_print_hex kernel/trace/trace_output.c

kernel/trace/trace_output.c renamed from kernel/trace/trace_output.c~ftrace_print_hex +0 -0
@@ -355,6 +355,21 @@ ftrace_print_symbols_seq(struct trace_se
 }
 EXPORT_SYMBOL(ftrace_print_symbols_seq);
 

kernel/trace/trace_output.c ftrace_print_symbols_seq(struct trace_se · line 367

Quoted 10 lines
kernel/trace/trace_output.c renamed from kernel/trace/trace_output.c~ftrace_print_hex +10 -0
+const char *
+ftrace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len)
+{
+	int i;
+	const char *ret = p->buffer + p->len;
+
+	for (i = 0; i < buf_len; i++)
+		trace_seq_printf(p, "%s%2.2x", i == 0 ? "" : " ", buf[i]);
+
+	trace_seq_putc(p, 0);

hex_dump_to_buffer?

#2 lore raw
Quoted 8 lines · Joe Perches
Quoted 7 lines · Kei Tokunaga

diff -puN kernel/trace/trace_output.c~ftrace_print_hex kernel/trace/trace_output.c

kernel/trace/trace_output.c renamed from kernel/trace/trace_output.c~ftrace_print_hex +0 -0
@@ -355,6 +355,21 @@ ftrace_print_symbols_seq(struct trace_se
 }
 EXPORT_SYMBOL(ftrace_print_symbols_seq);
 
Quoted 13 lines

kernel/trace/trace_output.c ftrace_print_symbols_seq(struct trace_se · line 367

Quoted 10 lines
kernel/trace/trace_output.c renamed from kernel/trace/trace_output.c~ftrace_print_hex +10 -0
+const char *
+ftrace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len)
+{
+	int i;
+	const char *ret = p->buffer + p->len;
+
+	for (i = 0; i < buf_len; i++)
+		trace_seq_printf(p, "%s%2.2x", i == 0 ? "" : " ", buf[i]);
+
+	trace_seq_putc(p, 0);

hex_dump_to_buffer?

hex_dump_to_buffer has some limitations. For example, you have to specify:

@rowsize: number of bytes to print per line; must be 16 or 32

We can change hex_dump_to_buffer() to fit our needs, but let us do that later.