|
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(__i386__) |
|
66 |
|
67 /* 80-bit floating-point register */ |
|
68 struct _libc_fpreg { |
|
69 unsigned short significand[4]; |
|
70 unsigned short exponent; |
|
71 }; |
|
72 |
|
73 /* Simple floating-point state, see FNSTENV instruction */ |
|
74 struct _libc_fpstate { |
|
75 unsigned long cw; |
|
76 unsigned long sw; |
|
77 unsigned long tag; |
|
78 unsigned long ipoff; |
|
79 unsigned long cssel; |
|
80 unsigned long dataoff; |
|
81 unsigned long datasel; |
|
82 struct _libc_fpreg _st[8]; |
|
83 unsigned long status; |
|
84 }; |
|
85 |
|
86 typedef uint32_t greg_t; |
|
87 |
|
88 typedef struct { |
|
89 uint32_t gregs[19]; |
|
90 struct _libc_fpstate* fpregs; |
|
91 uint32_t oldmask; |
|
92 uint32_t cr2; |
|
93 } mcontext_t; |
|
94 |
|
95 enum { |
|
96 REG_GS = 0, |
|
97 REG_FS, |
|
98 REG_ES, |
|
99 REG_DS, |
|
100 REG_EDI, |
|
101 REG_ESI, |
|
102 REG_EBP, |
|
103 REG_ESP, |
|
104 REG_EBX, |
|
105 REG_EDX, |
|
106 REG_ECX, |
|
107 REG_EAX, |
|
108 REG_TRAPNO, |
|
109 REG_ERR, |
|
110 REG_EIP, |
|
111 REG_CS, |
|
112 REG_EFL, |
|
113 REG_UESP, |
|
114 REG_SS, |
|
115 }; |
|
116 |
|
117 // The i386 kernel uses a 64-bit signal mask. |
|
118 typedef uint32_t kernel_sigmask_t[2]; |
|
119 |
|
120 typedef struct ucontext { |
|
121 uint32_t uc_flags; |
|
122 struct ucontext* uc_link; |
|
123 stack_t uc_stack; |
|
124 mcontext_t uc_mcontext; |
|
125 kernel_sigmask_t uc_sigmask; |
|
126 struct _libc_fpstate __fpregs_mem; |
|
127 } ucontext_t; |
|
128 |
|
129 #elif defined(__mips__) |
|
130 |
|
131 // Not supported by Google Breakpad at this point, but just in case. |
|
132 typedef struct { |
|
133 uint32_t regmask; |
|
134 uint32_t status; |
|
135 uint64_t pc; |
|
136 uint64_t gregs[32]; |
|
137 uint64_t fpregs[32]; |
|
138 uint32_t acx; |
|
139 uint32_t fpc_csr; |
|
140 uint32_t fpc_eir; |
|
141 uint32_t used_math; |
|
142 uint32_t dsp; |
|
143 uint64_t mdhi; |
|
144 uint64_t mdlo; |
|
145 uint32_t hi1; |
|
146 uint32_t lo1; |
|
147 uint32_t hi2; |
|
148 uint32_t lo2; |
|
149 uint32_t hi3; |
|
150 uint32_t lo3; |
|
151 } mcontext_t; |
|
152 |
|
153 // The MIPS kernel uses a 128-bit signal mask. |
|
154 typedef uint32_t kernel_sigmask_t[4]; |
|
155 |
|
156 typedef struct ucontext { |
|
157 uint32_t uc_flags; |
|
158 struct ucontext* uc_link; |
|
159 stack_t uc_stack; |
|
160 mcontext_t uc_mcontext; |
|
161 kernel_sigmask_t uc_sigmask; |
|
162 // Other fields are not used by Google Breakpad. Don't define them. |
|
163 } ucontext_t; |
|
164 |
|
165 #else |
|
166 # error "Unsupported Android CPU ABI!" |
|
167 #endif |
|
168 |
|
169 #endif // __BIONIC_HAVE_UCONTEXT_T |
|
170 |
|
171 #ifdef __cplusplus |
|
172 } // extern "C" |
|
173 #endif // __cplusplus |
|
174 |
|
175 #endif // GOOGLE_BREAKPAD_COMMON_ANDROID_INCLUDE_SYS_UCONTEXT_H |