diff options
author | Yabin Cui <yabinc@google.com> | 2023-11-04 04:55:56 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-11-04 04:55:56 +0000 |
commit | e14c8665bab5709547588c7a5118c944a9fe684d (patch) | |
tree | f73c8c8589a477043da944ff6221c247dfe1565e | |
parent | bb003f496fe546475e4a4cfd9520de8f3b2625bc (diff) | |
parent | c09cef115ef62b655c39f5c87d6b78ba92a9765b (diff) | |
download | extras-e14c8665bab5709547588c7a5118c944a9fe684d.tar.gz |
Merge "simpleperf: Add --tp-filter option in the stat cmd" into main am: c09cef115e
Original change: https://android-review.googlesource.com/c/platform/system/extras/+/2817900
Change-Id: Ie83b2136f8e4675151ff18120642dac3c1f2b087
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | simpleperf/cmd_record.cpp | 3 | ||||
-rw-r--r-- | simpleperf/cmd_stat.cpp | 10 | ||||
-rw-r--r-- | simpleperf/cmd_stat_impl.h | 1 | ||||
-rw-r--r-- | simpleperf/cmd_stat_test.cpp | 7 |
4 files changed, 20 insertions, 1 deletions
diff --git a/simpleperf/cmd_record.cpp b/simpleperf/cmd_record.cpp index 14d157b8..97f96ac7 100644 --- a/simpleperf/cmd_record.cpp +++ b/simpleperf/cmd_record.cpp @@ -1252,7 +1252,8 @@ bool RecordCommand::ParseOptions(const std::vector<std::string>& args, return false; } } else { - CHECK(false) << "unprocessed option: " << name; + LOG(ERROR) << "unprocessed option: " << name; + return false; } } diff --git a/simpleperf/cmd_stat.cpp b/simpleperf/cmd_stat.cpp index d4bcbd0a..a23fec1f 100644 --- a/simpleperf/cmd_stat.cpp +++ b/simpleperf/cmd_stat.cpp @@ -402,6 +402,9 @@ class StatCommand : public Command { " Stat events on existing processes. Processes are searched either by pid\n" " or process name regex. Mutually exclusive with -a.\n" "-t tid1,tid2,... Stat events on existing threads. Mutually exclusive with -a.\n" +"--tp-filter filter_string Set filter_string for the previous tracepoint event.\n" +" Format is in Documentation/trace/events.rst in the kernel.\n" +" An example: 'prev_comm != \"simpleperf\" && (prev_pid > 1)'.\n" "--print-hw-counter Test and print CPU PMU hardware counters available on the device.\n" "--sort key1,key2,... Select keys used to sort the report, used when --per-thread\n" " or --per-core appears. The appearance order of keys decides\n" @@ -763,6 +766,13 @@ bool StatCommand::ParseOptions(const std::vector<std::string>& args, if (!event_selection_set_.AddEventGroup(event_types)) { return false; } + } else if (name == "--tp-filter") { + if (!event_selection_set_.SetTracepointFilter(*value.str_value)) { + return false; + } + } else { + LOG(ERROR) << "unprocessed option: " << name; + return false; } } diff --git a/simpleperf/cmd_stat_impl.h b/simpleperf/cmd_stat_impl.h index d337fd5a..a7397477 100644 --- a/simpleperf/cmd_stat_impl.h +++ b/simpleperf/cmd_stat_impl.h @@ -327,6 +327,7 @@ inline const OptionFormatMap& GetStatCmdOptionFormats() { {"--sort", {OptionValueType::STRING, OptionType::SINGLE, AppRunnerType::ALLOWED}}, {"--stop-signal-fd", {OptionValueType::UINT, OptionType::SINGLE, AppRunnerType::CHECK_FD}}, {"-t", {OptionValueType::STRING, OptionType::MULTIPLE, AppRunnerType::ALLOWED}}, + {"--tp-filter", {OptionValueType::STRING, OptionType::ORDERED, AppRunnerType::ALLOWED}}, {"--tracepoint-events", {OptionValueType::STRING, OptionType::SINGLE, AppRunnerType::CHECK_PATH}}, {"--use-devfreq-counters", diff --git a/simpleperf/cmd_stat_test.cpp b/simpleperf/cmd_stat_test.cpp index e6701992..86c7ae8c 100644 --- a/simpleperf/cmd_stat_test.cpp +++ b/simpleperf/cmd_stat_test.cpp @@ -427,6 +427,13 @@ TEST(stat_cmd, kprobe_option) { ASSERT_TRUE(StatCmd()->Run({"--group", "kprobes:do_sys_openat2", "-a", "--duration", SLEEP_SEC})); } +TEST(stat_cmd, tp_filter_option) { + TEST_REQUIRE_HOST_ROOT(); + TEST_REQUIRE_TRACEPOINT_EVENTS(); + ASSERT_TRUE(StatCmd()->Run( + {"-e", "sched:sched_switch", "--tp-filter", "prev_comm != sleep", "sleep", SLEEP_SEC})); +} + class StatCmdSummaryBuilderTest : public ::testing::Test { protected: struct CounterArg { |