diff options
| author | Corey Ashford <cjashfor@linux.vnet.ibm.com> | 2010-11-30 17:27:01 -0500 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-11-30 20:04:39 -0500 |
| commit | 4c635a4e04700a371ef7e4d4bb33ed88747e801e (patch) | |
| tree | 66fc0a44217cc8f01a720b92c1b74f70a83a6fc7 | |
| parent | 3e8e24f2fc66d32eb0e570e4117dfd05227047e6 (diff) | |
perf tools: fix event parsing of comma-separated tracepoint events
There are number of issues that prevent the use of multiple tracepoint events
being specified in a -e/--event switch, separated by commas.
For example, perf stat -e irq:irq_handler_entry,irq:irq_handler_exit ... fails
because the tracepoint event parsing code doesn't recognize the comma separator
properly.
This patch corrects those issues.
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Julia Lawall <julia@diku.dk>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Reported-by: Michael Ellerman <michaele@au1.ibm.com>
LKML-Reference: <1291156021-17711-1-git-send-email-cjashfor@linux.vnet.ibm.com>
Signed-off-by: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
| -rw-r--r-- | tools/perf/util/parse-events.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 4af5bd59cfd1..c305305a3884 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
| @@ -434,7 +434,7 @@ parse_single_tracepoint_event(char *sys_name, | |||
| 434 | id = atoll(id_buf); | 434 | id = atoll(id_buf); |
| 435 | attr->config = id; | 435 | attr->config = id; |
| 436 | attr->type = PERF_TYPE_TRACEPOINT; | 436 | attr->type = PERF_TYPE_TRACEPOINT; |
| 437 | *strp = evt_name + evt_length; | 437 | *strp += strlen(sys_name) + evt_length + 1; /* + 1 for the ':' */ |
| 438 | 438 | ||
| 439 | attr->sample_type |= PERF_SAMPLE_RAW; | 439 | attr->sample_type |= PERF_SAMPLE_RAW; |
| 440 | attr->sample_type |= PERF_SAMPLE_TIME; | 440 | attr->sample_type |= PERF_SAMPLE_TIME; |
| @@ -495,7 +495,7 @@ static enum event_result parse_tracepoint_event(const char **strp, | |||
| 495 | struct perf_event_attr *attr) | 495 | struct perf_event_attr *attr) |
| 496 | { | 496 | { |
| 497 | const char *evt_name; | 497 | const char *evt_name; |
| 498 | char *flags; | 498 | char *flags = NULL, *comma_loc; |
| 499 | char sys_name[MAX_EVENT_LENGTH]; | 499 | char sys_name[MAX_EVENT_LENGTH]; |
| 500 | unsigned int sys_length, evt_length; | 500 | unsigned int sys_length, evt_length; |
| 501 | 501 | ||
| @@ -514,6 +514,11 @@ static enum event_result parse_tracepoint_event(const char **strp, | |||
| 514 | sys_name[sys_length] = '\0'; | 514 | sys_name[sys_length] = '\0'; |
| 515 | evt_name = evt_name + 1; | 515 | evt_name = evt_name + 1; |
| 516 | 516 | ||
| 517 | comma_loc = strchr(evt_name, ','); | ||
| 518 | if (comma_loc) { | ||
| 519 | /* take the event name up to the comma */ | ||
| 520 | evt_name = strndup(evt_name, comma_loc - evt_name); | ||
| 521 | } | ||
| 517 | flags = strchr(evt_name, ':'); | 522 | flags = strchr(evt_name, ':'); |
| 518 | if (flags) { | 523 | if (flags) { |
| 519 | /* split it out: */ | 524 | /* split it out: */ |
| @@ -524,9 +529,8 @@ static enum event_result parse_tracepoint_event(const char **strp, | |||
| 524 | evt_length = strlen(evt_name); | 529 | evt_length = strlen(evt_name); |
| 525 | if (evt_length >= MAX_EVENT_LENGTH) | 530 | if (evt_length >= MAX_EVENT_LENGTH) |
| 526 | return EVT_FAILED; | 531 | return EVT_FAILED; |
| 527 | |||
| 528 | if (strpbrk(evt_name, "*?")) { | 532 | if (strpbrk(evt_name, "*?")) { |
| 529 | *strp = evt_name + evt_length; | 533 | *strp += strlen(sys_name) + evt_length; |
| 530 | return parse_multiple_tracepoint_event(sys_name, evt_name, | 534 | return parse_multiple_tracepoint_event(sys_name, evt_name, |
| 531 | flags); | 535 | flags); |
| 532 | } else | 536 | } else |
