diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-08-15 16:31:29 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-08-15 17:25:55 +0200 |
commit | 124e02be72fdff05ab5d7f004a3c0d4061569380 (patch) | |
tree | fb0a1c6280914a4806bda6ca8a178dd39235d17b /tools/perf/builtin-script.c | |
parent | perf evswitch: Introduce OPTS_EVSWITCH() for cmd line processing (diff) | |
download | linux-124e02be72fdff05ab5d7f004a3c0d4061569380.tar.xz linux-124e02be72fdff05ab5d7f004a3c0d4061569380.zip |
perf evswitch: Introduce init() method to set the on/off evsels from the command line
Another step in having all the boilerplate in just one place to then use
in the other tools.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: William Cohen <wcohen@redhat.com>
Link: https://lkml.kernel.org/n/tip-snreb1wmwyjei3eefwotxp1l@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r-- | tools/perf/builtin-script.c | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 2a5b8af80e6b..1764efd16cd4 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -3868,24 +3868,9 @@ int cmd_script(int argc, const char **argv) script.range_num); } - if (script.evswitch.on_name) { - script.evswitch.on = perf_evlist__find_evsel_by_str(session->evlist, script.evswitch.on_name); - if (script.evswitch.on == NULL) { - fprintf(stderr, "switch-on event not found (%s)\n", script.evswitch.on_name); - err = -ENOENT; - goto out_delete; - } - script.evswitch.discarding = true; - } - - if (script.evswitch.off_name) { - script.evswitch.off = perf_evlist__find_evsel_by_str(session->evlist, script.evswitch.off_name); - if (script.evswitch.off == NULL) { - fprintf(stderr, "switch-off event not found (%s)\n", script.evswitch.off_name); - err = -ENOENT; - goto out_delete; - } - } + err = evswitch__init(&script.evswitch, session->evlist, stderr); + if (err) + goto out_delete; err = __cmd_script(&script); |