• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 CRASH_EXCEPTION_H
17 #define CRASH_EXCEPTION_H
18 
19 #include <cinttypes>
20 #include <string>
21 #include "dfx_exception.h"
22 #include "dfx_dump_request.h"
23 
24 namespace OHOS {
25 namespace HiviewDFX {
26 
27 /**
28  * @brief fault log file check keyword info
29 */
30 struct LogValidCheckInfo {
31     /** key words for check */
32     std::string key;
33     /** regex rule */
34     std::string regx;
35     /** offset of the key words in file */
36     std::string::size_type start;
37     /** error code when file invalid */
38     int32_t errCode;
39 };
40 
41 /**
42  * @brief get current time
43 */
44 uint64_t GetTimeMillisec(void);
45 
46 /**
47  * @brief save crashed process info
48 */
49 void SetCrashProcInfo(const ProcessDumpType& dumpType, const std::string& name, int32_t pid, int32_t uid);
50 
51 /**
52  * @brief report crash to sysevent
53 */
54 void ReportCrashException(int32_t errCode);
55 
56 /**
57  * @brief report crash to sysevent
58 */
59 void ReportCrashException(std::string name, int32_t pid, int32_t uid, int32_t errCode);
60 
61 /**
62  * @brief report crash unwinder error to sysevent
63 */
64 void ReportUnwinderException(uint16_t unwError);
65 
66 /**
67  * @brief Check summary valid,The valid is if the string contains stack information for the first three frames
68  *
69  * @param summary Stack information in the fault info
70  * @return if check valid return true, otherwise return false
71 */
72 bool CheckFaultSummaryValid(const std::string &summary);
73 }
74 }
75 #endif