Skip to contentSkip to conversation

perf: trace-event-parse: support more operators and print formats

PATCH In review David Sharp 2 participants 4 messages Mar 10, 2011 perf events

lore
Share & tools
lore
#0 lore raw

cover perf: trace-event-parse: support more operators and print formats

These patches correspond to similar patches recently applied to trace-cmd

Cc Steven Rostedt <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Stephane Eranian <[email protected]>

David Sharp (2):
perf: trace-event-parse: support additional operators: '!', '~', and

    '!='

perf: trace-event-parse: support printing short fields

 tools/perf/util/trace-event-parse.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
Signature · 1 line
1.7.3.1
#1 lore raw

PATCH 1/2 perf: trace-event-parse: support additional operators: '!', '~', and '!='

Add support for the unary operators '!' and '~', and support '!=' so that it is differentiated from '!'.

Cc Steven Rostedt <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/util/trace-event-parse.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
tools/perf/util/trace-event-parse.c +19 -0
index 73a0222..67fe01a 100644
@@ -1107,6 +1107,9 @@ static int get_op_prio(char *op)
 {
 	if (!op[1]) {
 		switch (op[0]) {
+		case '~':
+		case '!':
+			return 4;
 		case '*':
 		case '/':
 		case '%':
@@ -1184,6 +1187,7 @@ process_op(struct event *event, struct print_arg *arg, char **tok)
 			return EVENT_ERROR;
 		}
 		switch (token[0]) {
+		case '~':
 		case '!':
 		case '+':
 		case '-':
@@ -2109,6 +2113,21 @@ static unsigned long long eval_num_arg(void *data, int size,
 		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]) {
+		case '!':
+			switch (arg->op.op[1]) {
+			case 0:
+				val = !right;
+				break;
+			case '=':
+				val = left != right;
+				break;
+			default:
+				die("unknown op '%s'", arg->op.op);
+			}
+			break;
+		case '~':
+			val = ~right;
+			break;
 		case '|':
 			if (arg->op.op[1])
 				val = left || right;
Signature · 1 line
1.7.3.1
#2 lore raw

PATCH 2/2 perf: trace-event-parse: support printing short fields

In reply to David Sharp

Handle "%hd" etc. in pretty_print()

Cc Steven Rostedt <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/util/trace-event-parse.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
tools/perf/util/trace-event-parse.c +9 -0
index 67fe01a..0cf4366 100644
@@ -2534,6 +2534,9 @@ static void pretty_print(void *data, int size, struct event *event)
 			case '%':
 				printf("%%");
 				break;
+			case 'h':
+				ls--;
+				goto cont_process;
 			case 'l':
 				ls++;
 				goto cont_process;
@@ -2589,6 +2592,12 @@ static void pretty_print(void *data, int size, struct event *event)
 					}
 				}
 				switch (ls) {
+				case -2:
+					printf(format, (char)val);
+					break;
+				case -1:
+					printf(format, (short)val);
+					break;
 				case 0:
 					printf(format, (int)val);
 					break;
Signature · 1 line
1.7.3.1
#3 lore raw
In reply to David Sharp

[ Added Cc for Arnaldo and Frederic ]

-- Steve

Quoted 14 lines · David Sharp

These patches correspond to similar patches recently applied to trace-cmd

Cc Steven Rostedt <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Stephane Eranian <[email protected]>

David Sharp (2):
perf: trace-event-parse: support additional operators: '!', '~', and

    '!='

perf: trace-event-parse: support printing short fields

 tools/perf/util/trace-event-parse.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)