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/process_reader_win.h" | 18 #include "snapshot/win/process_reader_win.h" |
19 | 19 |
20 namespace crashpad { | 20 namespace crashpad { |
21 namespace internal { | 21 namespace internal { |
22 | 22 |
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; | |
cpu_(ooo_6.6-7.5)
2015/05/12 01:06:50
44 is the only one that breaks uniform naming... i
scottmg
2015/05/12 19:37:05
Do you mean the capitalization of the name? (This
| |
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 out->dr6 = context.Dr6; | |
54 out->dr7 = context.Dr7; | |
55 | |
56 static_assert(sizeof(out->fxsave) == sizeof(context.FltSave), | |
57 "types must be equivalent"); | |
58 memcpy(&out->fxsave, &context.FltSave.ControlWord, sizeof(out->fxsave)); | |
59 } | |
60 | |
61 void InitializeX86Context(const CONTEXT& context, | |
62 CPUContextX86* out) { | |
63 CHECK(false) << "TODO(scottmg) InitializeX86Context()"; | |
64 } | |
65 | |
66 } // namespace | |
67 | |
23 ThreadSnapshotWin::ThreadSnapshotWin() | 68 ThreadSnapshotWin::ThreadSnapshotWin() |
24 : ThreadSnapshot(), context_(), stack_(), thread_(), initialized_() { | 69 : ThreadSnapshot(), context_(), stack_(), thread_(), initialized_() { |
25 } | 70 } |
26 | 71 |
27 ThreadSnapshotWin::~ThreadSnapshotWin() { | 72 ThreadSnapshotWin::~ThreadSnapshotWin() { |
28 } | 73 } |
29 | 74 |
30 bool ThreadSnapshotWin::Initialize( | 75 bool ThreadSnapshotWin::Initialize( |
31 ProcessReaderWin* process_reader, | 76 ProcessReaderWin* process_reader, |
32 const ProcessReaderWin::Thread& process_reader_thread) { | 77 const ProcessReaderWin::Thread& process_reader_thread) { |
33 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); | 78 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); |
34 | 79 |
35 thread_ = process_reader_thread; | 80 thread_ = process_reader_thread; |
36 stack_.Initialize( | 81 stack_.Initialize( |
37 process_reader, thread_.stack_region_address, thread_.stack_region_size); | 82 process_reader, thread_.stack_region_address, thread_.stack_region_size); |
38 | 83 |
84 #if defined(ARCH_CPU_X86_FAMILY) | |
85 if (process_reader->Is64Bit()) { | |
86 context_.architecture = kCPUArchitectureX86_64; | |
87 context_.x86_64 = &context_union_.x86_64; | |
88 InitializeX64Context(process_reader_thread.context, context_.x86_64); | |
89 } else { | |
90 context_.architecture = kCPUArchitectureX86; | |
91 context_.x86 = &context_union_.x86; | |
92 InitializeX86Context(process_reader_thread.context, context_.x86); | |
93 } | |
94 #endif | |
95 | |
39 INITIALIZATION_STATE_SET_VALID(initialized_); | 96 INITIALIZATION_STATE_SET_VALID(initialized_); |
40 return true; | 97 return true; |
41 } | 98 } |
42 | 99 |
43 const CPUContext* ThreadSnapshotWin::Context() const { | 100 const CPUContext* ThreadSnapshotWin::Context() const { |
44 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 101 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
45 LOG(ERROR) << "TODO(scottmg): CPUContext"; | |
46 return &context_; | 102 return &context_; |
47 } | 103 } |
48 | 104 |
49 const MemorySnapshot* ThreadSnapshotWin::Stack() const { | 105 const MemorySnapshot* ThreadSnapshotWin::Stack() const { |
50 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 106 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
51 return &stack_; | 107 return &stack_; |
52 } | 108 } |
53 | 109 |
54 uint64_t ThreadSnapshotWin::ThreadID() const { | 110 uint64_t ThreadSnapshotWin::ThreadID() const { |
55 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 111 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
(...skipping 10 matching lines...) Expand all Loading... | |
66 return thread_.priority; | 122 return thread_.priority; |
67 } | 123 } |
68 | 124 |
69 uint64_t ThreadSnapshotWin::ThreadSpecificDataAddress() const { | 125 uint64_t ThreadSnapshotWin::ThreadSpecificDataAddress() const { |
70 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 126 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
71 return thread_.teb; | 127 return thread_.teb; |
72 } | 128 } |
73 | 129 |
74 } // namespace internal | 130 } // namespace internal |
75 } // namespace crashpad | 131 } // namespace crashpad |
OLD | NEW |