1 /* 2 * Copyright (c) 2021-2023 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_DUMP_REQUEST_H 16 #define DFX_DUMP_REQUEST_H 17 18 #include <inttypes.h> 19 #include <signal.h> 20 #include <ucontext.h> 21 #include "dfx_define.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /** 28 * @brief ProcessDump type 29 */ 30 enum ProcessDumpType : int32_t { 31 /** dump process stack */ 32 DUMP_TYPE_PROCESS, 33 /** dump thread stack */ 34 DUMP_TYPE_THREAD, 35 }; 36 37 /** 38 * @brief Process trace information 39 */ 40 enum OperateResult : int32_t { 41 OPE_FAIL = 0, 42 OPE_SUCCESS = 1, 43 OPE_CONTINUE = 2, 44 }; 45 46 typedef enum { 47 MESSAGE_NONE = 0, 48 MESSAGE_FATAL, // Need to write LastFatalMessage 49 MESSAGE_CALLBACK, // call back memssage 50 } MessageType; 51 52 typedef struct { 53 MessageType type; 54 char body[MAX_FATAL_MSG_SIZE]; 55 } Message; 56 57 /** 58 * @brief ProcessDump request information 59 * It is used to save and transfer the current process context from signalhandler to processdump, 60 * and also contains some other information of the process. 61 */ 62 struct ProcessDumpRequest { 63 /** processdump type */ 64 enum ProcessDumpType type; 65 /** thread id */ 66 int32_t tid; 67 /** asynchronous thread id */ 68 int32_t recycleTid; 69 /** process id */ 70 int32_t pid; 71 /** namespace process id */ 72 int32_t nsPid; 73 /** virtual process id */ 74 int32_t vmPid; 75 /** virtual namespace process id */ 76 int32_t vmNsPid; 77 /** process user id */ 78 uint32_t uid; 79 /** reserved field */ 80 uint64_t reserved; 81 /** timestamp */ 82 uint64_t timeStamp; 83 /** current process signal context */ 84 siginfo_t siginfo; 85 /** current process context */ 86 ucontext_t context; 87 /** thread name */ 88 char threadName[NAME_BUF_LEN]; 89 /** process name */ 90 char processName[NAME_BUF_LEN]; 91 /** Storing different types of messages */ 92 Message msg; 93 /** current porcess fd table address*/ 94 uint64_t fdTableAddr; 95 /** stackId for async-stack */ 96 uint64_t stackId; 97 /** application runing unique Id */ 98 char appRunningId[MAX_APP_RUNNING_UNIQUE_ID_LEN]; 99 /** source child process with processdump pipe */ 100 int childPipeFd[2]; 101 /** is integrate crash dump flow 0:false 1:true */ 102 int32_t dumpMode; 103 /** vm process pid addr */ 104 intptr_t vmProcRealPidAddr; 105 /** whether block source process pid */ 106 intptr_t blockCrashExitAddr; 107 /** whether processdump unwind crash success */ 108 intptr_t unwindResultAddr; 109 uintptr_t crashObj; 110 }; 111 112 static const int CRASH_BLOCK_EXIT_FLAG = 0x13579BDF; 113 static const int CRASH_UNWIND_SUCCESS_FLAG = 0x2468ACEF; 114 #ifdef __cplusplus 115 } 116 #endif 117 #endif 118