diff options
Diffstat (limited to 'tools/perf/util/trace-event-parse.c')
-rw-r--r-- | tools/perf/util/trace-event-parse.c | 118 |
1 files changed, 24 insertions, 94 deletions
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index 613c9cc90570..73a02223c629 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c | |||
@@ -37,10 +37,12 @@ int header_page_ts_offset; | |||
37 | int header_page_ts_size; | 37 | int header_page_ts_size; |
38 | int header_page_size_offset; | 38 | int header_page_size_offset; |
39 | int header_page_size_size; | 39 | int header_page_size_size; |
40 | int header_page_overwrite_offset; | ||
41 | int header_page_overwrite_size; | ||
40 | int header_page_data_offset; | 42 | int header_page_data_offset; |
41 | int header_page_data_size; | 43 | int header_page_data_size; |
42 | 44 | ||
43 | int latency_format; | 45 | bool latency_format; |
44 | 46 | ||
45 | static char *input_buf; | 47 | static char *input_buf; |
46 | static unsigned long long input_buf_ptr; | 48 | static unsigned long long input_buf_ptr; |
@@ -628,23 +630,32 @@ static int test_type(enum event_type type, enum event_type expect) | |||
628 | return 0; | 630 | return 0; |
629 | } | 631 | } |
630 | 632 | ||
631 | static int test_type_token(enum event_type type, char *token, | 633 | static int __test_type_token(enum event_type type, char *token, |
632 | enum event_type expect, const char *expect_tok) | 634 | enum event_type expect, const char *expect_tok, |
635 | bool warn) | ||
633 | { | 636 | { |
634 | if (type != expect) { | 637 | if (type != expect) { |
635 | warning("Error: expected type %d but read %d", | 638 | if (warn) |
636 | expect, type); | 639 | warning("Error: expected type %d but read %d", |
640 | expect, type); | ||
637 | return -1; | 641 | return -1; |
638 | } | 642 | } |
639 | 643 | ||
640 | if (strcmp(token, expect_tok) != 0) { | 644 | if (strcmp(token, expect_tok) != 0) { |
641 | warning("Error: expected '%s' but read '%s'", | 645 | if (warn) |
642 | expect_tok, token); | 646 | warning("Error: expected '%s' but read '%s'", |
647 | expect_tok, token); | ||
643 | return -1; | 648 | return -1; |
644 | } | 649 | } |
645 | return 0; | 650 | return 0; |
646 | } | 651 | } |
647 | 652 | ||
653 | static int test_type_token(enum event_type type, char *token, | ||
654 | enum event_type expect, const char *expect_tok) | ||
655 | { | ||
656 | return __test_type_token(type, token, expect, expect_tok, true); | ||
657 | } | ||
658 | |||
648 | static int __read_expect_type(enum event_type expect, char **tok, int newline_ok) | 659 | static int __read_expect_type(enum event_type expect, char **tok, int newline_ok) |
649 | { | 660 | { |
650 | enum event_type type; | 661 | enum event_type type; |
@@ -661,7 +672,8 @@ static int read_expect_type(enum event_type expect, char **tok) | |||
661 | return __read_expect_type(expect, tok, 1); | 672 | return __read_expect_type(expect, tok, 1); |
662 | } | 673 | } |
663 | 674 | ||
664 | static int __read_expected(enum event_type expect, const char *str, int newline_ok) | 675 | static int __read_expected(enum event_type expect, const char *str, |
676 | int newline_ok, bool warn) | ||
665 | { | 677 | { |
666 | enum event_type type; | 678 | enum event_type type; |
667 | char *token; | 679 | char *token; |
@@ -672,7 +684,7 @@ static int __read_expected(enum event_type expect, const char *str, int newline_ | |||
672 | else | 684 | else |
673 | type = read_token_item(&token); | 685 | type = read_token_item(&token); |
674 | 686 | ||
675 | ret = test_type_token(type, token, expect, str); | 687 | ret = __test_type_token(type, token, expect, str, warn); |
676 | 688 | ||
677 | free_token(token); | 689 | free_token(token); |
678 | 690 | ||
@@ -681,12 +693,12 @@ static int __read_expected(enum event_type expect, const char *str, int newline_ | |||
681 | 693 | ||
682 | static int read_expected(enum event_type expect, const char *str) | 694 | static int read_expected(enum event_type expect, const char *str) |
683 | { | 695 | { |
684 | return __read_expected(expect, str, 1); | 696 | return __read_expected(expect, str, 1, true); |
685 | } | 697 | } |
686 | 698 | ||
687 | static int read_expected_item(enum event_type expect, const char *str) | 699 | static int read_expected_item(enum event_type expect, const char *str) |
688 | { | 700 | { |
689 | return __read_expected(expect, str, 0); | 701 | return __read_expected(expect, str, 0, true); |
690 | } | 702 | } |
691 | 703 | ||
692 | static char *event_read_name(void) | 704 | static char *event_read_name(void) |
@@ -744,7 +756,7 @@ static int field_is_string(struct format_field *field) | |||
744 | 756 | ||
745 | static int field_is_dynamic(struct format_field *field) | 757 | static int field_is_dynamic(struct format_field *field) |
746 | { | 758 | { |
747 | if (!strcmp(field->type, "__data_loc")) | 759 | if (!strncmp(field->type, "__data_loc", 10)) |
748 | return 1; | 760 | return 1; |
749 | 761 | ||
750 | return 0; | 762 | return 0; |
@@ -3087,88 +3099,6 @@ static void print_args(struct print_arg *args) | |||
3087 | } | 3099 | } |
3088 | } | 3100 | } |
3089 | 3101 | ||
3090 | static void parse_header_field(const char *field, | ||
3091 | int *offset, int *size) | ||
3092 | { | ||
3093 | char *token; | ||
3094 | int type; | ||
3095 | |||
3096 | if (read_expected(EVENT_ITEM, "field") < 0) | ||
3097 | return; | ||
3098 | if (read_expected(EVENT_OP, ":") < 0) | ||
3099 | return; | ||
3100 | |||
3101 | /* type */ | ||
3102 | if (read_expect_type(EVENT_ITEM, &token) < 0) | ||
3103 | goto fail; | ||
3104 | free_token(token); | ||
3105 | |||
3106 | if (read_expected(EVENT_ITEM, field) < 0) | ||
3107 | return; | ||
3108 | if (read_expected(EVENT_OP, ";") < 0) | ||
3109 | return; | ||
3110 | if (read_expected(EVENT_ITEM, "offset") < 0) | ||
3111 | return; | ||
3112 | if (read_expected(EVENT_OP, ":") < 0) | ||
3113 | return; | ||
3114 | if (read_expect_type(EVENT_ITEM, &token) < 0) | ||
3115 | goto fail; | ||
3116 | *offset = atoi(token); | ||
3117 | free_token(token); | ||
3118 | if (read_expected(EVENT_OP, ";") < 0) | ||
3119 | return; | ||
3120 | if (read_expected(EVENT_ITEM, "size") < 0) | ||
3121 | return; | ||
3122 | if (read_expected(EVENT_OP, ":") < 0) | ||
3123 | return; | ||
3124 | if (read_expect_type(EVENT_ITEM, &token) < 0) | ||
3125 | goto fail; | ||
3126 | *size = atoi(token); | ||
3127 | free_token(token); | ||
3128 | if (read_expected(EVENT_OP, ";") < 0) | ||
3129 | return; | ||
3130 | type = read_token(&token); | ||
3131 | if (type != EVENT_NEWLINE) { | ||
3132 | /* newer versions of the kernel have a "signed" type */ | ||
3133 | if (type != EVENT_ITEM) | ||
3134 | goto fail; | ||
3135 | |||
3136 | if (strcmp(token, "signed") != 0) | ||
3137 | goto fail; | ||
3138 | |||
3139 | free_token(token); | ||
3140 | |||
3141 | if (read_expected(EVENT_OP, ":") < 0) | ||
3142 | return; | ||
3143 | |||
3144 | if (read_expect_type(EVENT_ITEM, &token)) | ||
3145 | goto fail; | ||
3146 | |||
3147 | free_token(token); | ||
3148 | if (read_expected(EVENT_OP, ";") < 0) | ||
3149 | return; | ||
3150 | |||
3151 | if (read_expect_type(EVENT_NEWLINE, &token)) | ||
3152 | goto fail; | ||
3153 | } | ||
3154 | fail: | ||
3155 | free_token(token); | ||
3156 | } | ||
3157 | |||
3158 | int parse_header_page(char *buf, unsigned long size) | ||
3159 | { | ||
3160 | init_input_buf(buf, size); | ||
3161 | |||
3162 | parse_header_field("timestamp", &header_page_ts_offset, | ||
3163 | &header_page_ts_size); | ||
3164 | parse_header_field("commit", &header_page_size_offset, | ||
3165 | &header_page_size_size); | ||
3166 | parse_header_field("data", &header_page_data_offset, | ||
3167 | &header_page_data_size); | ||
3168 | |||
3169 | return 0; | ||
3170 | } | ||
3171 | |||
3172 | int parse_ftrace_file(char *buf, unsigned long size) | 3102 | int parse_ftrace_file(char *buf, unsigned long size) |
3173 | { | 3103 | { |
3174 | struct format_field *field; | 3104 | struct format_field *field; |