OLD | NEW |
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 224 |
224 out->float_save.fpsr = fpregs.fpsr; | 225 out->float_save.fpsr = fpregs.fpsr; |
225 out->float_save.fpcr = fpregs.fpcr; | 226 out->float_save.fpcr = fpregs.fpcr; |
226 my_memcpy(&out->float_save.regs, &fpregs.vregs, | 227 my_memcpy(&out->float_save.regs, &fpregs.vregs, |
227 MD_FLOATINGSAVEAREA_ARM64_FPR_COUNT * 16); | 228 MD_FLOATINGSAVEAREA_ARM64_FPR_COUNT * 16); |
228 } | 229 } |
229 | 230 |
230 #elif defined(__mips__) | 231 #elif defined(__mips__) |
231 | 232 |
232 uintptr_t ThreadInfo::GetInstructionPointer() const { | 233 uintptr_t ThreadInfo::GetInstructionPointer() const { |
233 return regs.epc; | 234 return mcontext.pc; |
234 } | 235 } |
235 | 236 |
236 void ThreadInfo::FillCPUContext(RawContextCPU* out) const { | 237 void ThreadInfo::FillCPUContext(RawContextCPU* out) const { |
237 out->context_flags = MD_CONTEXT_MIPS_FULL; | 238 out->context_flags = MD_CONTEXT_MIPS_FULL; |
238 | 239 |
239 for (int i = 0; i < MD_CONTEXT_MIPS_GPR_COUNT; ++i) | 240 for (int i = 0; i < MD_CONTEXT_MIPS_GPR_COUNT; ++i) |
240 out->iregs[i] = regs.regs[i]; | 241 out->iregs[i] = mcontext.gregs[i]; |
241 | 242 |
242 out->mdhi = regs.hi; | 243 out->mdhi = mcontext.mdhi; |
243 out->mdlo = regs.lo; | 244 out->mdlo = mcontext.mdlo; |
| 245 out->dsp_control = mcontext.dsp; |
244 | 246 |
245 for (int i = 0; i < MD_CONTEXT_MIPS_DSP_COUNT; ++i) { | 247 out->hi[0] = mcontext.hi1; |
246 out->hi[i] = hi[i]; | 248 out->lo[0] = mcontext.lo1; |
247 out->lo[i] = lo[i]; | 249 out->hi[1] = mcontext.hi2; |
248 } | 250 out->lo[1] = mcontext.lo2; |
249 out->dsp_control = dsp_control; | 251 out->hi[2] = mcontext.hi3; |
| 252 out->lo[2] = mcontext.lo3; |
250 | 253 |
251 out->epc = regs.epc; | 254 out->epc = mcontext.pc; |
252 out->badvaddr = regs.badvaddr; | 255 out->badvaddr = 0; // Not stored in mcontext |
253 out->status = regs.status; | 256 out->status = 0; // Not stored in mcontext |
254 out->cause = regs.cause; | 257 out->cause = 0; // Not stored in mcontext |
255 | 258 |
256 for (int i = 0; i < MD_FLOATINGSAVEAREA_MIPS_FPR_COUNT; ++i) | 259 for (int i = 0; i < MD_FLOATINGSAVEAREA_MIPS_FPR_COUNT; ++i) |
257 out->float_save.regs[i] = fpregs.regs[i]; | 260 out->float_save.regs[i] = mcontext.fpregs.fp_r.fp_fregs[i]._fp_fregs; |
258 | 261 |
259 out->float_save.fpcsr = fpregs.fpcsr; | 262 out->float_save.fpcsr = mcontext.fpc_csr; |
260 #if _MIPS_SIM == _ABIO32 | 263 #if _MIPS_SIM == _ABIO32 |
261 out->float_save.fir = fpregs.fir; | 264 out->float_save.fir = mcontext.fpc_eir; |
262 #endif | 265 #endif |
263 } | 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); |
264 #endif | 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 } |
265 | 298 |
266 } // namespace google_breakpad | 299 } // namespace google_breakpad |
OLD | NEW |