diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2017-01-25 02:28:17 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-01-25 13:17:47 -0500 |
commit | 0fe05591790e953f3ef9cf4f1bce08b6dd7b771f (patch) | |
tree | 5aca9cf31220fecef67b7bd68939291d0d13e2e1 /tools/lib | |
parent | 2acae0d5b0f73a8fb4b180bd13491feb96e55fc6 (diff) | |
download | linux-0fe05591790e953f3ef9cf4f1bce08b6dd7b771f.tar.gz linux-0fe05591790e953f3ef9cf4f1bce08b6dd7b771f.tar.bz2 linux-0fe05591790e953f3ef9cf4f1bce08b6dd7b771f.zip |
lib, traceevent: add PRINT_HEX_STR variant
Add support for the __print_hex_str() macro that was added for
tracing, so that user space tools such as perf can understand
it as well.
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>
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/traceevent/event-parse.c | 34 | ||||
-rw-r--r-- | tools/lib/traceevent/event-parse.h | 1 |
2 files changed, 32 insertions, 3 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 14a4f623c1a5..f2ea78021450 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -831,6 +831,7 @@ static void free_arg(struct print_arg *arg) free_flag_sym(arg->symbol.symbols); break; case PRINT_HEX: + case PRINT_HEX_STR: free_arg(arg->hex.field); free_arg(arg->hex.size); break; @@ -2629,10 +2630,11 @@ out_free: } static enum event_type -process_hex(struct event_format *event, struct print_arg *arg, char **tok) +process_hex_common(struct event_format *event, struct print_arg *arg, + char **tok, enum print_arg_type type) { memset(arg, 0, sizeof(*arg)); - arg->type = PRINT_HEX; + arg->type = type; if (alloc_and_process_delim(event, ",", &arg->hex.field)) goto out; @@ -2651,6 +2653,19 @@ out: } static enum event_type +process_hex(struct event_format *event, struct print_arg *arg, char **tok) +{ + return process_hex_common(event, arg, tok, PRINT_HEX); +} + +static enum event_type +process_hex_str(struct event_format *event, struct print_arg *arg, + char **tok) +{ + return process_hex_common(event, arg, tok, PRINT_HEX_STR); +} + +static enum event_type process_int_array(struct event_format *event, struct print_arg *arg, char **tok) { memset(arg, 0, sizeof(*arg)); @@ -3009,6 +3024,10 @@ process_function(struct event_format *event, struct print_arg *arg, free_token(token); return process_hex(event, arg, tok); } + if (strcmp(token, "__print_hex_str") == 0) { + free_token(token); + return process_hex_str(event, arg, tok); + } if (strcmp(token, "__print_array") == 0) { free_token(token); return process_int_array(event, arg, tok); @@ -3547,6 +3566,7 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg case PRINT_SYMBOL: case PRINT_INT_ARRAY: case PRINT_HEX: + case PRINT_HEX_STR: break; case PRINT_TYPE: val = eval_num_arg(data, size, event, arg->typecast.item); @@ -3962,6 +3982,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, } break; case PRINT_HEX: + case PRINT_HEX_STR: if (arg->hex.field->type == PRINT_DYNAMIC_ARRAY) { unsigned long offset; offset = pevent_read_number(pevent, @@ -3981,7 +4002,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, } len = eval_num_arg(data, size, event, arg->hex.size); for (i = 0; i < len; i++) { - if (i) + if (i && arg->type == PRINT_HEX) trace_seq_putc(s, ' '); trace_seq_printf(s, "%02x", hex[i]); } @@ -5727,6 +5748,13 @@ static void print_args(struct print_arg *args) print_args(args->hex.size); printf(")"); break; + case PRINT_HEX_STR: + printf("__print_hex_str("); + print_args(args->hex.field); + printf(", "); + print_args(args->hex.size); + printf(")"); + break; case PRINT_INT_ARRAY: printf("__print_array("); print_args(args->int_array.field); diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 7aae746ec2fe..74cecba87daa 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h @@ -292,6 +292,7 @@ enum print_arg_type { PRINT_FUNC, PRINT_BITMASK, PRINT_DYNAMIC_ARRAY_LEN, + PRINT_HEX_STR, }; struct print_arg { |