• 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 HIDUMPER_SERVICES_DUMP_CFG_H
16 #define HIDUMPER_SERVICES_DUMP_CFG_H
17 #include <string>
18 #include <vector>
19 #include "common/dumper_constant.h"
20 #include "common/option_args.h"
21 namespace OHOS {
22 namespace HiviewDFX {
23 class HidumperExecutor;
24 struct DumpCfg {
25     std::string name_;
26     std::string desc_;
27     std::string target_;
28     std::string section_;
29     int class_ {DumperConstant::NONE};
30     int level_ {DumperConstant::NONE};
31     int loop_ {DumperConstant::NONE};
32     std::string filterCfg_;
33     std::shared_ptr<OptionArgs> args_;
34     int type_ {DumperConstant::NONE}; // DumperConstant::NONE, GROUPTYPE_PID, GROUPTYPE_CPUID
35     bool expand_ {false}; // true: expand; false: non-expand
36     std::shared_ptr<DumpCfg> parent_;
37     std::vector<std::shared_ptr<DumpCfg>> childs_; // GROUP, must clear
38     std::shared_ptr<HidumperExecutor> executor_; // GROUP, must clear
39 public:
40     DumpCfg();
41     ~DumpCfg();
42     DumpCfg& operator=(const DumpCfg& dumpCfg);
43     bool IsGroup() const;
44     bool IsDumper() const;
45     bool IsFilter() const;
46     bool IsLevel() const;
47     bool CanLoop() const;
48     bool IsOutput() const;
49     bool HasPid() const;
50     bool HasCpuId() const;
51     void Dump(int deep = 0) const;
52     static std::shared_ptr<DumpCfg> Create();
53     static bool IsDumper(int cls);
54     static bool IsFilter(int cls);
55     static bool IsLevel(int level);
56     static bool CanLoop(int loop);
57     static bool IsOutput(int cls);
58     static bool HasPid(const std::string &target);
59     static bool HasCpuId(const std::string &target);
60     static std::string ToStr(int type);
61     static void Dump(const DumpCfg& cfg, int nest = 0);
62 private:
63     static std::string ToDumperStr(int type);
64     static std::string ToFilterStr(int type);
65     static std::string ToOutputStr(int type);
66     static std::string ToLevelStr(int type);
67     static std::string ToTypeStr(int type);
68 };
69 } // namespace HiviewDFX
70 } // namespace OHOS
71 #endif // HIDUMPER_SERVICES_DUMP_CFG_H
72