diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2017-01-24 20:28:17 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-01-25 13:17:47 -0500 |
commit | 0fe05591790e953f3ef9cf4f1bce08b6dd7b771f (patch) | |
tree | 5aca9cf31220fecef67b7bd68939291d0d13e2e1 /tools/lib/traceevent | |
parent | 2acae0d5b0f73a8fb4b180bd13491feb96e55fc6 (diff) |
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/traceevent')
-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) | |||
831 | free_flag_sym(arg->symbol.symbols); | 831 | free_flag_sym(arg->symbol.symbols); |
832 | break; | 832 | break; |
833 | case PRINT_HEX: | 833 | case PRINT_HEX: |
834 | case PRINT_HEX_STR: | ||
834 | free_arg(arg->hex.field); | 835 | free_arg(arg->hex.field); |
835 | free_arg(arg->hex.size); | 836 | free_arg(arg->hex.size); |
836 | break; | 837 | break; |
@@ -2629,10 +2630,11 @@ out_free: | |||
2629 | } | 2630 | } |
2630 | 2631 | ||
2631 | static enum event_type | 2632 | static enum event_type |
2632 | process_hex(struct event_format *event, struct print_arg *arg, char **tok) | 2633 | process_hex_common(struct event_format *event, struct print_arg *arg, |
2634 | char **tok, enum print_arg_type type) | ||
2633 | { | 2635 | { |
2634 | memset(arg, 0, sizeof(*arg)); | 2636 | memset(arg, 0, sizeof(*arg)); |
2635 | arg->type = PRINT_HEX; | 2637 | arg->type = type; |
2636 | 2638 | ||
2637 | if (alloc_and_process_delim(event, ",", &arg->hex.field)) | 2639 | if (alloc_and_process_delim(event, ",", &arg->hex.field)) |
2638 | goto out; | 2640 | goto out; |
@@ -2651,6 +2653,19 @@ out: | |||
2651 | } | 2653 | } |
2652 | 2654 | ||
2653 | static enum event_type | 2655 | static enum event_type |
2656 | process_hex(struct event_format *event, struct print_arg *arg, char **tok) | ||
2657 | { | ||
2658 | return process_hex_common(event, arg, tok, PRINT_HEX); | ||
2659 | } | ||
2660 | |||
2661 | static enum event_type | ||
2662 | process_hex_str(struct event_format *event, struct print_arg *arg, | ||
2663 | char **tok) | ||
2664 | { | ||
2665 | return process_hex_common(event, arg, tok, PRINT_HEX_STR); | ||
2666 | } | ||
2667 | |||
2668 | static enum event_type | ||
2654 | process_int_array(struct event_format *event, struct print_arg *arg, char **tok) | 2669 | process_int_array(struct event_format *event, struct print_arg *arg, char **tok) |
2655 | { | 2670 | { |
2656 | memset(arg, 0, sizeof(*arg)); | 2671 | memset(arg, 0, sizeof(*arg)); |
@@ -3009,6 +3024,10 @@ process_function(struct event_format *event, struct print_arg *arg, | |||
3009 | free_token(token); | 3024 | free_token(token); |
3010 | return process_hex(event, arg, tok); | 3025 | return process_hex(event, arg, tok); |
3011 | } | 3026 | } |
3027 | if (strcmp(token, "__print_hex_str") == 0) { | ||
3028 | free_token(token); | ||
3029 | return process_hex_str(event, arg, tok); | ||
3030 | } | ||
3012 | if (strcmp(token, "__print_array") == 0) { | 3031 | if (strcmp(token, "__print_array") == 0) { |
3013 | free_token(token); | 3032 | free_token(token); |
3014 | return process_int_array(event, arg, tok); | 3033 | 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 | |||
3547 | case PRINT_SYMBOL: | 3566 | case PRINT_SYMBOL: |
3548 | case PRINT_INT_ARRAY: | 3567 | case PRINT_INT_ARRAY: |
3549 | case PRINT_HEX: | 3568 | case PRINT_HEX: |
3569 | case PRINT_HEX_STR: | ||
3550 | break; | 3570 | break; |
3551 | case PRINT_TYPE: | 3571 | case PRINT_TYPE: |
3552 | val = eval_num_arg(data, size, event, arg->typecast.item); | 3572 | 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, | |||
3962 | } | 3982 | } |
3963 | break; | 3983 | break; |
3964 | case PRINT_HEX: | 3984 | case PRINT_HEX: |
3985 | case PRINT_HEX_STR: | ||
3965 | if (arg->hex.field->type == PRINT_DYNAMIC_ARRAY) { | 3986 | if (arg->hex.field->type == PRINT_DYNAMIC_ARRAY) { |
3966 | unsigned long offset; | 3987 | unsigned long offset; |
3967 | offset = pevent_read_number(pevent, | 3988 | offset = pevent_read_number(pevent, |
@@ -3981,7 +4002,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, | |||
3981 | } | 4002 | } |
3982 | len = eval_num_arg(data, size, event, arg->hex.size); | 4003 | len = eval_num_arg(data, size, event, arg->hex.size); |
3983 | for (i = 0; i < len; i++) { | 4004 | for (i = 0; i < len; i++) { |
3984 | if (i) | 4005 | if (i && arg->type == PRINT_HEX) |
3985 | trace_seq_putc(s, ' '); | 4006 | trace_seq_putc(s, ' '); |
3986 | trace_seq_printf(s, "%02x", hex[i]); | 4007 | trace_seq_printf(s, "%02x", hex[i]); |
3987 | } | 4008 | } |
@@ -5727,6 +5748,13 @@ static void print_args(struct print_arg *args) | |||
5727 | print_args(args->hex.size); | 5748 | print_args(args->hex.size); |
5728 | printf(")"); | 5749 | printf(")"); |
5729 | break; | 5750 | break; |
5751 | case PRINT_HEX_STR: | ||
5752 | printf("__print_hex_str("); | ||
5753 | print_args(args->hex.field); | ||
5754 | printf(", "); | ||
5755 | print_args(args->hex.size); | ||
5756 | printf(")"); | ||
5757 | break; | ||
5730 | case PRINT_INT_ARRAY: | 5758 | case PRINT_INT_ARRAY: |
5731 | printf("__print_array("); | 5759 | printf("__print_array("); |
5732 | print_args(args->int_array.field); | 5760 | 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 { | |||
292 | PRINT_FUNC, | 292 | PRINT_FUNC, |
293 | PRINT_BITMASK, | 293 | PRINT_BITMASK, |
294 | PRINT_DYNAMIC_ARRAY_LEN, | 294 | PRINT_DYNAMIC_ARRAY_LEN, |
295 | PRINT_HEX_STR, | ||
295 | }; | 296 | }; |
296 | 297 | ||
297 | struct print_arg { | 298 | struct print_arg { |