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> | 17 #include <vector> |
18 | 18 |
19 #include "base/logging.h" | 19 #include "base/logging.h" |
| 20 #include "snapshot/win/capture_context_memory.h" |
20 #include "snapshot/win/cpu_context_win.h" | 21 #include "snapshot/win/cpu_context_win.h" |
21 #include "snapshot/win/process_reader_win.h" | 22 #include "snapshot/win/process_reader_win.h" |
22 | 23 |
23 namespace crashpad { | 24 namespace crashpad { |
24 namespace internal { | 25 namespace internal { |
25 | 26 |
26 ThreadSnapshotWin::ThreadSnapshotWin() | 27 ThreadSnapshotWin::ThreadSnapshotWin() |
27 : ThreadSnapshot(), | 28 : ThreadSnapshot(), |
28 context_(), | 29 context_(), |
29 stack_(), | 30 stack_(), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 context_.architecture = kCPUArchitectureX86; | 69 context_.architecture = kCPUArchitectureX86; |
69 context_.x86 = &context_union_.x86; | 70 context_.x86 = &context_union_.x86; |
70 InitializeX86Context(process_reader_thread.context.wow64, context_.x86); | 71 InitializeX86Context(process_reader_thread.context.wow64, context_.x86); |
71 } | 72 } |
72 #else | 73 #else |
73 context_.architecture = kCPUArchitectureX86; | 74 context_.architecture = kCPUArchitectureX86; |
74 context_.x86 = &context_union_.x86; | 75 context_.x86 = &context_union_.x86; |
75 InitializeX86Context(process_reader_thread.context.native, context_.x86); | 76 InitializeX86Context(process_reader_thread.context.native, context_.x86); |
76 #endif // ARCH_CPU_X86_64 | 77 #endif // ARCH_CPU_X86_64 |
77 | 78 |
| 79 CaptureMemoryPointedToByContext( |
| 80 context_, process_reader, thread_, &pointed_to_memory_); |
| 81 |
78 INITIALIZATION_STATE_SET_VALID(initialized_); | 82 INITIALIZATION_STATE_SET_VALID(initialized_); |
79 return true; | 83 return true; |
80 } | 84 } |
81 | 85 |
82 const CPUContext* ThreadSnapshotWin::Context() const { | 86 const CPUContext* ThreadSnapshotWin::Context() const { |
83 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 87 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
84 return &context_; | 88 return &context_; |
85 } | 89 } |
86 | 90 |
87 const MemorySnapshot* ThreadSnapshotWin::Stack() const { | 91 const MemorySnapshot* ThreadSnapshotWin::Stack() const { |
(...skipping 16 matching lines...) Expand all Loading... |
104 return thread_.priority; | 108 return thread_.priority; |
105 } | 109 } |
106 | 110 |
107 uint64_t ThreadSnapshotWin::ThreadSpecificDataAddress() const { | 111 uint64_t ThreadSnapshotWin::ThreadSpecificDataAddress() const { |
108 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 112 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
109 return thread_.teb_address; | 113 return thread_.teb_address; |
110 } | 114 } |
111 | 115 |
112 std::vector<const MemorySnapshot*> ThreadSnapshotWin::ExtraMemory() const { | 116 std::vector<const MemorySnapshot*> ThreadSnapshotWin::ExtraMemory() const { |
113 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 117 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
114 // TODO(scottmg): Ensure this region is readable, and make sure we don't | 118 std::vector<const MemorySnapshot*> result; |
115 // discard the entire dump if it isn't. https://crashpad.chromium.org/bug/59 | 119 result.reserve(1 + pointed_to_memory_.size()); |
116 return std::vector<const MemorySnapshot*>(1, &teb_); | 120 result.push_back(&teb_); |
| 121 std::copy(pointed_to_memory_.begin(), |
| 122 pointed_to_memory_.end(), |
| 123 std::back_inserter(result)); |
| 124 return result; |
117 } | 125 } |
118 | 126 |
119 } // namespace internal | 127 } // namespace internal |
120 } // namespace crashpad | 128 } // namespace crashpad |
OLD | NEW |