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 DFX_SOCKET_REQUEST_H 17 #define DFX_SOCKET_REQUEST_H 18 19 #include <inttypes.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 /** 26 * @brief type of request 27 * 28 */ 29 enum FaultLoggerType { 30 /** C/C++ crash at runtime */ 31 CPP_CRASH = 2, 32 /** js crash at runtime */ 33 JS_CRASH, 34 /** application freeze */ 35 APP_FREEZE, 36 /** trace native stack */ 37 CPP_STACKTRACE = 101, 38 /** trace js stack */ 39 JS_STACKTRACE, 40 /** js heap */ 41 JS_HEAP_SNAPSHOT, 42 /** js raw heap */ 43 JS_RAW_SNAPSHOT, 44 /** js heap leak list */ 45 JS_HEAP_LEAK_LIST, 46 /** leak stacktrace */ 47 LEAK_STACKTRACE, 48 /** ffrt crash log */ 49 FFRT_CRASH_LOG, 50 /** jit code log */ 51 JIT_CODE_LOG, 52 }; 53 54 /** 55 * @brief type of faultlogger client 56 * 57 */ 58 enum FaultLoggerClientType { 59 /** For original request crash info temp file */ 60 DEFAULT_CLIENT = 0, 61 /** For request a debug file to record nornal unwind and process dump logs */ 62 LOG_FILE_DES_CLIENT, 63 /** For request to record nornal unwind and process dump to hilog */ 64 PRINT_T_HILOG_CLIENT, 65 /** For request to check permission */ 66 PERMISSION_CLIENT, 67 /** For request to dump stack */ 68 SDK_DUMP_CLIENT, 69 /** For request file descriptor of pipe */ 70 PIPE_FD_CLIENT, 71 /** For report crash dump exception */ 72 REPORT_EXCEPTION_CLIENT, 73 }; 74 75 /** 76 * @brief type of request about pipe 77 */ 78 enum FaultLoggerPipeType { 79 /** For request file descriptor of pipe to read buffer */ 80 PIPE_FD_READ_BUF = 0, 81 /** For request file descriptor of pipe to write buffer */ 82 PIPE_FD_WRITE_BUF, 83 /** For request file descriptor of pipe to read result */ 84 PIPE_FD_READ_RES, 85 /** For request file descriptor of pipe to write result */ 86 PIPE_FD_WRITE_RES, 87 /** For request file descriptor of pipe to json read buffer */ 88 PIPE_FD_JSON_READ_BUF, 89 /** For request file descriptor of pipe to json write buffer */ 90 PIPE_FD_JSON_WRITE_BUF, 91 /** For request file descriptor of pipe to json read result */ 92 PIPE_FD_JSON_READ_RES, 93 /** For request file descriptor of pipe to json write result */ 94 PIPE_FD_JSON_WRITE_RES, 95 /** For request to delete file descriptor of pipe */ 96 PIPE_FD_DELETE, 97 }; 98 /** 99 * @brief type of responding check permission request 100 */ 101 enum FaultLoggerCheckPermissionResp { 102 /** pass */ 103 CHECK_PERMISSION_PASS = 1, 104 /** reject */ 105 CHECK_PERMISSION_REJECT, 106 }; 107 /** 108 * @brief type of responding sdk dump request 109 */ 110 enum FaultLoggerSdkDumpResp { 111 /** pass */ 112 SDK_DUMP_PASS = 1, 113 /** reject */ 114 SDK_DUMP_REJECT, 115 /** repeat request */ 116 SDK_DUMP_REPEAT, 117 /** process not exist */ 118 SDK_DUMP_NOPROC, 119 /** process has crashed */ 120 SDK_PROCESS_CRASHED, 121 }; 122 /** 123 * @brief request information 124 */ 125 struct FaultLoggerdRequest { 126 /** type of resquest */ 127 int32_t type; 128 /** type of faultlogger client */ 129 int32_t clientType; 130 /** type of pipe */ 131 int32_t pipeType; 132 /** signal code */ 133 int32_t sigCode; 134 /** process id */ 135 int32_t pid; 136 /** thread id */ 137 int32_t tid; 138 /** user id */ 139 uint32_t uid; 140 /** process id of calling sdk dump ,only for sdk dump client */ 141 int32_t callerPid; 142 /** thread id of calling sdk dump ,only for sdk dump client */ 143 int32_t callerTid; 144 /** time of current request */ 145 uint64_t time; 146 /** ture output json string, false output default string */ 147 bool isJson; 148 /** dumpcatcher remote unwind endtime ms */ 149 uint64_t endTime; 150 } __attribute__((packed)); 151 152 /** 153 * @brief type of faultloggerd stats request 154 */ 155 enum FaultLoggerdStatType { 156 /** dump catcher stats */ 157 DUMP_CATCHER = 0, 158 /** processdump stats */ 159 PROCESS_DUMP 160 }; 161 162 /** 163 * @brief struct of faultloggerd stats request 164 */ 165 struct FaultLoggerdStatsRequest { 166 /** type of resquest */ 167 int32_t type; 168 /** target process id outside sandbox */ 169 int32_t pid; 170 /** the time call dumpcatcher interface */ 171 uint64_t requestTime; 172 /** the time signal arrive in targe process */ 173 uint64_t signalTime; 174 /** the time enter processdump main */ 175 uint64_t processdumpStartTime; 176 /** the time finish processdump */ 177 uint64_t processdumpFinishTime; 178 /** the time return from dumpcatcher interface */ 179 uint64_t dumpCatcherFinishTime; 180 /** dumpcatcher result */ 181 int32_t result; 182 /** caller elf offset */ 183 uintptr_t offset; 184 char summary[128]; // 128 : max summary size 185 /** the caller elf of dumpcatcher interface */ 186 char callerElf[128]; // 128 : max function name size 187 /** the caller processName */ 188 char callerProcess[128]; // 128 : max function name size 189 /** the target processName */ 190 char targetProcess[128]; // 128 : max function name size 191 } __attribute__((packed)); 192 #ifdef __cplusplus 193 } 194 #endif 195 #endif