• 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 HIVIEW_FAULTLOGGER_CLIENT_INTERFACE_H
16 #define HIVIEW_FAULTLOGGER_CLIENT_INTERFACE_H
17 #include <cstdint>
18 #include <map>
19 #include <string>
20 #include "faultlog_query_result.h"
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 struct FaultLogInfoInner {
25     int64_t time {0};
26     int32_t id {-1};
27     int32_t pid {-1};
28     int32_t faultLogType {0};
29     std::string module;
30     std::string reason;
31     std::string summary;
32     std::string logPath;
33     std::map<std::string, std::string> sectionMaps;
34 };
35 void AddFaultLog(FaultLogInfoInner* info);
36 void ReportCppCrashEvent(FaultLogInfoInner* info);
37 #ifdef __cplusplus
38 }
39 #endif
40 
41 namespace OHOS {
42 namespace HiviewDFX {
43 enum FaultLogType {
44     NO_SPECIFIC = 0,
45     CPP_CRASH = 2,
46     JS_CRASH,
47     APP_FREEZE,
48     SYS_FREEZE,
49 };
50 
51 // internal interface
52 bool CheckFaultloggerStatus();
53 void AddFaultLog(const FaultLogInfoInner &info);
54 void AddFaultLog(int64_t time, int32_t logType, const std::string &module, const std::string &summary);
55 
56 // external interface
57 std::unique_ptr<FaultLogQueryResult> QuerySelfFaultLog(FaultLogType faultType, int32_t maxNum);
58 }  // namespace HiviewDFX
59 }  // namespace OHOS
60 #endif  // HIVIEW_FAULTLOGGER_CLIENT_INTERFACE_H
61