提交 4c635a4e 编写于 作者: C Corey Ashford 提交者: Arnaldo Carvalho de Melo

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: NMichael Ellerman <michaele@au1.ibm.com>
LKML-Reference: <1291156021-17711-1-git-send-email-cjashfor@linux.vnet.ibm.com>
Signed-off-by: NCorey Ashford <cjashfor@linux.vnet.ibm.com>
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 3e8e24f2
...@@ -434,7 +434,7 @@ parse_single_tracepoint_event(char *sys_name, ...@@ -434,7 +434,7 @@ parse_single_tracepoint_event(char *sys_name,
id = atoll(id_buf); id = atoll(id_buf);
attr->config = id; attr->config = id;
attr->type = PERF_TYPE_TRACEPOINT; attr->type = PERF_TYPE_TRACEPOINT;
*strp = evt_name + evt_length; *strp += strlen(sys_name) + evt_length + 1; /* + 1 for the ':' */
attr->sample_type |= PERF_SAMPLE_RAW; attr->sample_type |= PERF_SAMPLE_RAW;
attr->sample_type |= PERF_SAMPLE_TIME; attr->sample_type |= PERF_SAMPLE_TIME;
...@@ -495,7 +495,7 @@ static enum event_result parse_tracepoint_event(const char **strp, ...@@ -495,7 +495,7 @@ static enum event_result parse_tracepoint_event(const char **strp,
struct perf_event_attr *attr) struct perf_event_attr *attr)
{ {
const char *evt_name; const char *evt_name;
char *flags; char *flags = NULL, *comma_loc;
char sys_name[MAX_EVENT_LENGTH]; char sys_name[MAX_EVENT_LENGTH];
unsigned int sys_length, evt_length; unsigned int sys_length, evt_length;
...@@ -514,6 +514,11 @@ static enum event_result parse_tracepoint_event(const char **strp, ...@@ -514,6 +514,11 @@ static enum event_result parse_tracepoint_event(const char **strp,
sys_name[sys_length] = '\0'; sys_name[sys_length] = '\0';
evt_name = evt_name + 1; evt_name = evt_name + 1;
comma_loc = strchr(evt_name, ',');
if (comma_loc) {
/* take the event name up to the comma */
evt_name = strndup(evt_name, comma_loc - evt_name);
}
flags = strchr(evt_name, ':'); flags = strchr(evt_name, ':');
if (flags) { if (flags) {
/* split it out: */ /* split it out: */
...@@ -524,9 +529,8 @@ static enum event_result parse_tracepoint_event(const char **strp, ...@@ -524,9 +529,8 @@ static enum event_result parse_tracepoint_event(const char **strp,
evt_length = strlen(evt_name); evt_length = strlen(evt_name);
if (evt_length >= MAX_EVENT_LENGTH) if (evt_length >= MAX_EVENT_LENGTH)
return EVT_FAILED; return EVT_FAILED;
if (strpbrk(evt_name, "*?")) { if (strpbrk(evt_name, "*?")) {
*strp = evt_name + evt_length; *strp += strlen(sys_name) + evt_length;
return parse_multiple_tracepoint_event(sys_name, evt_name, return parse_multiple_tracepoint_event(sys_name, evt_name,
flags); flags);
} else } else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册