* [PATCH 1/2] perf tools: Concatenate strings in expressions
@ 2012-03-25 21:08 Jörg Sommer
2012-03-25 21:11 ` [PATCH 2/2] perf tools: Fix parsing of unary operator in ?: expression Jörg Sommer
2012-03-26 18:15 ` [PATCH 1/2] perf tools: Concatenate strings in expressions Arnaldo Carvalho de Melo
0 siblings, 2 replies; 4+ messages in thread
From: Jörg Sommer @ 2012-03-25 21:08 UTC (permalink / raw)
To: Peter Zijlstra, Paul Mackerras, Ingo Molnar,
Arnaldo Carvalho de Melo, linux-kernel
Cc: Jörg Sommer
The tracepoint event kvm_userspace_exit uses string snippet the C
compiler concatenates to a big string, e.g. "KVM_EXIT_" "UNKNOWN". The
parser of the data must do the same and join successive strings.
print fmt: "reason %s (%d)", … __print_symbolic(REC->reason, { 0, "KVM_EXIT_" "UNKNOWN" }, { 1, "KVM_EXIT_" "EXCEPTION" } …
Signed-off-by: Jörg Sommer <joerg@alea.gnuu.de>
---
tools/perf/util/trace-event-parse.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 1a8d4dc..185e284 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -1726,6 +1726,21 @@ process_arg_token(struct event *event, struct print_arg *arg,
}
break;
case EVENT_DQUOTE:
+ atom = token;
+ type = read_token_item(&token);
+
+ /* merge with following strings */
+ while (type == EVENT_DQUOTE) {
+ atom = realloc(atom, strlen(atom) + strlen(token) + 1);
+ strcat(atom, token);
+ free_token(token);
+ type = read_token_item(&token);
+ }
+
+ arg->type = PRINT_ATOM;
+ arg->atom.atom = atom;
+
+ break;
case EVENT_SQUOTE:
arg->type = PRINT_ATOM;
arg->atom.atom = token;
--
1.7.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 2/2] perf tools: Fix parsing of unary operator in ?: expression 2012-03-25 21:08 [PATCH 1/2] perf tools: Concatenate strings in expressions Jörg Sommer @ 2012-03-25 21:11 ` Jörg Sommer 2012-03-26 18:32 ` Arnaldo Carvalho de Melo 2012-03-26 18:15 ` [PATCH 1/2] perf tools: Concatenate strings in expressions Arnaldo Carvalho de Melo 1 sibling, 1 reply; 4+ messages in thread From: Jörg Sommer @ 2012-03-25 21:11 UTC (permalink / raw) To: Peter Zijlstra, Paul Mackerras, Ingo Molnar, Arnaldo Carvalho de Melo, linux-kernel Cc: Jörg Sommer Parsing an expression like print fmt: "reason %s (%d)", …, REC->errno < 0 ? -REC->errno : REC->reason in kvm_space_exit fails with Fatal unknown op ':' The colon after a simple operator signals the end of this expression. The token should not be advanced, because the colon is handled in process_cond(). Hence, it's enough to signal there's an operation heading. Signed-off-by: Jörg Sommer <joerg@alea.gnuu.de> --- An alternative could be: --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -1287,7 +1287,7 @@ process_op(struct event *event, struct print_arg *arg, char **tok) return EVENT_NONE; } - if (type == EVENT_OP) { + if (type == EVENT_OP && strcmp(*tok, ":") != 0) { int prio; /* higher prios need to be closer to the root */ tools/perf/util/trace-event-parse.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index 185e284..d7b5880 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -1125,6 +1125,7 @@ static int get_op_prio(char *op) case '|': return 13; case '?': + case ':': return 16; default: die("unknown op '%c'", op[0]); @@ -1202,6 +1203,8 @@ process_op(struct event *event, struct print_arg *arg, char **tok) type = process_arg(event, right, tok); + } else if (strcmp(token, ":") == 0) { + return EVENT_OP; } else if (strcmp(token, "?") == 0) { left = malloc_or_die(sizeof(*left)); -- 1.7.9.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] perf tools: Fix parsing of unary operator in ?: expression 2012-03-25 21:11 ` [PATCH 2/2] perf tools: Fix parsing of unary operator in ?: expression Jörg Sommer @ 2012-03-26 18:32 ` Arnaldo Carvalho de Melo 0 siblings, 0 replies; 4+ messages in thread From: Arnaldo Carvalho de Melo @ 2012-03-26 18:32 UTC (permalink / raw) To: Jörg Sommer Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, linux-kernel Em Sun, Mar 25, 2012 at 11:11:32PM +0200, Jörg Sommer escreveu: > Parsing an expression like > > print fmt: "reason %s (%d)", …, REC->errno < 0 ? -REC->errno : REC->reason > > in kvm_space_exit fails with There is no 'kvm_space_exit' I could google for except in this patch, this is 'kvm_userspace_exit', right? Fixing that in the changeset log. - Arnaldo > Fatal unknown op ':' > > The colon after a simple operator signals the end of this expression. The > token should not be advanced, because the colon is handled in > process_cond(). Hence, it's enough to signal there's an operation > heading. > > Signed-off-by: Jörg Sommer <joerg@alea.gnuu.de> > --- > An alternative could be: > > --- a/tools/perf/util/trace-event-parse.c > +++ b/tools/perf/util/trace-event-parse.c > @@ -1287,7 +1287,7 @@ process_op(struct event *event, struct print_arg *arg, char **tok) > return EVENT_NONE; > } > > - if (type == EVENT_OP) { > + if (type == EVENT_OP && strcmp(*tok, ":") != 0) { > int prio; > > /* higher prios need to be closer to the root */ > > > tools/perf/util/trace-event-parse.c | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c > index 185e284..d7b5880 100644 > --- a/tools/perf/util/trace-event-parse.c > +++ b/tools/perf/util/trace-event-parse.c > @@ -1125,6 +1125,7 @@ static int get_op_prio(char *op) > case '|': > return 13; > case '?': > + case ':': > return 16; > default: > die("unknown op '%c'", op[0]); > @@ -1202,6 +1203,8 @@ process_op(struct event *event, struct print_arg *arg, char **tok) > > type = process_arg(event, right, tok); > > + } else if (strcmp(token, ":") == 0) { > + return EVENT_OP; > } else if (strcmp(token, "?") == 0) { > > left = malloc_or_die(sizeof(*left)); > -- > 1.7.9.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] perf tools: Concatenate strings in expressions 2012-03-25 21:08 [PATCH 1/2] perf tools: Concatenate strings in expressions Jörg Sommer 2012-03-25 21:11 ` [PATCH 2/2] perf tools: Fix parsing of unary operator in ?: expression Jörg Sommer @ 2012-03-26 18:15 ` Arnaldo Carvalho de Melo 1 sibling, 0 replies; 4+ messages in thread From: Arnaldo Carvalho de Melo @ 2012-03-26 18:15 UTC (permalink / raw) To: Jörg Sommer Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, linux-kernel Em Sun, Mar 25, 2012 at 11:08:39PM +0200, Jörg Sommer escreveu: > The tracepoint event kvm_userspace_exit uses string snippet the C > compiler concatenates to a big string, e.g. "KVM_EXIT_" "UNKNOWN". The > parser of the data must do the same and join successive strings. > > print fmt: "reason %s (%d)", … __print_symbolic(REC->reason, { 0, "KVM_EXIT_" "UNKNOWN" }, { 1, "KVM_EXIT_" "EXCEPTION" } … > > Signed-off-by: Jörg Sommer <joerg@alea.gnuu.de> > --- > tools/perf/util/trace-event-parse.c | 15 +++++++++++++++ > 1 files changed, 15 insertions(+), 0 deletions(-) > > diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c > index 1a8d4dc..185e284 100644 > --- a/tools/perf/util/trace-event-parse.c > +++ b/tools/perf/util/trace-event-parse.c > @@ -1726,6 +1726,21 @@ process_arg_token(struct event *event, struct print_arg *arg, > } > break; > case EVENT_DQUOTE: > + atom = token; > + type = read_token_item(&token); > + > + /* merge with following strings */ > + while (type == EVENT_DQUOTE) { > + atom = realloc(atom, strlen(atom) + strlen(token) + 1); realloc can fail, please check its result and take appropriate action. - Arnaldo > + strcat(atom, token); > + free_token(token); > + type = read_token_item(&token); > + } > + > + arg->type = PRINT_ATOM; > + arg->atom.atom = atom; > + > + break; > case EVENT_SQUOTE: > arg->type = PRINT_ATOM; > arg->atom.atom = token; > -- > 1.7.9.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-03-26 18:32 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-03-25 21:08 [PATCH 1/2] perf tools: Concatenate strings in expressions Jörg Sommer 2012-03-25 21:11 ` [PATCH 2/2] perf tools: Fix parsing of unary operator in ?: expression Jörg Sommer 2012-03-26 18:32 ` Arnaldo Carvalho de Melo 2012-03-26 18:15 ` [PATCH 1/2] perf tools: Concatenate strings in expressions Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
Powered by JetHome