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