Skip to content

Commit 4c635a4

Browse files
Corey Ashfordacmel
authored andcommitted
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>
1 parent 3e8e24f commit 4c635a4

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎tools/perf/util/parse-events.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ parse_single_tracepoint_event(char *sys_name,
434434
id = atoll(id_buf);
435435
attr->config = id;
436436
attr->type = PERF_TYPE_TRACEPOINT;
437-
*strp = evt_name + evt_length;
437+
*strp += strlen(sys_name) + evt_length + 1; /* + 1 for the ':' */
438438

439439
attr->sample_type |= PERF_SAMPLE_RAW;
440440
attr->sample_type |= PERF_SAMPLE_TIME;
@@ -495,7 +495,7 @@ static enum event_result parse_tracepoint_event(const char **strp,
495495
struct perf_event_attr *attr)
496496
{
497497
const char *evt_name;
498-
char *flags;
498+
char *flags = NULL, *comma_loc;
499499
char sys_name[MAX_EVENT_LENGTH];
500500
unsigned int sys_length, evt_length;
501501

@@ -514,6 +514,11 @@ static enum event_result parse_tracepoint_event(const char **strp,
514514
sys_name[sys_length] = '\0';
515515
evt_name = evt_name + 1;
516516

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+
}
517522
flags = strchr(evt_name, ':');
518523
if (flags) {
519524
/* split it out: */
@@ -524,9 +529,8 @@ static enum event_result parse_tracepoint_event(const char **strp,
524529
evt_length = strlen(evt_name);
525530
if (evt_length >= MAX_EVENT_LENGTH)
526531
return EVT_FAILED;
527-
528532
if (strpbrk(evt_name, "*?")) {
529-
*strp = evt_name + evt_length;
533+
*strp += strlen(sys_name) + evt_length;
530534
return parse_multiple_tracepoint_event(sys_name, evt_name,
531535
flags);
532536
} else

0 commit comments

Comments
 (0)