Commit a5a178e1 authored by Stefan Hajnoczi's avatar Stefan Hajnoczi Committed by Arnaldo Carvalho de Melo

perf tools: Allow expressions in __print_symbolic() fields

The __print_symbolic() function takes a sequence of key-value pairs for
pretty-printing a constant.  The new kvm:kvm_exit print fmt uses the
expression:

  __print_symbolic(..., { 0x040 + 1, "DB excp" }, ...)

Currently only atoms are supported and this print fmt fails to parse.
This patch adds support for expressions instead of just atoms so that
0x040 + 1 is parsed successfully.  Also add arg_num_eval() support for
the '+' operator.
Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1315148939-14313-1-git-send-email-stefanha@linux.vnet.ibm.comSigned-off-by: default avatarStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 09bda443
...@@ -1423,6 +1423,11 @@ static long long arg_num_eval(struct print_arg *arg) ...@@ -1423,6 +1423,11 @@ static long long arg_num_eval(struct print_arg *arg)
die("unknown op '%s'", arg->op.op); die("unknown op '%s'", arg->op.op);
} }
break; break;
case '+':
left = arg_num_eval(arg->op.left);
right = arg_num_eval(arg->op.right);
val = left + right;
break;
default: default:
die("unknown op '%s'", arg->op.op); die("unknown op '%s'", arg->op.op);
} }
...@@ -1483,6 +1488,13 @@ process_fields(struct event *event, struct print_flag_sym **list, char **tok) ...@@ -1483,6 +1488,13 @@ process_fields(struct event *event, struct print_flag_sym **list, char **tok)
free_token(token); free_token(token);
type = process_arg(event, arg, &token); type = process_arg(event, arg, &token);
if (type == EVENT_OP)
type = process_op(event, arg, &token);
if (type == EVENT_ERROR)
goto out_free;
if (test_type_token(type, token, EVENT_DELIM, ",")) if (test_type_token(type, token, EVENT_DELIM, ","))
goto out_free; goto out_free;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment