LEFT | RIGHT |
1 // Copyright (c) 2014, Google Inc. | 1 // Copyright (c) 2014, 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 12 matching lines...) Expand all Loading... |
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | 29 |
30 #include "client/linux/dump_writer_common/thread_info.h" | 30 #include "client/linux/dump_writer_common/thread_info.h" |
31 | 31 |
32 #include <string.h> | 32 #include <string.h> |
| 33 #include <assert.h> |
33 | 34 |
34 #include "common/linux/linux_libc_support.h" | 35 #include "common/linux/linux_libc_support.h" |
35 #include "google_breakpad/common/minidump_format.h" | 36 #include "google_breakpad/common/minidump_format.h" |
36 | 37 |
37 namespace { | 38 namespace { |
38 | 39 |
39 #if defined(__i386__) | 40 #if defined(__i386__) |
40 // Write a uint16_t to memory | 41 // Write a uint16_t to memory |
41 // out: memory location to write to | 42 // out: memory location to write to |
42 // v: value to write. | 43 // v: value to write. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 172 |
172 out->flt_save.control_word = fpregs.cwd; | 173 out->flt_save.control_word = fpregs.cwd; |
173 out->flt_save.status_word = fpregs.swd; | 174 out->flt_save.status_word = fpregs.swd; |
174 out->flt_save.tag_word = fpregs.ftw; | 175 out->flt_save.tag_word = fpregs.ftw; |
175 out->flt_save.error_opcode = fpregs.fop; | 176 out->flt_save.error_opcode = fpregs.fop; |
176 out->flt_save.error_offset = fpregs.rip; | 177 out->flt_save.error_offset = fpregs.rip; |
177 out->flt_save.error_selector = 0; // We don't have this. | 178 out->flt_save.error_selector = 0; // We don't have this. |
178 out->flt_save.data_offset = fpregs.rdp; | 179 out->flt_save.data_offset = fpregs.rdp; |
179 out->flt_save.data_selector = 0; // We don't have this. | 180 out->flt_save.data_selector = 0; // We don't have this. |
180 out->flt_save.mx_csr = fpregs.mxcsr; | 181 out->flt_save.mx_csr = fpregs.mxcsr; |
181 #if defined (__ANDROID__) | |
182 // Internal bug b/18097559 | |
183 out->flt_save.mx_csr_mask = fpregs.mxcsr_mask; | |
184 #else | |
185 out->flt_save.mx_csr_mask = fpregs.mxcr_mask; | 182 out->flt_save.mx_csr_mask = fpregs.mxcr_mask; |
186 #endif | 183 |
187 my_memcpy(&out->flt_save.float_registers, &fpregs.st_space, 8 * 16); | 184 my_memcpy(&out->flt_save.float_registers, &fpregs.st_space, 8 * 16); |
188 my_memcpy(&out->flt_save.xmm_registers, &fpregs.xmm_space, 16 * 16); | 185 my_memcpy(&out->flt_save.xmm_registers, &fpregs.xmm_space, 16 * 16); |
189 } | 186 } |
190 | 187 |
191 #elif defined(__ARM_EABI__) | 188 #elif defined(__ARM_EABI__) |
192 | 189 |
193 uintptr_t ThreadInfo::GetInstructionPointer() const { | 190 uintptr_t ThreadInfo::GetInstructionPointer() const { |
194 return regs.uregs[15]; | 191 return regs.uregs[15]; |
195 } | 192 } |
196 | 193 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 uintptr_t ThreadInfo::GetInstructionPointer() const { | 233 uintptr_t ThreadInfo::GetInstructionPointer() const { |
237 return mcontext.pc; | 234 return mcontext.pc; |
238 } | 235 } |
239 | 236 |
240 void ThreadInfo::FillCPUContext(RawContextCPU* out) const { | 237 void ThreadInfo::FillCPUContext(RawContextCPU* out) const { |
241 out->context_flags = MD_CONTEXT_MIPS_FULL; | 238 out->context_flags = MD_CONTEXT_MIPS_FULL; |
242 | 239 |
243 for (int i = 0; i < MD_CONTEXT_MIPS_GPR_COUNT; ++i) | 240 for (int i = 0; i < MD_CONTEXT_MIPS_GPR_COUNT; ++i) |
244 out->iregs[i] = mcontext.gregs[i]; | 241 out->iregs[i] = mcontext.gregs[i]; |
245 | 242 |
246 out->mdhi = mcontext.mdhi; | 243 out->mdhi = mcontext.mdhi; |
247 out->mdlo = mcontext.mdlo; | 244 out->mdlo = mcontext.mdlo; |
248 out->dsp_control = mcontext.dsp; | 245 out->dsp_control = mcontext.dsp; |
249 | 246 |
250 out->hi[0] = mcontext.hi1; | 247 out->hi[0] = mcontext.hi1; |
251 out->lo[0] = mcontext.lo1; | 248 out->lo[0] = mcontext.lo1; |
252 out->hi[1] = mcontext.hi2; | 249 out->hi[1] = mcontext.hi2; |
253 out->lo[1] = mcontext.lo2; | 250 out->lo[1] = mcontext.lo2; |
254 out->hi[2] = mcontext.hi3; | 251 out->hi[2] = mcontext.hi3; |
255 out->lo[2] = mcontext.lo3; | 252 out->lo[2] = mcontext.lo3; |
256 | 253 |
257 out->epc = mcontext.pc; | 254 out->epc = mcontext.pc; |
258 out->badvaddr = 0; // Not stored in mcontext | 255 out->badvaddr = 0; // Not stored in mcontext |
259 out->status = 0; // Not stored in mcontext | 256 out->status = 0; // Not stored in mcontext |
260 out->cause = 0; // Not stored in mcontext | 257 out->cause = 0; // Not stored in mcontext |
261 | 258 |
262 for (int i = 0; i < MD_FLOATINGSAVEAREA_MIPS_FPR_COUNT; ++i) | 259 for (int i = 0; i < MD_FLOATINGSAVEAREA_MIPS_FPR_COUNT; ++i) |
263 out->float_save.regs[i] = mcontext.fpregs.fp_r.fp_fregs[i]._fp_fregs; | 260 out->float_save.regs[i] = mcontext.fpregs.fp_r.fp_fregs[i]._fp_fregs; |
264 | 261 |
265 out->float_save.fpcsr = mcontext.fpc_csr; | 262 out->float_save.fpcsr = mcontext.fpc_csr; |
| 263 #if _MIPS_SIM == _ABIO32 |
266 out->float_save.fir = mcontext.fpc_eir; | 264 out->float_save.fir = mcontext.fpc_eir; |
267 } | 265 #endif |
268 #endif | 266 } |
| 267 #endif // __mips__ |
| 268 |
| 269 void ThreadInfo::GetGeneralPurposeRegisters(void** gp_regs, size_t* size) { |
| 270 assert(gp_regs || size); |
| 271 #if defined(__mips__) |
| 272 if (gp_regs) |
| 273 *gp_regs = mcontext.gregs; |
| 274 if (size) |
| 275 *size = sizeof(mcontext.gregs); |
| 276 #else |
| 277 if (gp_regs) |
| 278 *gp_regs = ®s; |
| 279 if (size) |
| 280 *size = sizeof(regs); |
| 281 #endif |
| 282 } |
| 283 |
| 284 void ThreadInfo::GetFloatingPointRegisters(void** fp_regs, size_t* size) { |
| 285 assert(fp_regs || size); |
| 286 #if defined(__mips__) |
| 287 if (fp_regs) |
| 288 *fp_regs = &mcontext.fpregs; |
| 289 if (size) |
| 290 *size = sizeof(mcontext.fpregs); |
| 291 #else |
| 292 if (fp_regs) |
| 293 *fp_regs = &fpregs; |
| 294 if (size) |
| 295 *size = sizeof(fpregs); |
| 296 #endif |
| 297 } |
269 | 298 |
270 } // namespace google_breakpad | 299 } // namespace google_breakpad |
LEFT | RIGHT |