• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 
16 #ifndef FREEZE_VENDOR_H
17 #define FREEZE_VENDOR_H
18 
19 #include <set>
20 #include <string>
21 #include <vector>
22 
23 #include "faultlog_info.h"
24 #include "freeze_common.h"
25 #include "log_store_ex.h"
26 #include "smart_parser.h"
27 #include "watch_point.h"
28 
29 namespace OHOS {
30 namespace HiviewDFX {
31 class Vendor {
32 public:
Vendor(std::shared_ptr<FreezeCommon> fc)33     explicit Vendor(std::shared_ptr<FreezeCommon> fc) : freezeCommon_(fc) {};
~Vendor()34     ~Vendor() {};
35     Vendor& operator=(const Vendor&) = delete;
36     Vendor(const Vendor&) = delete;
37 
38     bool Init();
39     std::string GetTimeString(unsigned long long timestamp) const;
40     void DumpEventInfo(std::ostringstream& oss, const std::string& header, const WatchPoint& watchPoint) const;
41     std::string MergeEventLog(
42         const WatchPoint &watchPoint, const std::vector<WatchPoint>& list,
43         const std::vector<FreezeResult>& result) const;
44     bool ReduceRelevanceEvents(std::list<WatchPoint>& list, const FreezeResult& result) const;
45 
46 private:
47     static const int MAX_LINE_NUM = 100;
48     static const int TIME_STRING_LEN = 16;
49     static const int MAX_FILE_NUM = 500;
50     static const int MAX_FOLDER_SIZE = 50 * 1024 * 1024;
51     static const inline std::string TRIGGER_HEADER = ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
52     static const inline std::string HEADER = "*******************************************";
53     static const inline std::string HYPHEN = "-";
54     static const inline std::string NEW_LINE = "\n";
55     static const inline std::string EVENT_SUMMARY = "SUMMARY";
56     static const inline std::string POSTFIX = ".tmp";
57     static const inline std::string APPFREEZE = "appfreeze";
58     static const inline std::string SYSFREEZE = "sysfreeze";
59     static const inline std::string SP_SYSTEMHUNGFAULT = "SystemHungFault";
60     static const inline std::string SP_APPFREEZE = "AppFreeze";
61     static const inline std::string SP_ENDSTACK = "END_STACK";
62     static const inline std::string FREEZE_DETECTOR_PATH = "/data/log/faultlog/";
63     static const inline std::string FAULT_LOGGER_PATH = "/data/log/faultlog/faultlogger/";
64     static const inline std::string SMART_PARSER_PATH = "/system/etc/hiview/";
65 
66     std::string SendFaultLog(const WatchPoint &watchPoint, const std::string& logPath,
67         const std::string& logName) const;
68 
69     std::unique_ptr<LogStoreEx> logStore_ = nullptr;
70     std::shared_ptr<FreezeCommon> freezeCommon_ = nullptr;
71 };
72 }  // namespace HiviewDFX
73 }  // namespace OHOS
74 #endif // FREEZE_VENDOR_H
75