• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 INIT_SIGNAL_HANDLER_H
16 #define INIT_SIGNAL_HANDLER_H
17 
18 #include <pthread.h>
19 #include <inttypes.h>
20 #include <signal.h>
21 #include <ucontext.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #define LOCAL_HANDLER_STACK_SIZE (64 * 1024) // 64K
28 #define FAULTLOG_FILE_PROP 0640
29 #define MAX_FRAME 64
30 #define BUF_SZ 512
31 #define NAME_LEN 128
32 #define PATH_LEN 1024
33 #define MAX_FATAL_MSG_SIZE 1024
34 #define SYMBOL_BUF_SIZE 1024
35 #define MIN_VALID_FRAME_COUNT 3
36 #define BACK_STACK_MAX_STEPS 64
37 
38 #if defined(__arm__)
39 typedef enum ARM_REG {
40     ARM_R0 = 0,
41     ARM_R1,
42     ARM_R2,
43     ARM_R3,
44     ARM_R4,
45     ARM_R5,
46     ARM_R6,
47     ARM_R7,
48     ARM_R8,
49     ARM_R9,
50     ARM_R10,
51     ARM_FP,
52     ARM_IP,
53     ARM_SP,
54     ARM_LR,
55     ARM_PC
56 } ARM_REG;
57 #elif defined(__aarch64__)
58 enum AARCH64_REG {
59     AARCH64_X0 = 0,
60     AARCH64_X1,
61     AARCH64_X2,
62     AARCH64_X3,
63     AARCH64_X4,
64     AARCH64_X5,
65     AARCH64_X6,
66     AARCH64_X7,
67     AARCH64_X8,
68     AARCH64_X9,
69     AARCH64_X10,
70     AARCH64_X11,
71     AARCH64_X12,
72     AARCH64_X13,
73     AARCH64_X14,
74     AARCH64_X15,
75     AARCH64_X16,
76     AARCH64_X17,
77     AARCH64_X18,
78     AARCH64_X19,
79     AARCH64_X20,
80     AARCH64_X21,
81     AARCH64_X22,
82     AARCH64_X23,
83     AARCH64_X24,
84     AARCH64_X25,
85     AARCH64_X26,
86     AARCH64_X27,
87     AARCH64_X28,
88     AARCH64_X29,
89     AARCH64_X30,
90     AARCH64_SP = 31,
91     AARCH64_PC
92 };
93 #endif
94 
95 typedef struct ProcessDumpRequest_ {
96     int32_t type;
97     int32_t tid;
98     int32_t pid;
99     int32_t vmPid;
100     uint32_t uid;
101     uint64_t timeStamp;
102     siginfo_t siginfo;
103     ucontext_t context;
104 } ProcessDumpRequest;
105 
106 typedef struct SignalInfo_ {
107     int sigNo;
108     const char *name;
109 } SignalInfo;
110 
111 void InstallLocalSignalHandler(void);
112 
113 #ifdef __cplusplus
114 }
115 #endif
116 #endif