• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef SUBCOMMAND_LIST_H_
16 #define SUBCOMMAND_LIST_H_
17 
18 #include <algorithm>
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 #include "debug_logger.h"
24 #include "option.h"
25 #include "perf_events.h"
26 #include "subcommand.h"
27 #include "utilities.h"
28 
29 namespace OHOS {
30 namespace Developtools {
31 namespace HiPerf {
32 class SubCommandList : public SubCommand {
33 public:
SubCommandList()34     SubCommandList()
35         // clang-format off
36         : SubCommand("list", "List the supported event types.",
37         "Usage: hiperf list [event type name]\n"
38         "       List all supported event types on this devices.\n"
39         "   To list the events of a specific type, specify the type name\n"
40         "       hw          hardware events\n"
41         "       sw          software events\n"
42         "       tp          tracepoint events\n"
43         "       cache       hardware cache events\n"
44         "       raw         raw pmu events\n\n"
45         )
46     // clang-format on
47     {
48     }
49 
50     bool OnSubCommand(std::vector<std::string> &args) override;
51 
52     static void RegisterSubCommandList(void);
53 
54 private:
55     PerfEvents perfEvents_;
56 
57     const std::map<std::string, perf_type_id> SUPPORT_NAME_OPTIONS = {
58         {"hw", PERF_TYPE_HARDWARE},    {"sw", PERF_TYPE_SOFTWARE}, {"tp", PERF_TYPE_TRACEPOINT},
59         {"cache", PERF_TYPE_HW_CACHE}, {"raw", PERF_TYPE_RAW},
60     };
61 
62     bool ShowSupportEventsTypes(std::vector<perf_type_id> requestEventTypes);
63 };
64 } // namespace HiPerf
65 } // namespace Developtools
66 } // namespace OHOS
67 #endif