diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-08-15 10:11:14 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-08-15 11:24:42 -0400 |
commit | 0b495b121585a1b6ca120fe13f950e2f86ca8197 (patch) | |
tree | 058b99e8bf9d87254f1ad1c4384e1234d014464c /tools/perf/builtin-script.c | |
parent | 8829e56fa050998164e496d380cd69186ae9b8d0 (diff) |
perf evswitch: Add the names of on/off events
So that we can have macros for the OPT_ entries and also for finding
those in an evlist, this way other tools will use this very easily.
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-q0og1xoqqi0w38ve5u0a43k2@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 | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index e7b950e977a9..177e4e91b199 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -3400,8 +3400,6 @@ int cmd_script(int argc, const char **argv) | |||
3400 | struct utsname uts; | 3400 | struct utsname uts; |
3401 | char *script_path = NULL; | 3401 | char *script_path = NULL; |
3402 | const char **__argv; | 3402 | const char **__argv; |
3403 | const char *event_switch_on = NULL, | ||
3404 | *event_switch_off = NULL; | ||
3405 | int i, j, err = 0; | 3403 | int i, j, err = 0; |
3406 | struct perf_script script = { | 3404 | struct perf_script script = { |
3407 | .tool = { | 3405 | .tool = { |
@@ -3545,9 +3543,9 @@ int cmd_script(int argc, const char **argv) | |||
3545 | "file", "file saving guest os /proc/kallsyms"), | 3543 | "file", "file saving guest os /proc/kallsyms"), |
3546 | OPT_STRING(0, "guestmodules", &symbol_conf.default_guest_modules, | 3544 | OPT_STRING(0, "guestmodules", &symbol_conf.default_guest_modules, |
3547 | "file", "file saving guest os /proc/modules"), | 3545 | "file", "file saving guest os /proc/modules"), |
3548 | OPT_STRING(0, "switch-on", &event_switch_on, | 3546 | OPT_STRING(0, "switch-on", &script.evswitch.on_name, |
3549 | "event", "Consider events after the ocurrence of this event"), | 3547 | "event", "Consider events after the ocurrence of this event"), |
3550 | OPT_STRING(0, "switch-off", &event_switch_off, | 3548 | OPT_STRING(0, "switch-off", &script.evswitch.off_name, |
3551 | "event", "Stop considering events after the ocurrence of this event"), | 3549 | "event", "Stop considering events after the ocurrence of this event"), |
3552 | OPT_BOOLEAN(0, "show-on-off-events", &script.evswitch.show_on_off_events, | 3550 | OPT_BOOLEAN(0, "show-on-off-events", &script.evswitch.show_on_off_events, |
3553 | "Show the on/off switch events, used with --switch-on"), | 3551 | "Show the on/off switch events, used with --switch-on"), |
@@ -3875,20 +3873,20 @@ int cmd_script(int argc, const char **argv) | |||
3875 | script.range_num); | 3873 | script.range_num); |
3876 | } | 3874 | } |
3877 | 3875 | ||
3878 | if (event_switch_on) { | 3876 | if (script.evswitch.on_name) { |
3879 | script.evswitch.on = perf_evlist__find_evsel_by_str(session->evlist, event_switch_on); | 3877 | script.evswitch.on = perf_evlist__find_evsel_by_str(session->evlist, script.evswitch.on_name); |
3880 | if (script.evswitch.on == NULL) { | 3878 | if (script.evswitch.on == NULL) { |
3881 | fprintf(stderr, "switch-on event not found (%s)\n", event_switch_on); | 3879 | fprintf(stderr, "switch-on event not found (%s)\n", script.evswitch.on_name); |
3882 | err = -ENOENT; | 3880 | err = -ENOENT; |
3883 | goto out_delete; | 3881 | goto out_delete; |
3884 | } | 3882 | } |
3885 | script.evswitch.discarding = true; | 3883 | script.evswitch.discarding = true; |
3886 | } | 3884 | } |
3887 | 3885 | ||
3888 | if (event_switch_off) { | 3886 | if (script.evswitch.off_name) { |
3889 | script.evswitch.off = perf_evlist__find_evsel_by_str(session->evlist, event_switch_off); | 3887 | script.evswitch.off = perf_evlist__find_evsel_by_str(session->evlist, script.evswitch.off_name); |
3890 | if (script.evswitch.off == NULL) { | 3888 | if (script.evswitch.off == NULL) { |
3891 | fprintf(stderr, "switch-off event not found (%s)\n", event_switch_off); | 3889 | fprintf(stderr, "switch-off event not found (%s)\n", script.evswitch.off_name); |
3892 | err = -ENOENT; | 3890 | err = -ENOENT; |
3893 | goto out_delete; | 3891 | goto out_delete; |
3894 | } | 3892 | } |