• 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 
16 #ifndef RELIABILITY_XCOLLIE_UTILS_H
17 #define RELIABILITY_XCOLLIE_UTILS_H
18 
19 #include <chrono>
20 #include <string>
21 #include <sys/ioctl.h>
22 #include <fstream>
23 
24 #include "hilog/log.h"
25 
26 namespace OHOS {
27 namespace HiviewDFX {
28 constexpr char WMS_FULL_NAME[] = "WindowManagerService";
29 constexpr char IPC_FULL[] = "IPC_FULL";
30 constexpr char IPC_CHECKER[] = "IpcChecker";
31 constexpr int64_t SEC_TO_MANOSEC = 1000000000;
32 constexpr int64_t SEC_TO_MICROSEC = 1000000;
33 const int BUFF_STACK_SIZE = 20 * 1024;
34 const int FFRT_BUFFER_SIZE = 512 * 1024;
35 const int MAX_NAME_SIZE = 128;
36 constexpr OHOS::HiviewDFX::HiLogLabel g_XCOLLIE_LOG_LABEL = {LOG_CORE, 0xD002D06, "XCollie"};
37 #define XCOLLIE_LOGF(...) (void)OHOS::HiviewDFX::HiLog::Fatal(g_XCOLLIE_LOG_LABEL, ##__VA_ARGS__)
38 #define XCOLLIE_LOGE(...) (void)OHOS::HiviewDFX::HiLog::Error(g_XCOLLIE_LOG_LABEL, ##__VA_ARGS__)
39 #define XCOLLIE_LOGW(...) (void)OHOS::HiviewDFX::HiLog::Warn(g_XCOLLIE_LOG_LABEL, ##__VA_ARGS__)
40 #define XCOLLIE_LOGI(...) (void)OHOS::HiviewDFX::HiLog::Info(g_XCOLLIE_LOG_LABEL, ##__VA_ARGS__)
41 #define XCOLLIE_LOGD(...) (void)OHOS::HiviewDFX::HiLog::Debug(g_XCOLLIE_LOG_LABEL, ##__VA_ARGS__)
42 #define MAGIC_NUM           0x9517
43 #define HTRANSIO            0xAB
44 #define LOGGER_GET_STACK    _IO(HTRANSIO, 9)
45 
46 uint64_t GetCurrentTickMillseconds();
47 
48 std::string GetSelfProcName();
49 
50 std::string GetFirstLine(const std::string& path);
51 
52 std::string GetProcessNameFromProcCmdline(int32_t pid);
53 
54 std::string GetLimitedSizeName(std::string name);
55 
56 bool IsProcessDebug(int32_t pid);
57 
58 void DelayBeforeExit(unsigned int leftTime);
59 } // end of HiviewDFX
60 } // end of OHOS
61 #endif
62