Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 191191
b: refs/heads/master
c: e9e94e3
h: refs/heads/master
i:
  191189: 85a4afd
  191187: f29043b
  191183: ffbbdc6
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Apr 8, 2010
1 parent a1fb386 commit 953dc65
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 854c5548dfad017920a36201d40449fdbad90bfb
refs/heads/master: e9e94e3bd862d31777335722e747e97d9821bc1d
49 changes: 34 additions & 15 deletions trunk/tools/perf/util/trace-event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ int header_page_ts_offset;
int header_page_ts_size;
int header_page_size_offset;
int header_page_size_size;
int header_page_overwrite_offset;
int header_page_overwrite_size;
int header_page_data_offset;
int header_page_data_size;

Expand Down Expand Up @@ -628,23 +630,32 @@ static int test_type(enum event_type type, enum event_type expect)
return 0;
}

static int test_type_token(enum event_type type, char *token,
enum event_type expect, const char *expect_tok)
static int __test_type_token(enum event_type type, char *token,
enum event_type expect, const char *expect_tok,
bool warn)
{
if (type != expect) {
warning("Error: expected type %d but read %d",
expect, type);
if (warn)
warning("Error: expected type %d but read %d",
expect, type);
return -1;
}

if (strcmp(token, expect_tok) != 0) {
warning("Error: expected '%s' but read '%s'",
expect_tok, token);
if (warn)
warning("Error: expected '%s' but read '%s'",
expect_tok, token);
return -1;
}
return 0;
}

static int test_type_token(enum event_type type, char *token,
enum event_type expect, const char *expect_tok)
{
return __test_type_token(type, token, expect, expect_tok, true);
}

static int __read_expect_type(enum event_type expect, char **tok, int newline_ok)
{
enum event_type type;
Expand All @@ -661,7 +672,8 @@ static int read_expect_type(enum event_type expect, char **tok)
return __read_expect_type(expect, tok, 1);
}

static int __read_expected(enum event_type expect, const char *str, int newline_ok)
static int __read_expected(enum event_type expect, const char *str,
int newline_ok, bool warn)
{
enum event_type type;
char *token;
Expand All @@ -672,21 +684,26 @@ static int __read_expected(enum event_type expect, const char *str, int newline_
else
type = read_token_item(&token);

ret = test_type_token(type, token, expect, str);
ret = __test_type_token(type, token, expect, str, warn);

free_token(token);

return ret;
}

static int read_expected_warn(enum event_type expect, const char *str, bool warn)
{
return __read_expected(expect, str, 1, warn);
}

static int read_expected(enum event_type expect, const char *str)
{
return __read_expected(expect, str, 1);
return __read_expected(expect, str, 1, true);
}

static int read_expected_item(enum event_type expect, const char *str)
{
return __read_expected(expect, str, 0);
return __read_expected(expect, str, 0, true);
}

static char *event_read_name(void)
Expand Down Expand Up @@ -3088,7 +3105,7 @@ static void print_args(struct print_arg *args)
}

static void parse_header_field(const char *field,
int *offset, int *size)
int *offset, int *size, bool warn)
{
char *token;
int type;
Expand All @@ -3103,7 +3120,7 @@ static void parse_header_field(const char *field,
goto fail;
free_token(token);

if (read_expected(EVENT_ITEM, field) < 0)
if (read_expected_warn(EVENT_ITEM, field, warn) < 0)
return;
if (read_expected(EVENT_OP, ";") < 0)
return;
Expand Down Expand Up @@ -3160,11 +3177,13 @@ int parse_header_page(char *buf, unsigned long size)
init_input_buf(buf, size);

parse_header_field("timestamp", &header_page_ts_offset,
&header_page_ts_size);
&header_page_ts_size, true);
parse_header_field("commit", &header_page_size_offset,
&header_page_size_size);
&header_page_size_size, true);
parse_header_field("overwrite", &header_page_overwrite_offset,
&header_page_overwrite_size, false);
parse_header_field("data", &header_page_data_offset,
&header_page_data_size);
&header_page_data_size, true);

return 0;
}
Expand Down

0 comments on commit 953dc65

Please sign in to comment.