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>
This commit is contained in:
committed by
Ingo Molnar
parent
f1d1feecf0
commit
13999e5934
@@ -924,23 +924,30 @@ static int event_read_fields(struct event *event, struct format_field **fields)
|
|||||||
if (read_expected(EVENT_OP, (char *)";") < 0)
|
if (read_expected(EVENT_OP, (char *)";") < 0)
|
||||||
goto fail_expect;
|
goto fail_expect;
|
||||||
|
|
||||||
if (read_expected(EVENT_ITEM, (char *)"signed") < 0)
|
type = read_token(&token);
|
||||||
goto fail_expect;
|
if (type != EVENT_NEWLINE) {
|
||||||
|
/* newer versions of the kernel have a "signed" type */
|
||||||
|
if (test_type_token(type, token, EVENT_ITEM, (char *)"signed"))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
if (read_expected(EVENT_OP, (char *)":") < 0)
|
free_token(token);
|
||||||
goto fail_expect;
|
|
||||||
|
|
||||||
if (read_expect_type(EVENT_ITEM, &token))
|
if (read_expected(EVENT_OP, (char *)":") < 0)
|
||||||
goto fail;
|
goto fail_expect;
|
||||||
if (strtoul(token, NULL, 0))
|
|
||||||
field->flags |= FIELD_IS_SIGNED;
|
|
||||||
free_token(token);
|
|
||||||
|
|
||||||
if (read_expected(EVENT_OP, (char *)";") < 0)
|
if (read_expect_type(EVENT_ITEM, &token))
|
||||||
goto fail_expect;
|
goto fail;
|
||||||
|
|
||||||
|
/* add signed type */
|
||||||
|
|
||||||
|
free_token(token);
|
||||||
|
if (read_expected(EVENT_OP, (char *)";") < 0)
|
||||||
|
goto fail_expect;
|
||||||
|
|
||||||
|
if (read_expect_type(EVENT_NEWLINE, &token))
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
if (read_expect_type(EVENT_NEWLINE, &token) < 0)
|
|
||||||
goto fail;
|
|
||||||
free_token(token);
|
free_token(token);
|
||||||
|
|
||||||
*fields = field;
|
*fields = field;
|
||||||
@@ -2949,21 +2956,23 @@ static void print_args(struct print_arg *args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_header_field(char *type,
|
static void parse_header_field(char *field,
|
||||||
int *offset, int *size)
|
int *offset, int *size)
|
||||||
{
|
{
|
||||||
char *token;
|
char *token;
|
||||||
|
int type;
|
||||||
|
|
||||||
if (read_expected(EVENT_ITEM, (char *)"field") < 0)
|
if (read_expected(EVENT_ITEM, (char *)"field") < 0)
|
||||||
return;
|
return;
|
||||||
if (read_expected(EVENT_OP, (char *)":") < 0)
|
if (read_expected(EVENT_OP, (char *)":") < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* type */
|
/* type */
|
||||||
if (read_expect_type(EVENT_ITEM, &token) < 0)
|
if (read_expect_type(EVENT_ITEM, &token) < 0)
|
||||||
return;
|
goto fail;
|
||||||
free_token(token);
|
free_token(token);
|
||||||
|
|
||||||
if (read_expected(EVENT_ITEM, type) < 0)
|
if (read_expected(EVENT_ITEM, field) < 0)
|
||||||
return;
|
return;
|
||||||
if (read_expected(EVENT_OP, (char *)";") < 0)
|
if (read_expected(EVENT_OP, (char *)";") < 0)
|
||||||
return;
|
return;
|
||||||
@@ -2972,7 +2981,7 @@ static void parse_header_field(char *type,
|
|||||||
if (read_expected(EVENT_OP, (char *)":") < 0)
|
if (read_expected(EVENT_OP, (char *)":") < 0)
|
||||||
return;
|
return;
|
||||||
if (read_expect_type(EVENT_ITEM, &token) < 0)
|
if (read_expect_type(EVENT_ITEM, &token) < 0)
|
||||||
return;
|
goto fail;
|
||||||
*offset = atoi(token);
|
*offset = atoi(token);
|
||||||
free_token(token);
|
free_token(token);
|
||||||
if (read_expected(EVENT_OP, (char *)";") < 0)
|
if (read_expected(EVENT_OP, (char *)";") < 0)
|
||||||
@@ -2982,22 +2991,36 @@ static void parse_header_field(char *type,
|
|||||||
if (read_expected(EVENT_OP, (char *)":") < 0)
|
if (read_expected(EVENT_OP, (char *)":") < 0)
|
||||||
return;
|
return;
|
||||||
if (read_expect_type(EVENT_ITEM, &token) < 0)
|
if (read_expect_type(EVENT_ITEM, &token) < 0)
|
||||||
return;
|
goto fail;
|
||||||
*size = atoi(token);
|
*size = atoi(token);
|
||||||
free_token(token);
|
free_token(token);
|
||||||
if (read_expected(EVENT_OP, (char *)";") < 0)
|
if (read_expected(EVENT_OP, (char *)";") < 0)
|
||||||
return;
|
return;
|
||||||
if (read_expected(EVENT_ITEM, (char *)"signed") < 0)
|
type = read_token(&token);
|
||||||
return;
|
if (type != EVENT_NEWLINE) {
|
||||||
if (read_expected(EVENT_OP, (char *)":") < 0)
|
/* newer versions of the kernel have a "signed" type */
|
||||||
return;
|
if (type != EVENT_ITEM)
|
||||||
if (read_expect_type(EVENT_ITEM, &token) < 0)
|
goto fail;
|
||||||
return;
|
|
||||||
free_token(token);
|
if (strcmp(token, (char *)"signed") != 0)
|
||||||
if (read_expected(EVENT_OP, (char *)";") < 0)
|
goto fail;
|
||||||
return;
|
|
||||||
if (read_expect_type(EVENT_NEWLINE, &token) < 0)
|
free_token(token);
|
||||||
return;
|
|
||||||
|
if (read_expected(EVENT_OP, (char *)":") < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (read_expect_type(EVENT_ITEM, &token))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
free_token(token);
|
||||||
|
if (read_expected(EVENT_OP, (char *)";") < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (read_expect_type(EVENT_NEWLINE, &token))
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
fail:
|
||||||
free_token(token);
|
free_token(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user