OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #include "snapshot/win/cpu_context_win.h" |
| 16 |
| 17 #include <string.h> |
| 18 |
| 19 #include "base/logging.h" |
| 20 #include "snapshot/cpu_context.h" |
| 21 |
| 22 namespace crashpad { |
| 23 |
| 24 #if defined(ARCH_CPU_64_BITS) |
| 25 |
| 26 void InitializeX86Context(const WOW64_CONTEXT& context, CPUContextX86* out) { |
| 27 CHECK(false) << "TODO(scottmg) InitializeX86Context()"; |
| 28 } |
| 29 |
| 30 void InitializeX64Context(const CONTEXT& context, CPUContextX86_64* out) { |
| 31 out->rax = context.Rax; |
| 32 out->rbx = context.Rbx; |
| 33 out->rcx = context.Rcx; |
| 34 out->rdx = context.Rdx; |
| 35 out->rdi = context.Rdi; |
| 36 out->rsi = context.Rsi; |
| 37 out->rbp = context.Rbp; |
| 38 out->rsp = context.Rsp; |
| 39 out->r8 = context.R8; |
| 40 out->r9 = context.R9; |
| 41 out->r10 = context.R10; |
| 42 out->r11 = context.R11; |
| 43 out->r12 = context.R12; |
| 44 out->r13 = context.R13; |
| 45 out->r14 = context.R14; |
| 46 out->r15 = context.R15; |
| 47 out->rip = context.Rip; |
| 48 out->rflags = context.EFlags; |
| 49 out->cs = context.SegCs; |
| 50 out->fs = context.SegFs; |
| 51 out->gs = context.SegGs; |
| 52 |
| 53 out->dr0 = context.Dr0; |
| 54 out->dr1 = context.Dr1; |
| 55 out->dr2 = context.Dr2; |
| 56 out->dr3 = context.Dr3; |
| 57 // DR4 and DR5 are obsolete synonyms for DR6 and DR7, see |
| 58 // http://en.wikipedia.org/wiki/X86_debug_register. |
| 59 out->dr4 = context.Dr6; |
| 60 out->dr5 = context.Dr7; |
| 61 out->dr6 = context.Dr6; |
| 62 out->dr7 = context.Dr7; |
| 63 |
| 64 static_assert(sizeof(out->fxsave) == sizeof(context.FltSave), |
| 65 "types must be equivalent"); |
| 66 memcpy(&out->fxsave, &context.FltSave.ControlWord, sizeof(out->fxsave)); |
| 67 } |
| 68 |
| 69 #else // ARCH_CPU_64_BITS |
| 70 |
| 71 void InitializeX86Context(const CONTEXT& context, CPUContextX86* out) { |
| 72 CHECK(false) << "TODO(scottmg) InitializeX86Context()"; |
| 73 } |
| 74 |
| 75 #endif // ARCH_CPU_64_BITS |
| 76 |
| 77 } // namespace crashpad |
OLD | NEW |