Commit 6dd76680 authored by Ian Rogers's avatar Ian Rogers Committed by Namhyung Kim

perf expr: Fix "has_event" function for metric style events

Events in metrics cannot use '/' as a separator, it would be
recognized as a divide, so they use '@'. The '@' is recognized in the
metricgroups code and changed to '/', do the same in the has_event
function so that the parsing is only tried without the @s.

Fixes: 4a4a9bf9 ("perf expr: Add has_event function")
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: James Clark <james.clark@arm.com>
Cc: Kaige Ye <ye@kaige.org>
Cc: John Garry <john.g.garry@oracle.com>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240209204947.3873294-3-irogers@google.com
parent 4ea7d944
......@@ -500,7 +500,25 @@ double expr__has_event(const struct expr_parse_ctx *ctx, bool compute_ids, const
tmp = evlist__new();
if (!tmp)
return NAN;
ret = parse_event(tmp, id) ? 0 : 1;
if (strchr(id, '@')) {
char *tmp_id, *p;
tmp_id = strdup(id);
if (!tmp_id) {
ret = NAN;
goto out;
}
p = strchr(tmp_id, '@');
*p = '/';
p = strrchr(tmp_id, '@');
*p = '/';
ret = parse_event(tmp, tmp_id) ? 0 : 1;
free(tmp_id);
} else {
ret = parse_event(tmp, id) ? 0 : 1;
}
out:
evlist__delete(tmp);
return ret;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment