• 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 DFX_FAULTLOGGERD_CLIENT_H
16 #define DFX_FAULTLOGGERD_CLIENT_H
17 
18 #include <inttypes.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 #define FAULTLOGGER_DAEMON_RESP "RESP:COMPLETE"
25 
26 enum FaultLoggerType {
27     JAVA_CRASH = 1,
28     CPP_CRASH,
29     JS_CRASH,
30     APP_FREEZE,
31     JAVA_STACKTRACE = 100, // unsupported yet
32     CPP_STACKTRACE,
33     JS_STACKTRACE,
34     JS_HEAP_SNAPSHOT,
35 };
36 
37 enum FaultLoggerClientType {
38     DEFAULT_CLIENT = 0, // For original request crash info file
39     LOG_FILE_DES_CLIENT, // For request a file to record nornal unwind and process dump logs.
40     PRINT_T_HILOG_CLIENT, // For request a file to record nornal unwind and process dump logs.
41     PERMISSION_CLIENT,
42     SDK_DUMP_CLIENT,
43     PIPE_FD_CLIENT,
44     MAX_CLIENT
45 };
46 
47 enum FaultLoggerPipeType {
48     PIPE_FD_READ_BUF = 0,
49     PIPE_FD_WRITE_BUF,
50     PIPE_FD_READ_RES,
51     PIPE_FD_WRITE_RES,
52     PIPE_FD_DELETE,
53 };
54 
55 enum FaultLoggerCheckPermissionResp {
56     CHECK_PERMISSION_PASS = 1,
57     CHECK_PERMISSION_REJECT,
58     CHECK_PERMISSION_MAX
59 };
60 
61 enum FaultLoggerSdkDumpResp {
62     SDK_DUMP_PASS = 1,
63     SDK_DUMP_REJECT,
64     SDK_DUMP_REPEAT,
65     SDK_DUMP_NOPROC,
66     SDK_DUMP_MAX
67 };
68 
69 struct FaultLoggerdRequest {
70     int32_t type;
71     int32_t clientType;
72     int32_t pipeType;
73     int32_t sigCode;
74     int32_t pid;
75     int32_t tid;
76     uint32_t uid;
77     int32_t callerPid; // only for sdk dump client
78     int32_t callerTid; // only for sdk dump client
79     char module[128];
80     uint64_t time;
81 } __attribute__((packed));
82 
83 bool CheckConnectStatus();
84 int32_t RequestFileDescriptor(int32_t type);
85 int32_t RequestLogFileDescriptor(struct FaultLoggerdRequest *request);
86 int32_t RequestPipeFd(int32_t pid, int32_t pipeType);
87 int32_t RequestDelPipeFd(int32_t pid);
88 int RequestFileDescriptorEx(const struct FaultLoggerdRequest *request);
89 bool RequestCheckPermission(int32_t pid);
90 void RequestPrintTHilog(const char *msg, int length);
91 int RequestSdkDump(int32_t type, int32_t pid, int32_t tid);
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif
98