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 * keep sync with the definition in hitracec.h 40 */ 41 typedef struct TraceInfo { 42 #if __BYTE_ORDER == __LITTLE_ENDIAN 43 uint64_t valid : 1; 44 uint64_t ver : 3; 45 uint64_t chainId : 60; 46 47 uint64_t flags : 12; 48 uint64_t spanId : 26; 49 uint64_t parentSpanId : 26; 50 #elif __BYTE_ORDER == __BIG_ENDIAN 51 uint64_t chainId : 60; 52 uint64_t ver : 3; 53 uint64_t valid : 1; 54 55 uint64_t parentSpanId : 26; 56 uint64_t spanId : 26; 57 uint64_t flags : 12; 58 #else 59 #error "ERROR: No BIG_LITTLE_ENDIAN defines." 60 #endif 61 } TraceInfo; 62 63 /** 64 * @brief ProcessDump request information 65 * It is used to save and transfer the current process context from signalhandler to processdump, 66 * and also contains some other information of the process. 67 */ 68 struct ProcessDumpRequest { 69 /** processdump type */ 70 enum ProcessDumpType type; 71 /** thread id */ 72 int32_t tid; 73 /** asynchronous thread id */ 74 int32_t recycleTid; 75 /** process id */ 76 int32_t pid; 77 /** namespace process id */ 78 int32_t nsPid; 79 /** virtual process id */ 80 int32_t vmPid; 81 /** virtual namespace process id */ 82 int32_t vmNsPid; 83 /** process user id */ 84 uint32_t uid; 85 /** reserved field */ 86 uint64_t reserved; 87 /** timestamp */ 88 uint64_t timeStamp; 89 /** current process signal context */ 90 siginfo_t siginfo; 91 /** current process context */ 92 ucontext_t context; 93 /** thread name */ 94 char threadName[NAME_LEN]; 95 /** process name */ 96 char processName[NAME_LEN]; 97 /** hilog last fatal log message */ 98 char lastFatalMessage[MAX_FATAL_MSG_SIZE]; 99 /** process trace info */ 100 TraceInfo traceInfo; 101 }; 102 #ifdef __cplusplus 103 } 104 #endif 105 #endif 106