trace: add variant without spacing in trace_print_hex_seq
authorDaniel Borkmann <daniel@iogearbox.net>
Wed, 25 Jan 2017 01:28:16 +0000 (02:28 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 25 Jan 2017 18:17:47 +0000 (13:17 -0500)
For upcoming tracepoint support for BPF, we want to dump the program's
tag. Format should be similar to __print_hex(), but without spacing.
Add a __print_hex_str() variant for exactly that purpose that reuses
trace_print_hex_seq().

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/trace_events.h
include/trace/trace_events.h
kernel/trace/trace_output.c

index be007610ceb08aaa7cad1073effe73b24adff66d..cfa475a0e9ca31dca792bcc053f9514e688a2997 100644 (file)
@@ -33,7 +33,8 @@ const char *trace_print_bitmask_seq(struct trace_seq *p, void *bitmask_ptr,
                                    unsigned int bitmask_size);
 
 const char *trace_print_hex_seq(struct trace_seq *p,
-                               const unsigned char *buf, int len);
+                               const unsigned char *buf, int len,
+                               bool spacing);
 
 const char *trace_print_array_seq(struct trace_seq *p,
                                   const void *buf, int count,
index 467e12f780d863956b1b1b650c406d9d4cb5c0c2..9f684629c3cf1e3e6c4117253ea2f11679b9e258 100644 (file)
@@ -297,7 +297,12 @@ TRACE_MAKE_SYSTEM_STR();
 #endif
 
 #undef __print_hex
-#define __print_hex(buf, buf_len) trace_print_hex_seq(p, buf, buf_len)
+#define __print_hex(buf, buf_len)                                      \
+       trace_print_hex_seq(p, buf, buf_len, true)
+
+#undef __print_hex_str
+#define __print_hex_str(buf, buf_len)                                  \
+       trace_print_hex_seq(p, buf, buf_len, false)
 
 #undef __print_array
 #define __print_array(array, count, el_size)                           \
@@ -711,6 +716,7 @@ static inline void ftrace_test_probe_##call(void)                   \
 #undef __print_flags
 #undef __print_symbolic
 #undef __print_hex
+#undef __print_hex_str
 #undef __get_dynamic_array
 #undef __get_dynamic_array_len
 #undef __get_str
index 5d33a7352919853e3d586f20a84f8d12b3d88bbb..30a144b1b9eeb316a847a8d384ccba91b6e41bcf 100644 (file)
@@ -163,14 +163,15 @@ trace_print_bitmask_seq(struct trace_seq *p, void *bitmask_ptr,
 EXPORT_SYMBOL_GPL(trace_print_bitmask_seq);
 
 const char *
-trace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len)
+trace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len,
+                   bool spacing)
 {
        int i;
        const char *ret = trace_seq_buffer_ptr(p);
 
        for (i = 0; i < buf_len; i++)
-               trace_seq_printf(p, "%s%2.2x", i == 0 ? "" : " ", buf[i]);
-
+               trace_seq_printf(p, "%s%2.2x", !spacing || i == 0 ? "" : " ",
+                                buf[i]);
        trace_seq_putc(p, 0);
 
        return ret;