Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169497
b: refs/heads/master
c: 0959b8d
h: refs/heads/master
i:
  169495: c9a8d34
v: v3
  • Loading branch information
Steven Rostedt authored and Ingo Molnar committed Oct 15, 2009
1 parent 1534ff0 commit d1e4901
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 298ebc3ef2a6c569b3eb51651f04e26aecbf8a1d
refs/heads/master: 0959b8d65ce26131c2d5ccfa518a7b76529280fa
62 changes: 62 additions & 0 deletions trunk/tools/perf/util/trace-event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,35 @@ process_cond(struct event *event, struct print_arg *top, char **tok)
return EVENT_ERROR;
}

static enum event_type
process_array(struct event *event, struct print_arg *top, char **tok)
{
struct print_arg *arg;
enum event_type type;
char *token = NULL;

arg = malloc_or_die(sizeof(*arg));
memset(arg, 0, sizeof(*arg));

*tok = NULL;
type = process_arg(event, arg, &token);
if (test_type_token(type, token, EVENT_OP, (char *)"]"))
goto out_free;

top->op.right = arg;

free_token(token);
type = read_token_item(&token);
*tok = token;

return type;

out_free:
free_token(*tok);
free_arg(arg);
return EVENT_ERROR;
}

static int get_op_prio(char *op)
{
if (!op[1]) {
Expand Down Expand Up @@ -1192,6 +1221,18 @@ process_op(struct event *event, struct print_arg *arg, char **tok)

arg->op.right = right;

} else if (strcmp(token, "[") == 0) {

left = malloc_or_die(sizeof(*left));
*left = *arg;

arg->type = PRINT_OP;
arg->op.op = token;
arg->op.left = left;

arg->op.prio = 0;
type = process_array(event, arg, tok);

} else {
die("unknown op '%s'", token);
/* the arg is now the left side */
Expand Down Expand Up @@ -1931,6 +1972,7 @@ static unsigned long long eval_num_arg(void *data, int size,
{
unsigned long long val = 0;
unsigned long long left, right;
struct print_arg *larg;

switch (arg->type) {
case PRINT_NULL:
Expand All @@ -1957,6 +1999,26 @@ static unsigned long long eval_num_arg(void *data, int size,
return 0;
break;
case PRINT_OP:
if (strcmp(arg->op.op, "[") == 0) {
/*
* Arrays are special, since we don't want
* to read the arg as is.
*/
if (arg->op.left->type != PRINT_FIELD)
goto default_op; /* oops, all bets off */
larg = arg->op.left;
if (!larg->field.field) {
larg->field.field =
find_any_field(event, larg->field.name);
if (!larg->field.field)
die("field %s not found", larg->field.name);
}
right = eval_num_arg(data, size, event, arg->op.right);
val = read_size(data + larg->field.field->offset +
right * long_size, long_size);
break;
}
default_op:
left = eval_num_arg(data, size, event, arg->op.left);
right = eval_num_arg(data, size, event, arg->op.right);
switch (arg->op.op[0]) {
Expand Down

0 comments on commit d1e4901

Please sign in to comment.