perf evlist: Adopt __set_tracepoint_handlers method from perf_session

It all operates on the evsels in the session's evlist, so move it to the
evlist layer to make it useful to tools not using perf_session, just
evlists, like 'perf trace' in live mode.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-9oc53gnfi53vg82fvolkm85g@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo
2019-10-01 11:14:26 -03:00
parent 608127f737
commit c0e53476ab
4 changed files with 32 additions and 34 deletions

View File

@@ -186,6 +186,30 @@ void perf_evlist__splice_list_tail(struct evlist *evlist,
}
}
int __evlist__set_tracepoints_handlers(struct evlist *evlist,
const struct evsel_str_handler *assocs, size_t nr_assocs)
{
struct evsel *evsel;
size_t i;
int err;
for (i = 0; i < nr_assocs; i++) {
// Adding a handler for an event not in this evlist, just ignore it.
evsel = perf_evlist__find_tracepoint_by_name(evlist, assocs[i].name);
if (evsel == NULL)
continue;
err = -EEXIST;
if (evsel->handler != NULL)
goto out;
evsel->handler = assocs[i].handler;
}
err = 0;
out:
return err;
}
void __perf_evlist__set_leader(struct list_head *list)
{
struct evsel *evsel, *leader;