if (!show_event(sample, evsel, thread, al))
return;
- if (script->evswitch.on && script->evswitch.discarding) {
- if (script->evswitch.on != evsel)
- return;
-
- script->evswitch.discarding = false;
-
- if (!script->evswitch.show_on_off_events)
- return;
-
- goto print_it;
- }
-
- if (script->evswitch.off && !script->evswitch.discarding) {
- if (script->evswitch.off != evsel)
- goto print_it;
-
- script->evswitch.discarding = true;
+ if (evswitch__discard(&script->evswitch, evsel))
+ return;
- if (!script->evswitch.show_on_off_events)
- return;
- }
-print_it:
++es->samples;
perf_sample__fprintf_start(sample, thread, evsel,
perf-y += evlist.o
perf-y += evsel.o
perf-y += evsel_fprintf.o
+perf-y += evswitch.o
perf-y += find_bit.o
perf-y += get_current_dir_name.o
perf-y += kallsyms.o
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0-only
+// Copyright (C) 2019, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
+
+#include "evswitch.h"
+
+bool evswitch__discard(struct evswitch *evswitch, struct evsel *evsel)
+{
+ if (evswitch->on && evswitch->discarding) {
+ if (evswitch->on != evsel)
+ return true;
+
+ evswitch->discarding = false;
+
+ if (!evswitch->show_on_off_events)
+ return true;
+
+ return false;
+ }
+
+ if (evswitch->off && !evswitch->discarding) {
+ if (evswitch->off != evsel)
+ return false;
+
+ evswitch->discarding = true;
+
+ if (!evswitch->show_on_off_events)
+ return true;
+ }
+
+ return false;
+}
bool show_on_off_events;
};
+bool evswitch__discard(struct evswitch *evswitch, struct evsel *evsel);
+
#endif /* __PERF_EVSWITCH_H */