aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2017-01-24 20:28:16 -0500
committerDavid S. Miller <davem@davemloft.net>2017-01-25 13:17:47 -0500
commit2acae0d5b0f73a8fb4b180bd13491feb96e55fc6 (patch)
tree2446a003c916ffd69a70a4ec167848c67aa2305b
parent60b1af3300724d211bb0b420c1fbe6bf5b87b013 (diff)
trace: add variant without spacing in trace_print_hex_seq
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>
-rw-r--r--include/linux/trace_events.h3
-rw-r--r--include/trace/trace_events.h8
-rw-r--r--kernel/trace/trace_output.c7
3 files changed, 13 insertions, 5 deletions
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index be007610ceb0..cfa475a0e9ca 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -33,7 +33,8 @@ const char *trace_print_bitmask_seq(struct trace_seq *p, void *bitmask_ptr,
33 unsigned int bitmask_size); 33 unsigned int bitmask_size);
34 34
35const char *trace_print_hex_seq(struct trace_seq *p, 35const char *trace_print_hex_seq(struct trace_seq *p,
36 const unsigned char *buf, int len); 36 const unsigned char *buf, int len,
37 bool spacing);
37 38
38const char *trace_print_array_seq(struct trace_seq *p, 39const char *trace_print_array_seq(struct trace_seq *p,
39 const void *buf, int count, 40 const void *buf, int count,
diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index 467e12f780d8..9f684629c3cf 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -297,7 +297,12 @@ TRACE_MAKE_SYSTEM_STR();
297#endif 297#endif
298 298
299#undef __print_hex 299#undef __print_hex
300#define __print_hex(buf, buf_len) trace_print_hex_seq(p, buf, buf_len) 300#define __print_hex(buf, buf_len) \
301 trace_print_hex_seq(p, buf, buf_len, true)
302
303#undef __print_hex_str
304#define __print_hex_str(buf, buf_len) \
305 trace_print_hex_seq(p, buf, buf_len, false)
301 306
302#undef __print_array 307#undef __print_array
303#define __print_array(array, count, el_size) \ 308#define __print_array(array, count, el_size) \
@@ -711,6 +716,7 @@ static inline void ftrace_test_probe_##call(void) \
711#undef __print_flags 716#undef __print_flags
712#undef __print_symbolic 717#undef __print_symbolic
713#undef __print_hex 718#undef __print_hex
719#undef __print_hex_str
714#undef __get_dynamic_array 720#undef __get_dynamic_array
715#undef __get_dynamic_array_len 721#undef __get_dynamic_array_len
716#undef __get_str 722#undef __get_str
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 5d33a7352919..30a144b1b9ee 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -163,14 +163,15 @@ trace_print_bitmask_seq(struct trace_seq *p, void *bitmask_ptr,
163EXPORT_SYMBOL_GPL(trace_print_bitmask_seq); 163EXPORT_SYMBOL_GPL(trace_print_bitmask_seq);
164 164
165const char * 165const char *
166trace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len) 166trace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len,
167 bool spacing)
167{ 168{
168 int i; 169 int i;
169 const char *ret = trace_seq_buffer_ptr(p); 170 const char *ret = trace_seq_buffer_ptr(p);
170 171
171 for (i = 0; i < buf_len; i++) 172 for (i = 0; i < buf_len; i++)
172 trace_seq_printf(p, "%s%2.2x", i == 0 ? "" : " ", buf[i]); 173 trace_seq_printf(p, "%s%2.2x", !spacing || i == 0 ? "" : " ",
173 174 buf[i]);
174 trace_seq_putc(p, 0); 175 trace_seq_putc(p, 0);
175 176
176 return ret; 177 return ret;