• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 enum ProcessFlowMode : int32_t {
47     SPLIT_MODE,
48     FUSION_MODE,
49 };
50 
51 enum RemoteProcessType : int32_t {
52     MAIN_PROCESS,
53     VIRTUAL_PROCESS
54 };
55 
56 enum PidType : int32_t {
57     REAL_PROCESS_PID,
58     VIRTUAL_PROCESS_PID,
59     PID_MAX,
60 };
61 
62 /**
63  * @brief Process trace information
64  * keep sync with the definition in hitracec.h
65  */
66 typedef struct TraceInfo {
67 #if __BYTE_ORDER == __LITTLE_ENDIAN
68     uint64_t valid : 1;
69     uint64_t ver : 3;
70     uint64_t chainId : 60;
71 
72     uint64_t flags : 12;
73     uint64_t spanId : 26;
74     uint64_t parentSpanId : 26;
75 #elif __BYTE_ORDER == __BIG_ENDIAN
76     uint64_t chainId : 60;
77     uint64_t ver : 3;
78     uint64_t valid : 1;
79 
80     uint64_t parentSpanId : 26;
81     uint64_t spanId : 26;
82     uint64_t flags : 12;
83 #else
84 #error "ERROR: No BIG_LITTLE_ENDIAN defines."
85 #endif
86 } TraceInfo;
87 
88 /**
89  * @brief ProcessDump request information
90  * It is used to save and transfer the current process context from signalhandler to processdump,
91  * and also contains some other information of the process.
92  */
93 struct ProcessDumpRequest {
94     /** processdump type */
95     enum ProcessDumpType type;
96     /** thread id */
97     int32_t tid;
98     /** asynchronous thread id */
99     int32_t recycleTid;
100     /** process id */
101     int32_t pid;
102     /** namespace process id */
103     int32_t nsPid;
104     /** virtual process id */
105     int32_t vmPid;
106     /** virtual namespace process id */
107     int32_t vmNsPid;
108     /** process user id */
109     uint32_t uid;
110     /** reserved field */
111     uint64_t reserved;
112     /** timestamp */
113     uint64_t timeStamp;
114     /** current process signal context */
115     siginfo_t siginfo;
116     /** current process context */
117     ucontext_t context;
118     /** thread name */
119     char threadName[NAME_BUF_LEN];
120     /** process name */
121     char processName[NAME_BUF_LEN];
122     /** hilog last fatal log message */
123     char lastFatalMessage[MAX_FATAL_MSG_SIZE];
124     /** process trace info */
125     TraceInfo traceInfo;
126     /** current porcess fd table address*/
127     uint64_t fdTableAddr;
128     /** stackId for async-stack */
129     uint64_t stackId;
130     /** application runing unique Id */
131     char appRunningId[MAX_APP_RUNNING_UNIQUE_ID_LEN];
132     /** source process with processdump pipe */
133     int pmPipeFd[2];
134     /** vm process with proceeesump pipe */
135     int vmPipeFd[2];
136     /** is integrate crash dump flow 0:false 1:true */
137     int32_t dumpMode;
138 };
139 #ifdef __cplusplus
140 }
141 #endif
142 #endif
143