OLD | NEW |
1 // Copyright (c) 2012, Google Inc. | 1 // Copyright (c) 2012, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 183 |
184 line_reader->PopLine(line_len); | 184 line_reader->PopLine(line_len); |
185 } | 185 } |
186 sys_close(fd); | 186 sys_close(fd); |
187 | 187 |
188 if (info->ppid == -1 || info->tgid == -1) | 188 if (info->ppid == -1 || info->tgid == -1) |
189 return false; | 189 return false; |
190 | 190 |
191 #ifdef PTRACE_GETREGSET | 191 #ifdef PTRACE_GETREGSET |
192 struct iovec io; | 192 struct iovec io; |
193 io.iov_base = &info->regs; | 193 info->GetGeneralPurposeRegisters(&io.iov_base, &io.iov_len); |
194 io.iov_len = sizeof(info->regs); | |
195 if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_PRSTATUS, (void*)&io) == -1) { | 194 if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_PRSTATUS, (void*)&io) == -1) { |
196 return false; | 195 return false; |
197 } | 196 } |
198 | 197 |
199 io.iov_base = &info->fpregs; | 198 info->GetFloatingPointRegisters(&io.iov_base, &io.iov_len); |
200 io.iov_len = sizeof(info->fpregs); | |
201 if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_FPREGSET, (void*)&io) == -1) { | 199 if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_FPREGSET, (void*)&io) == -1) { |
202 return false; | 200 return false; |
203 } | 201 } |
204 #else | 202 #else // PTRACE_GETREGSET |
205 if (sys_ptrace(PTRACE_GETREGS, tid, NULL, &info->regs) == -1) { | 203 void* addr; |
| 204 info->GetGeneralPurposeRegisters(&addr, NULL); |
| 205 if (sys_ptrace(PTRACE_GETREGS, tid, NULL, addr) == -1) { |
206 return false; | 206 return false; |
207 } | 207 } |
208 | 208 |
209 if (sys_ptrace(PTRACE_GETFPREGS, tid, NULL, &info->fpregs) == -1) { | 209 info->GetFloatingPointRegisters(&addr, NULL); |
| 210 if (sys_ptrace(PTRACE_GETFPREGS, tid, NULL, addr) == -1) { |
210 return false; | 211 return false; |
211 } | 212 } |
212 #endif | 213 #endif |
213 | 214 |
214 #if defined(__i386) | 215 #if defined(__i386) |
215 #if !defined(bit_FXSAVE) // e.g. Clang | 216 #if !defined(bit_FXSAVE) // e.g. Clang |
216 #define bit_FXSAVE bit_FXSR | 217 #define bit_FXSAVE bit_FXSR |
217 #endif | 218 #endif |
218 // Detect if the CPU supports the FXSAVE/FXRSTOR instructions | 219 // Detect if the CPU supports the FXSAVE/FXRSTOR instructions |
219 int eax, ebx, ecx, edx; | 220 int eax, ebx, ecx, edx; |
(...skipping 14 matching lines...) Expand all Loading... |
234 reinterpret_cast<void*> (offsetof(struct user, | 235 reinterpret_cast<void*> (offsetof(struct user, |
235 u_debugreg[0]) + i * | 236 u_debugreg[0]) + i * |
236 sizeof(debugreg_t)), | 237 sizeof(debugreg_t)), |
237 &info->dregs[i]) == -1) { | 238 &info->dregs[i]) == -1) { |
238 return false; | 239 return false; |
239 } | 240 } |
240 } | 241 } |
241 #endif | 242 #endif |
242 | 243 |
243 #if defined(__mips__) | 244 #if defined(__mips__) |
244 for (int i = 0; i < 3; ++i) { | |
245 sys_ptrace(PTRACE_PEEKUSER, tid, | |
246 reinterpret_cast<void*>(DSP_BASE + (i * 2)), &info->hi[i]); | |
247 sys_ptrace(PTRACE_PEEKUSER, tid, | |
248 reinterpret_cast<void*>(DSP_BASE + (i * 2) + 1), &info->lo[i]); | |
249 } | |
250 sys_ptrace(PTRACE_PEEKUSER, tid, | 245 sys_ptrace(PTRACE_PEEKUSER, tid, |
251 reinterpret_cast<void*>(DSP_CONTROL), &info->dsp_control); | 246 reinterpret_cast<void*>(DSP_BASE), &info->mcontext.hi1); |
| 247 sys_ptrace(PTRACE_PEEKUSER, tid, |
| 248 reinterpret_cast<void*>(DSP_BASE + 1), &info->mcontext.lo1); |
| 249 sys_ptrace(PTRACE_PEEKUSER, tid, |
| 250 reinterpret_cast<void*>(DSP_BASE + 2), &info->mcontext.hi2); |
| 251 sys_ptrace(PTRACE_PEEKUSER, tid, |
| 252 reinterpret_cast<void*>(DSP_BASE + 3), &info->mcontext.lo2); |
| 253 sys_ptrace(PTRACE_PEEKUSER, tid, |
| 254 reinterpret_cast<void*>(DSP_BASE + 4), &info->mcontext.hi3); |
| 255 sys_ptrace(PTRACE_PEEKUSER, tid, |
| 256 reinterpret_cast<void*>(DSP_BASE + 5), &info->mcontext.lo3); |
| 257 sys_ptrace(PTRACE_PEEKUSER, tid, |
| 258 reinterpret_cast<void*>(DSP_CONTROL), &info->mcontext.dsp); |
252 #endif | 259 #endif |
253 | 260 |
254 const uint8_t* stack_pointer; | 261 const uint8_t* stack_pointer; |
255 #if defined(__i386) | 262 #if defined(__i386) |
256 my_memcpy(&stack_pointer, &info->regs.esp, sizeof(info->regs.esp)); | 263 my_memcpy(&stack_pointer, &info->regs.esp, sizeof(info->regs.esp)); |
257 #elif defined(__x86_64) | 264 #elif defined(__x86_64) |
258 my_memcpy(&stack_pointer, &info->regs.rsp, sizeof(info->regs.rsp)); | 265 my_memcpy(&stack_pointer, &info->regs.rsp, sizeof(info->regs.rsp)); |
259 #elif defined(__ARM_EABI__) | 266 #elif defined(__ARM_EABI__) |
260 my_memcpy(&stack_pointer, &info->regs.ARM_sp, sizeof(info->regs.ARM_sp)); | 267 my_memcpy(&stack_pointer, &info->regs.ARM_sp, sizeof(info->regs.ARM_sp)); |
261 #elif defined(__aarch64__) | 268 #elif defined(__aarch64__) |
262 my_memcpy(&stack_pointer, &info->regs.sp, sizeof(info->regs.sp)); | 269 my_memcpy(&stack_pointer, &info->regs.sp, sizeof(info->regs.sp)); |
263 #elif defined(__mips__) | 270 #elif defined(__mips__) |
264 stack_pointer = | 271 stack_pointer = |
265 reinterpret_cast<uint8_t*>(info->regs.regs[MD_CONTEXT_MIPS_REG_SP]); | 272 reinterpret_cast<uint8_t*>(info->mcontext.gregs[MD_CONTEXT_MIPS_REG_SP]); |
266 #else | 273 #else |
267 #error "This code hasn't been ported to your platform yet." | 274 #error "This code hasn't been ported to your platform yet." |
268 #endif | 275 #endif |
269 info->stack_pointer = reinterpret_cast<uintptr_t>(stack_pointer); | 276 info->stack_pointer = reinterpret_cast<uintptr_t>(stack_pointer); |
270 | 277 |
271 return true; | 278 return true; |
272 } | 279 } |
273 | 280 |
274 bool LinuxPtraceDumper::IsPostMortem() const { | 281 bool LinuxPtraceDumper::IsPostMortem() const { |
275 return false; | 282 return false; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } | 339 } |
333 } | 340 } |
334 dir_reader->PopEntry(); | 341 dir_reader->PopEntry(); |
335 } | 342 } |
336 | 343 |
337 sys_close(fd); | 344 sys_close(fd); |
338 return true; | 345 return true; |
339 } | 346 } |
340 | 347 |
341 } // namespace google_breakpad | 348 } // namespace google_breakpad |
OLD | NEW |