OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012, Google Inc. | |
2 // All rights reserved. | |
3 // | |
4 // Redistribution and use in source and binary forms, with or without | |
5 // modification, are permitted provided that the following conditions are | |
6 // met: | |
7 // | |
8 // * Redistributions of source code must retain the above copyright | |
9 // notice, this list of conditions and the following disclaimer. | |
10 // * Redistributions in binary form must reproduce the above | |
11 // copyright notice, this list of conditions and the following disclaimer | |
12 // in the documentation and/or other materials provided with the | |
13 // distribution. | |
14 // * Neither the name of Google Inc. nor the names of its | |
15 // contributors may be used to endorse or promote products derived from | |
16 // this software without specific prior written permission. | |
17 // | |
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 | |
30 #ifndef GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_UCONTEXT_H | |
31 #define GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_UCONTEXT_H | |
32 | |
33 #include <sys/cdefs.h> | |
34 #include <signal.h> | |
35 | |
36 #ifdef __cplusplus | |
37 extern "C" { | |
38 #endif // __cplusplus | |
39 | |
40 #ifndef __BIONIC_HAVE_UCONTEXT_T | |
41 | |
42 // Ensure that 'stack_t' is defined. | |
43 #include <asm/signal.h> | |
44 | |
45 // This version of the Android C library headers do not provide ucontext_t. | |
46 // Provide custom definitions for Google Breakpad. | |
47 #if defined(__arm__) | |
48 | |
49 // Ensure that 'struct sigcontext' is defined. | |
50 #include <asm/sigcontext.h> | |
51 typedef struct sigcontext mcontext_t; | |
52 | |
53 // The ARM kernel uses a 64-bit signal mask. | |
54 typedef uint32_t kernel_sigmask_t[2]; | |
55 | |
56 typedef struct ucontext { | |
57 uint32_t uc_flags; | |
58 struct ucontext* uc_link; | |
59 stack_t uc_stack; | |
60 mcontext_t uc_mcontext; | |
61 kernel_sigmask_t uc_sigmask; | |
62 // Other fields are not used by Google Breakpad. Don't define them. | |
63 } ucontext_t; | |
64 | |
65 #elif defined(__aarch64__) | |
66 | |
67 #include <asm/sigcontext.h> | |
68 typedef struct sigcontext mcontext_t; | |
69 | |
70 typedef struct ucontext { | |
71 unsigned long uc_flags; | |
72 struct ucontext *uc_link; | |
73 stack_t uc_stack; | |
74 sigset_t uc_sigmask; | |
75 char __padding[128 - sizeof(sigset_t)]; | |
76 mcontext_t uc_mcontext; | |
77 } ucontext_t; | |
78 | |
79 #elif defined(__i386__) | |
80 | |
81 /* 80-bit floating-point register */ | |
82 struct _libc_fpreg { | |
83 unsigned short significand[4]; | |
84 unsigned short exponent; | |
85 }; | |
86 | |
87 /* Simple floating-point state, see FNSTENV instruction */ | |
88 struct _libc_fpstate { | |
89 unsigned long cw; | |
90 unsigned long sw; | |
91 unsigned long tag; | |
92 unsigned long ipoff; | |
93 unsigned long cssel; | |
94 unsigned long dataoff; | |
95 unsigned long datasel; | |
96 struct _libc_fpreg _st[8]; | |
97 unsigned long status; | |
98 }; | |
99 | |
100 typedef uint32_t greg_t; | |
101 | |
102 typedef struct { | |
103 uint32_t gregs[19]; | |
104 struct _libc_fpstate* fpregs; | |
105 uint32_t oldmask; | |
106 uint32_t cr2; | |
107 } mcontext_t; | |
108 | |
109 enum { | |
110 REG_GS = 0, | |
111 REG_FS, | |
112 REG_ES, | |
113 REG_DS, | |
114 REG_EDI, | |
115 REG_ESI, | |
116 REG_EBP, | |
117 REG_ESP, | |
118 REG_EBX, | |
119 REG_EDX, | |
120 REG_ECX, | |
121 REG_EAX, | |
122 REG_TRAPNO, | |
123 REG_ERR, | |
124 REG_EIP, | |
125 REG_CS, | |
126 REG_EFL, | |
127 REG_UESP, | |
128 REG_SS, | |
129 }; | |
130 | |
131 // The i386 kernel uses a 64-bit signal mask. | |
132 typedef uint32_t kernel_sigmask_t[2]; | |
133 | |
134 typedef struct ucontext { | |
135 uint32_t uc_flags; | |
136 struct ucontext* uc_link; | |
137 stack_t uc_stack; | |
138 mcontext_t uc_mcontext; | |
139 kernel_sigmask_t uc_sigmask; | |
140 struct _libc_fpstate __fpregs_mem; | |
141 } ucontext_t; | |
142 | |
143 #elif defined(__mips__) | |
144 | |
145 typedef struct { | |
146 uint32_t regmask; | |
147 uint32_t status; | |
148 uint64_t pc; | |
149 uint64_t gregs[32]; | |
150 uint64_t fpregs[32]; | |
151 uint32_t acx; | |
152 uint32_t fpc_csr; | |
153 uint32_t fpc_eir; | |
154 uint32_t used_math; | |
155 uint32_t dsp; | |
156 uint64_t mdhi; | |
157 uint64_t mdlo; | |
158 uint32_t hi1; | |
159 uint32_t lo1; | |
160 uint32_t hi2; | |
161 uint32_t lo2; | |
162 uint32_t hi3; | |
163 uint32_t lo3; | |
164 } mcontext_t; | |
165 | |
166 // The MIPS kernel uses a 128-bit signal mask. | |
167 typedef uint32_t kernel_sigmask_t[4]; | |
168 | |
169 typedef struct ucontext { | |
170 uint32_t uc_flags; | |
171 struct ucontext* uc_link; | |
172 stack_t uc_stack; | |
173 mcontext_t uc_mcontext; | |
174 kernel_sigmask_t uc_sigmask; | |
175 // Other fields are not used by Google Breakpad. Don't define them. | |
176 } ucontext_t; | |
177 | |
178 #elif defined(__x86_64__) | |
179 enum { | |
180 REG_R8 = 0, | |
181 REG_R9, | |
182 REG_R10, | |
183 REG_R11, | |
184 REG_R12, | |
185 REG_R13, | |
186 REG_R14, | |
187 REG_R15, | |
188 REG_RDI, | |
189 REG_RSI, | |
190 REG_RBP, | |
191 REG_RBX, | |
192 REG_RDX, | |
193 REG_RAX, | |
194 REG_RCX, | |
195 REG_RSP, | |
196 REG_RIP, | |
197 REG_EFL, | |
198 REG_CSGSFS, | |
199 REG_ERR, | |
200 REG_TRAPNO, | |
201 REG_OLDMASK, | |
202 REG_CR2, | |
203 NGREG | |
204 }; | |
205 | |
206 // This struct is essentially the same as _fpstate in asm/sigcontext.h | |
207 // except that the individual field names are chosen here to match the | |
208 // ones used in breakpad for other x86_64 platforms. | |
209 struct _libc_fpstate { | |
210 /* 64-bit FXSAVE format. */ | |
211 uint16_t cwd; | |
212 uint16_t swd; | |
213 uint16_t ftw; | |
214 uint16_t fop; | |
215 uint64_t rip; | |
216 uint64_t rdp; | |
217 uint32_t mxcsr; | |
218 uint32_t mxcr_mask; | |
219 uint32_t _st[32]; // 128 bytes for the ST/MM registers 0-7 | |
220 uint32_t _xmm[64]; // 256 bytes for the XMM registers 0-7 | |
221 uint32_t padding[24]; // 96 bytes | |
222 }; | |
223 | |
224 typedef long greg_t; | |
225 typedef greg_t gregset_t[NGREG]; | |
226 | |
227 typedef struct _libc_fpstate* fpregset_t; | |
228 | |
229 typedef struct { | |
230 gregset_t gregs; | |
231 fpregset_t fpregs; | |
232 uint64_t __reserved1[8]; | |
233 } mcontext_t; | |
234 | |
235 typedef struct ucontext { | |
236 unsigned long uc_flags; | |
237 struct ucontext* uc_link; | |
238 stack_t uc_stack; | |
239 mcontext_t uc_mcontext; | |
240 sigset_t uc_sigmask; | |
241 uint64_t __padding[18]; | |
242 _libc_fpstate __fpregs_mem; | |
243 } ucontext_t; | |
244 | |
245 #else | |
246 # error "Unsupported Android CPU ABI!" | |
247 #endif | |
248 | |
249 #endif // __BIONIC_HAVE_UCONTEXT_T | |
250 | |
251 #ifdef __cplusplus | |
252 } // extern "C" | |
253 #endif // __cplusplus | |
254 | |
255 #endif // GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_UCONTEXT_H | |
OLD | NEW |