1 # HG changeset patch |
|
2 # User Wolfgang Rosenauer <wr@rosenauer.org> |
|
3 # Parent f6b8a48d89d77c7a3eb13fef234c618943306c2b |
|
4 Replace struct ucontext with ucontext_t |
|
5 |
|
6 diff --git a/toolkit/crashreporter/breakpad-client/linux/dump_writer_common/ucontext_reader.cc b/toolkit/crashreporter/breakpad-client/linux/dump_writer_common/ucontext_reader.cc |
|
7 --- a/toolkit/crashreporter/breakpad-client/linux/dump_writer_common/ucontext_reader.cc |
|
8 +++ b/toolkit/crashreporter/breakpad-client/linux/dump_writer_common/ucontext_reader.cc |
|
9 @@ -35,25 +35,25 @@ |
|
10 namespace google_breakpad { |
|
11 |
|
12 // Minidump defines register structures which are different from the raw |
|
13 // structures which we get from the kernel. These are platform specific |
|
14 // functions to juggle the ucontext and user structures into minidump format. |
|
15 |
|
16 #if defined(__i386__) |
|
17 |
|
18 -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) { |
|
19 +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) { |
|
20 return uc->uc_mcontext.gregs[REG_ESP]; |
|
21 } |
|
22 |
|
23 -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) { |
|
24 +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) { |
|
25 return uc->uc_mcontext.gregs[REG_EIP]; |
|
26 } |
|
27 |
|
28 -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc, |
|
29 +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc, |
|
30 const struct _libc_fpstate* fp) { |
|
31 const greg_t* regs = uc->uc_mcontext.gregs; |
|
32 |
|
33 out->context_flags = MD_CONTEXT_X86_FULL | |
|
34 MD_CONTEXT_X86_FLOATING_POINT; |
|
35 |
|
36 out->gs = regs[REG_GS]; |
|
37 out->fs = regs[REG_FS]; |
|
38 @@ -83,25 +83,25 @@ void UContextReader::FillCPUContext(RawC |
|
39 out->float_save.data_selector = fp->datasel; |
|
40 |
|
41 // 8 registers * 10 bytes per register. |
|
42 my_memcpy(out->float_save.register_area, fp->_st, 10 * 8); |
|
43 } |
|
44 |
|
45 #elif defined(__x86_64) |
|
46 |
|
47 -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) { |
|
48 +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) { |
|
49 return uc->uc_mcontext.gregs[REG_RSP]; |
|
50 } |
|
51 |
|
52 -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) { |
|
53 +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) { |
|
54 return uc->uc_mcontext.gregs[REG_RIP]; |
|
55 } |
|
56 |
|
57 -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc, |
|
58 +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc, |
|
59 const struct _libc_fpstate* fpregs) { |
|
60 const greg_t* regs = uc->uc_mcontext.gregs; |
|
61 |
|
62 out->context_flags = MD_CONTEXT_AMD64_FULL; |
|
63 |
|
64 out->cs = regs[REG_CSGSFS] & 0xffff; |
|
65 |
|
66 out->fs = (regs[REG_CSGSFS] >> 32) & 0xffff; |
|
67 @@ -140,25 +140,25 @@ void UContextReader::FillCPUContext(RawC |
|
68 out->flt_save.mx_csr = fpregs->mxcsr; |
|
69 out->flt_save.mx_csr_mask = fpregs->mxcr_mask; |
|
70 my_memcpy(&out->flt_save.float_registers, &fpregs->_st, 8 * 16); |
|
71 my_memcpy(&out->flt_save.xmm_registers, &fpregs->_xmm, 16 * 16); |
|
72 } |
|
73 |
|
74 #elif defined(__ARM_EABI__) |
|
75 |
|
76 -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) { |
|
77 +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) { |
|
78 return uc->uc_mcontext.arm_sp; |
|
79 } |
|
80 |
|
81 -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) { |
|
82 +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) { |
|
83 return uc->uc_mcontext.arm_pc; |
|
84 } |
|
85 |
|
86 -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc) { |
|
87 +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) { |
|
88 out->context_flags = MD_CONTEXT_ARM_FULL; |
|
89 |
|
90 out->iregs[0] = uc->uc_mcontext.arm_r0; |
|
91 out->iregs[1] = uc->uc_mcontext.arm_r1; |
|
92 out->iregs[2] = uc->uc_mcontext.arm_r2; |
|
93 out->iregs[3] = uc->uc_mcontext.arm_r3; |
|
94 out->iregs[4] = uc->uc_mcontext.arm_r4; |
|
95 out->iregs[5] = uc->uc_mcontext.arm_r5; |
|
96 @@ -179,25 +179,25 @@ void UContextReader::FillCPUContext(RawC |
|
97 // TODO: fix this after fixing ExceptionHandler |
|
98 out->float_save.fpscr = 0; |
|
99 my_memset(&out->float_save.regs, 0, sizeof(out->float_save.regs)); |
|
100 my_memset(&out->float_save.extra, 0, sizeof(out->float_save.extra)); |
|
101 } |
|
102 |
|
103 #elif defined(__aarch64__) |
|
104 |
|
105 -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) { |
|
106 +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) { |
|
107 return uc->uc_mcontext.sp; |
|
108 } |
|
109 |
|
110 -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) { |
|
111 +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) { |
|
112 return uc->uc_mcontext.pc; |
|
113 } |
|
114 |
|
115 -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc, |
|
116 +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc, |
|
117 const struct fpsimd_context* fpregs) { |
|
118 out->context_flags = MD_CONTEXT_ARM64_FULL; |
|
119 |
|
120 out->cpsr = static_cast<uint32_t>(uc->uc_mcontext.pstate); |
|
121 for (int i = 0; i < MD_CONTEXT_ARM64_REG_SP; ++i) |
|
122 out->iregs[i] = uc->uc_mcontext.regs[i]; |
|
123 out->iregs[MD_CONTEXT_ARM64_REG_SP] = uc->uc_mcontext.sp; |
|
124 out->iregs[MD_CONTEXT_ARM64_REG_PC] = uc->uc_mcontext.pc; |
|
125 @@ -205,25 +205,25 @@ void UContextReader::FillCPUContext(RawC |
|
126 out->float_save.fpsr = fpregs->fpsr; |
|
127 out->float_save.fpcr = fpregs->fpcr; |
|
128 my_memcpy(&out->float_save.regs, &fpregs->vregs, |
|
129 MD_FLOATINGSAVEAREA_ARM64_FPR_COUNT * 16); |
|
130 } |
|
131 |
|
132 #elif defined(__mips__) |
|
133 |
|
134 -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) { |
|
135 +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) { |
|
136 return uc->uc_mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]; |
|
137 } |
|
138 |
|
139 -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) { |
|
140 +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) { |
|
141 return uc->uc_mcontext.pc; |
|
142 } |
|
143 |
|
144 -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc) { |
|
145 +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) { |
|
146 #if _MIPS_SIM == _ABI64 |
|
147 out->context_flags = MD_CONTEXT_MIPS64_FULL; |
|
148 #elif _MIPS_SIM == _ABIO32 |
|
149 out->context_flags = MD_CONTEXT_MIPS_FULL; |
|
150 #else |
|
151 #error "This mips ABI is currently not supported (n32)" |
|
152 #endif |
|
153 |
|
154 diff --git a/toolkit/crashreporter/breakpad-client/linux/dump_writer_common/ucontext_reader.h b/toolkit/crashreporter/breakpad-client/linux/dump_writer_common/ucontext_reader.h |
|
155 --- a/toolkit/crashreporter/breakpad-client/linux/dump_writer_common/ucontext_reader.h |
|
156 +++ b/toolkit/crashreporter/breakpad-client/linux/dump_writer_common/ucontext_reader.h |
|
157 @@ -36,29 +36,29 @@ |
|
158 #include "linux/dump_writer_common/raw_context_cpu.h" |
|
159 #include "common/memory.h" |
|
160 #include "google_breakpad/common/minidump_format.h" |
|
161 |
|
162 namespace google_breakpad { |
|
163 |
|
164 // Wraps platform-dependent implementations of accessors to ucontext structs. |
|
165 struct UContextReader { |
|
166 - static uintptr_t GetStackPointer(const struct ucontext* uc); |
|
167 + static uintptr_t GetStackPointer(const ucontext_t* uc); |
|
168 |
|
169 - static uintptr_t GetInstructionPointer(const struct ucontext* uc); |
|
170 + static uintptr_t GetInstructionPointer(const ucontext_t* uc); |
|
171 |
|
172 // Juggle a arch-specific ucontext into a minidump format |
|
173 // out: the minidump structure |
|
174 // info: the collection of register structures. |
|
175 #if defined(__i386__) || defined(__x86_64) |
|
176 - static void FillCPUContext(RawContextCPU *out, const ucontext *uc, |
|
177 + static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc, |
|
178 const struct _libc_fpstate* fp); |
|
179 #elif defined(__aarch64__) |
|
180 - static void FillCPUContext(RawContextCPU *out, const ucontext *uc, |
|
181 + static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc, |
|
182 const struct fpsimd_context* fpregs); |
|
183 #else |
|
184 - static void FillCPUContext(RawContextCPU *out, const ucontext *uc); |
|
185 + static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc); |
|
186 #endif |
|
187 }; |
|
188 |
|
189 } // namespace google_breakpad |
|
190 |
|
191 #endif // CLIENT_LINUX_DUMP_WRITER_COMMON_UCONTEXT_READER_H |
|
192 diff --git a/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.cc b/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.cc |
|
193 --- a/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.cc |
|
194 +++ b/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.cc |
|
195 @@ -434,30 +434,30 @@ bool ExceptionHandler::HandleSignal(int |
|
196 info->si_code == SI_TKILL; |
|
197 if (signal_trusted || (signal_pid_trusted && info->si_pid == getpid())) { |
|
198 sys_prctl(PR_SET_DUMPABLE, 1, 0, 0, 0); |
|
199 } |
|
200 |
|
201 // Fill in all the holes in the struct to make Valgrind happy. |
|
202 memset(&g_crash_context_, 0, sizeof(g_crash_context_)); |
|
203 memcpy(&g_crash_context_.siginfo, info, sizeof(siginfo_t)); |
|
204 - memcpy(&g_crash_context_.context, uc, sizeof(struct ucontext)); |
|
205 + memcpy(&g_crash_context_.context, uc, sizeof(ucontext_t)); |
|
206 #if defined(__aarch64__) |
|
207 - struct ucontext* uc_ptr = (struct ucontext*)uc; |
|
208 + ucontext_t* uc_ptr = (ucontext_t*)uc; |
|
209 struct fpsimd_context* fp_ptr = |
|
210 (struct fpsimd_context*)&uc_ptr->uc_mcontext.__reserved; |
|
211 if (fp_ptr->head.magic == FPSIMD_MAGIC) { |
|
212 memcpy(&g_crash_context_.float_state, fp_ptr, |
|
213 sizeof(g_crash_context_.float_state)); |
|
214 } |
|
215 #elif !defined(__ARM_EABI__) && !defined(__mips__) |
|
216 // FP state is not part of user ABI on ARM Linux. |
|
217 // In case of MIPS Linux FP state is already part of struct ucontext |
|
218 // and 'float_state' is not a member of CrashContext. |
|
219 - struct ucontext* uc_ptr = (struct ucontext*)uc; |
|
220 + ucontext_t* uc_ptr = (ucontext_t*)uc; |
|
221 if (uc_ptr->uc_mcontext.fpregs) { |
|
222 memcpy(&g_crash_context_.float_state, uc_ptr->uc_mcontext.fpregs, |
|
223 sizeof(g_crash_context_.float_state)); |
|
224 } |
|
225 #endif |
|
226 g_crash_context_.tid = syscall(__NR_gettid); |
|
227 if (crash_handler_ != NULL) { |
|
228 if (crash_handler_(&g_crash_context_, sizeof(g_crash_context_), |
|
229 @@ -471,17 +471,17 @@ bool ExceptionHandler::HandleSignal(int |
|
230 // This is a public interface to HandleSignal that allows the client to |
|
231 // generate a crash dump. This function may run in a compromised context. |
|
232 bool ExceptionHandler::SimulateSignalDelivery(int sig) { |
|
233 siginfo_t siginfo = {}; |
|
234 // Mimic a trusted signal to allow tracing the process (see |
|
235 // ExceptionHandler::HandleSignal(). |
|
236 siginfo.si_code = SI_USER; |
|
237 siginfo.si_pid = getpid(); |
|
238 - struct ucontext context; |
|
239 + ucontext_t context; |
|
240 getcontext(&context); |
|
241 return HandleSignal(sig, &siginfo, &context); |
|
242 } |
|
243 |
|
244 // This function may run in a compromised context: see the top of the file. |
|
245 bool ExceptionHandler::GenerateDump(CrashContext *context) { |
|
246 if (IsOutOfProcess()) |
|
247 return crash_generation_client_->RequestDump(context, sizeof(*context)); |
|
248 diff --git a/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.h b/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.h |
|
249 --- a/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.h |
|
250 +++ b/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.h |
|
251 @@ -186,17 +186,17 @@ class ExceptionHandler { |
|
252 MinidumpCallback callback, |
|
253 void* callback_context); |
|
254 |
|
255 // This structure is passed to minidump_writer.h:WriteMinidump via an opaque |
|
256 // blob. It shouldn't be needed in any user code. |
|
257 struct CrashContext { |
|
258 siginfo_t siginfo; |
|
259 pid_t tid; // the crashing thread. |
|
260 - struct ucontext context; |
|
261 + ucontext_t context; |
|
262 #if !defined(__ARM_EABI__) && !defined(__mips__) |
|
263 // #ifdef this out because FP state is not part of user ABI for Linux ARM. |
|
264 // In case of MIPS Linux FP state is already part of struct |
|
265 // ucontext so 'float_state' is not required. |
|
266 fpstate_t float_state; |
|
267 #endif |
|
268 }; |
|
269 |
|
270 diff --git a/toolkit/crashreporter/breakpad-client/linux/microdump_writer/microdump_writer.cc b/toolkit/crashreporter/breakpad-client/linux/microdump_writer/microdump_writer.cc |
|
271 --- a/toolkit/crashreporter/breakpad-client/linux/microdump_writer/microdump_writer.cc |
|
272 +++ b/toolkit/crashreporter/breakpad-client/linux/microdump_writer/microdump_writer.cc |
|
273 @@ -566,17 +566,17 @@ class MicrodumpWriter { |
|
274 ++iter) { |
|
275 DumpModule(iter->first, false, 0, iter->second); |
|
276 } |
|
277 return true; |
|
278 } |
|
279 |
|
280 void* Alloc(unsigned bytes) { return dumper_->allocator()->Alloc(bytes); } |
|
281 |
|
282 - const struct ucontext* const ucontext_; |
|
283 + const ucontext_t* const ucontext_; |
|
284 #if !defined(__ARM_EABI__) && !defined(__mips__) |
|
285 const google_breakpad::fpstate_t* const float_state_; |
|
286 #endif |
|
287 LinuxDumper* dumper_; |
|
288 const MappingList& mapping_list_; |
|
289 const MicrodumpExtraInfo microdump_extra_info_; |
|
290 char* log_line_; |
|
291 }; |
|
292 diff --git a/toolkit/crashreporter/breakpad-client/linux/minidump_writer/minidump_writer.cc b/toolkit/crashreporter/breakpad-client/linux/minidump_writer/minidump_writer.cc |
|
293 --- a/toolkit/crashreporter/breakpad-client/linux/minidump_writer/minidump_writer.cc |
|
294 +++ b/toolkit/crashreporter/breakpad-client/linux/minidump_writer/minidump_writer.cc |
|
295 @@ -1242,17 +1242,17 @@ class MinidumpWriter { |
|
296 return false; |
|
297 return WriteFile(result, buf); |
|
298 } |
|
299 |
|
300 // Only one of the 2 member variables below should be set to a valid value. |
|
301 const int fd_; // File descriptor where the minidum should be written. |
|
302 const char* path_; // Path to the file where the minidum should be written. |
|
303 |
|
304 - const struct ucontext* const ucontext_; // also from the signal handler |
|
305 + const ucontext_t* const ucontext_; // also from the signal handler |
|
306 #if !defined(__ARM_EABI__) && !defined(__mips__) |
|
307 const google_breakpad::fpstate_t* const float_state_; // ditto |
|
308 #endif |
|
309 LinuxDumper* dumper_; |
|
310 MinidumpFileWriter minidump_writer_; |
|
311 off_t minidump_size_limit_; |
|
312 MDLocationDescriptor crashing_thread_context_; |
|
313 // Blocks of memory written to the dump. These are all currently |
|