aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-10-14 15:43:38 -0400
committerIngo Molnar <mingo@elte.hu>2009-10-15 04:42:37 -0400
commit13999e59343b042b0807be2df6ae5895d29782a0 (patch)
tree9e6dae86b7731bc340873245858087cec85cc67d /tools
parentf1d1feecf07261d083859ecfef0d4399036f9683 (diff)
perf tools: Handle the case with and without the "signed" trace field
The trace format files now have a "signed" field. But we should still be able to handle the kernels that do not have this field. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> LKML-Reference: <20091014194358.888239553@goodmis.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/trace-event-parse.c81
1 files changed, 52 insertions, 29 deletions
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 59e4e4db7438..0739b12675f0 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -924,23 +924,30 @@ static int event_read_fields(struct event *event, struct format_field **fields)
924 if (read_expected(EVENT_OP, (char *)";") < 0) 924 if (read_expected(EVENT_OP, (char *)";") < 0)
925 goto fail_expect; 925 goto fail_expect;
926 926
927 if (read_expected(EVENT_ITEM, (char *)"signed") < 0) 927 type = read_token(&token);
928 goto fail_expect; 928 if (type != EVENT_NEWLINE) {
929 /* newer versions of the kernel have a "signed" type */
930 if (test_type_token(type, token, EVENT_ITEM, (char *)"signed"))
931 goto fail;
929 932
930 if (read_expected(EVENT_OP, (char *)":") < 0) 933 free_token(token);
931 goto fail_expect;
932 934
933 if (read_expect_type(EVENT_ITEM, &token)) 935 if (read_expected(EVENT_OP, (char *)":") < 0)
934 goto fail; 936 goto fail_expect;
935 if (strtoul(token, NULL, 0))
936 field->flags |= FIELD_IS_SIGNED;
937 free_token(token);
938 937
939 if (read_expected(EVENT_OP, (char *)";") < 0) 938 if (read_expect_type(EVENT_ITEM, &token))
940 goto fail_expect; 939 goto fail;
940
941 /* add signed type */
942
943 free_token(token);
944 if (read_expected(EVENT_OP, (char *)";") < 0)
945 goto fail_expect;
946
947 if (read_expect_type(EVENT_NEWLINE, &token))
948 goto fail;
949 }
941 950
942 if (read_expect_type(EVENT_NEWLINE, &token) < 0)
943 goto fail;
944 free_token(token); 951 free_token(token);
945 952
946 *fields = field; 953 *fields = field;
@@ -2949,21 +2956,23 @@ static void print_args(struct print_arg *args)
2949 } 2956 }
2950} 2957}
2951 2958
2952static void parse_header_field(char *type, 2959static void parse_header_field(char *field,
2953 int *offset, int *size) 2960 int *offset, int *size)
2954{ 2961{
2955 char *token; 2962 char *token;
2963 int type;
2956 2964
2957 if (read_expected(EVENT_ITEM, (char *)"field") < 0) 2965 if (read_expected(EVENT_ITEM, (char *)"field") < 0)
2958 return; 2966 return;
2959 if (read_expected(EVENT_OP, (char *)":") < 0) 2967 if (read_expected(EVENT_OP, (char *)":") < 0)
2960 return; 2968 return;
2969
2961 /* type */ 2970 /* type */
2962 if (read_expect_type(EVENT_ITEM, &token) < 0) 2971 if (read_expect_type(EVENT_ITEM, &token) < 0)
2963 return; 2972 goto fail;
2964 free_token(token); 2973 free_token(token);
2965 2974
2966 if (read_expected(EVENT_ITEM, type) < 0) 2975 if (read_expected(EVENT_ITEM, field) < 0)
2967 return; 2976 return;
2968 if (read_expected(EVENT_OP, (char *)";") < 0) 2977 if (read_expected(EVENT_OP, (char *)";") < 0)
2969 return; 2978 return;
@@ -2972,7 +2981,7 @@ static void parse_header_field(char *type,
2972 if (read_expected(EVENT_OP, (char *)":") < 0) 2981 if (read_expected(EVENT_OP, (char *)":") < 0)
2973 return; 2982 return;
2974 if (read_expect_type(EVENT_ITEM, &token) < 0) 2983 if (read_expect_type(EVENT_ITEM, &token) < 0)
2975 return; 2984 goto fail;
2976 *offset = atoi(token); 2985 *offset = atoi(token);
2977 free_token(token); 2986 free_token(token);
2978 if (read_expected(EVENT_OP, (char *)";") < 0) 2987 if (read_expected(EVENT_OP, (char *)";") < 0)
@@ -2982,22 +2991,36 @@ static void parse_header_field(char *type,
2982 if (read_expected(EVENT_OP, (char *)":") < 0) 2991 if (read_expected(EVENT_OP, (char *)":") < 0)
2983 return; 2992 return;
2984 if (read_expect_type(EVENT_ITEM, &token) < 0) 2993 if (read_expect_type(EVENT_ITEM, &token) < 0)
2985 return; 2994 goto fail;
2986 *size = atoi(token); 2995 *size = atoi(token);
2987 free_token(token); 2996 free_token(token);
2988 if (read_expected(EVENT_OP, (char *)";") < 0) 2997 if (read_expected(EVENT_OP, (char *)";") < 0)
2989 return; 2998 return;
2990 if (read_expected(EVENT_ITEM, (char *)"signed") < 0) 2999 type = read_token(&token);
2991 return; 3000 if (type != EVENT_NEWLINE) {
2992 if (read_expected(EVENT_OP, (char *)":") < 0) 3001 /* newer versions of the kernel have a "signed" type */
2993 return; 3002 if (type != EVENT_ITEM)
2994 if (read_expect_type(EVENT_ITEM, &token) < 0) 3003 goto fail;
2995 return; 3004
2996 free_token(token); 3005 if (strcmp(token, (char *)"signed") != 0)
2997 if (read_expected(EVENT_OP, (char *)";") < 0) 3006 goto fail;
2998 return; 3007
2999 if (read_expect_type(EVENT_NEWLINE, &token) < 0) 3008 free_token(token);
3000 return; 3009
3010 if (read_expected(EVENT_OP, (char *)":") < 0)
3011 return;
3012
3013 if (read_expect_type(EVENT_ITEM, &token))
3014 goto fail;
3015
3016 free_token(token);
3017 if (read_expected(EVENT_OP, (char *)";") < 0)
3018 return;
3019
3020 if (read_expect_type(EVENT_NEWLINE, &token))
3021 goto fail;
3022 }
3023 fail:
3001 free_token(token); 3024 free_token(token);
3002} 3025}
3003 3026