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 <vector> |
| 18 |
17 #include "base/logging.h" | 19 #include "base/logging.h" |
18 #include "snapshot/win/cpu_context_win.h" | 20 #include "snapshot/win/cpu_context_win.h" |
19 #include "snapshot/win/process_reader_win.h" | 21 #include "snapshot/win/process_reader_win.h" |
20 | 22 |
21 namespace crashpad { | 23 namespace crashpad { |
22 namespace internal { | 24 namespace internal { |
23 | 25 |
24 ThreadSnapshotWin::ThreadSnapshotWin() | 26 ThreadSnapshotWin::ThreadSnapshotWin() |
25 : ThreadSnapshot(), context_(), stack_(), thread_(), initialized_() { | 27 : ThreadSnapshot(), |
| 28 context_(), |
| 29 stack_(), |
| 30 teb_(), |
| 31 thread_(), |
| 32 initialized_() { |
26 } | 33 } |
27 | 34 |
28 ThreadSnapshotWin::~ThreadSnapshotWin() { | 35 ThreadSnapshotWin::~ThreadSnapshotWin() { |
29 } | 36 } |
30 | 37 |
31 bool ThreadSnapshotWin::Initialize( | 38 bool ThreadSnapshotWin::Initialize( |
32 ProcessReaderWin* process_reader, | 39 ProcessReaderWin* process_reader, |
33 const ProcessReaderWin::Thread& process_reader_thread) { | 40 const ProcessReaderWin::Thread& process_reader_thread) { |
34 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); | 41 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); |
35 | 42 |
36 thread_ = process_reader_thread; | 43 thread_ = process_reader_thread; |
| 44 // TODO(scottmg): Ensure these regions are readable |
| 45 // https://code.google.com/p/crashpad/issues/detail?id=59 |
37 stack_.Initialize( | 46 stack_.Initialize( |
38 process_reader, thread_.stack_region_address, thread_.stack_region_size); | 47 process_reader, thread_.stack_region_address, thread_.stack_region_size); |
| 48 teb_.Initialize(process_reader, thread_.teb_address, thread_.teb_size); |
39 | 49 |
40 #if defined(ARCH_CPU_X86_64) | 50 #if defined(ARCH_CPU_X86_64) |
41 if (process_reader->Is64Bit()) { | 51 if (process_reader->Is64Bit()) { |
42 context_.architecture = kCPUArchitectureX86_64; | 52 context_.architecture = kCPUArchitectureX86_64; |
43 context_.x86_64 = &context_union_.x86_64; | 53 context_.x86_64 = &context_union_.x86_64; |
44 InitializeX64Context(process_reader_thread.context.native, context_.x86_64); | 54 InitializeX64Context(process_reader_thread.context.native, context_.x86_64); |
45 } else { | 55 } else { |
46 context_.architecture = kCPUArchitectureX86; | 56 context_.architecture = kCPUArchitectureX86; |
47 context_.x86 = &context_union_.x86; | 57 context_.x86 = &context_union_.x86; |
48 InitializeX86Context(process_reader_thread.context.wow64, context_.x86); | 58 InitializeX86Context(process_reader_thread.context.wow64, context_.x86); |
(...skipping 28 matching lines...) Expand all Loading... |
77 return thread_.suspend_count; | 87 return thread_.suspend_count; |
78 } | 88 } |
79 | 89 |
80 int ThreadSnapshotWin::Priority() const { | 90 int ThreadSnapshotWin::Priority() const { |
81 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 91 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
82 return thread_.priority; | 92 return thread_.priority; |
83 } | 93 } |
84 | 94 |
85 uint64_t ThreadSnapshotWin::ThreadSpecificDataAddress() const { | 95 uint64_t ThreadSnapshotWin::ThreadSpecificDataAddress() const { |
86 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 96 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
87 return thread_.teb; | 97 return thread_.teb_address; |
| 98 } |
| 99 |
| 100 std::vector<const MemorySnapshot*> ThreadSnapshotWin::ExtraMemory() const { |
| 101 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 102 // TODO(scottmg): Ensure this region is readable, and make sure we don't |
| 103 // discard the entire dump if it isn't. |
| 104 // https://code.google.com/p/crashpad/issues/detail?id=59 |
| 105 return std::vector<const MemorySnapshot*>(1, &teb_); |
88 } | 106 } |
89 | 107 |
90 } // namespace internal | 108 } // namespace internal |
91 } // namespace crashpad | 109 } // namespace crashpad |
OLD | NEW |