diff options
author | Yabin Cui <yabinc@google.com> | 2017-07-28 17:58:25 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2017-07-28 17:58:25 -0700 |
commit | 1944f4599ffb8ac19522a2ef988ddc414ebe5c0a (patch) | |
tree | 7211a31a0c4cb3a07ad096a46b66fdc4aafd9f51 | |
parent | d4c959ba79f5b794de49b360c07d3b369e4962c5 (diff) | |
download | extras-1944f4599ffb8ac19522a2ef988ddc414ebe5c0a.tar.gz |
simpleperf: add --show-features option in list cmd.
It is used to show features supported on the device.
Bug: http://b/64147273
Test: run simpleperf_unit_test.
Change-Id: Idb7821e74d1a23f8988ef2207696114498713f47
-rw-r--r-- | simpleperf/cmd_list.cpp | 33 | ||||
-rw-r--r-- | simpleperf/cmd_list_test.cpp | 4 |
2 files changed, 35 insertions, 2 deletions
diff --git a/simpleperf/cmd_list.cpp b/simpleperf/cmd_list.cpp index 7aa0c966..71998146 100644 --- a/simpleperf/cmd_list.cpp +++ b/simpleperf/cmd_list.cpp @@ -26,6 +26,7 @@ #include "environment.h" #include "event_attr.h" #include "event_fd.h" +#include "event_selection_set.h" #include "event_type.h" static bool IsEventTypeSupported(const EventType& event_type) { @@ -92,11 +93,27 @@ class ListCommand : public Command { public: ListCommand() : Command("list", "list available event types", - "Usage: simpleperf list [hw|sw|cache|raw|tracepoint]\n" - " List all available perf events on this machine.\n") { + // clang-format off +"Usage: simpleperf list [options] [hw|sw|cache|raw|tracepoint]\n" +" List all available event types.\n" +" Filters can be used to show only event types belong to selected types:\n" +" hw hardware events\n" +" sw software events\n" +" cache hardware cache events\n" +" raw raw pmu events\n" +" tracepoint tracepoint events\n" +"Options:\n" +"--show-features Show features supported on the device, including:\n" +" dwarf-based-call-graph\n" +" trace-offcpu\n" + // clang-format on + ) { } bool Run(const std::vector<std::string>& args) override; + + private: + void ShowFeatures(); }; bool ListCommand::Run(const std::vector<std::string>& args) { @@ -122,6 +139,9 @@ bool ListCommand::Run(const std::vector<std::string>& args) { for (auto& arg : args) { if (type_map.find(arg) != type_map.end()) { names.push_back(arg); + } else if (arg == "--show-features") { + ShowFeatures(); + return true; } else { LOG(ERROR) << "unknown event type category: " << arg << ", try using \"help list\""; return false; @@ -138,6 +158,15 @@ bool ListCommand::Run(const std::vector<std::string>& args) { return true; } +void ListCommand::ShowFeatures() { + if (IsDwarfCallChainSamplingSupported()) { + printf("dwarf-based-call-graph\n"); + } + if (IsDumpingRegsForTracepointEventsSupported()) { + printf("trace-offcpu\n"); + } +} + void RegisterListCommand() { RegisterCommand("list", [] { return std::unique_ptr<Command>(new ListCommand); }); } diff --git a/simpleperf/cmd_list_test.cpp b/simpleperf/cmd_list_test.cpp index 2bc64214..3cc67121 100644 --- a/simpleperf/cmd_list_test.cpp +++ b/simpleperf/cmd_list_test.cpp @@ -39,3 +39,7 @@ TEST_F(ListCommandTest, one_option) { TEST_F(ListCommandTest, multiple_options) { ASSERT_TRUE(list_cmd->Run({"hw", "tracepoint"})); } + +TEST_F(ListCommandTest, show_features_option) { + ASSERT_TRUE(list_cmd->Run({"--show-features"})); +} |