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/process_snapshot_win.h" | 15 #include "snapshot/win/process_snapshot_win.h" |
16 | 16 |
17 #include "snapshot/win/module_snapshot_win.h" | 17 #include "snapshot/win/module_snapshot_win.h" |
18 #include "util/win/time.h" | 18 #include "util/win/time.h" |
19 | 19 |
20 namespace crashpad { | 20 namespace crashpad { |
21 | 21 |
22 ProcessSnapshotWin::ProcessSnapshotWin() | 22 ProcessSnapshotWin::ProcessSnapshotWin() |
23 : ProcessSnapshot(), | 23 : ProcessSnapshot(), |
24 system_(), | 24 system_(), |
25 // TODO(scottmg): threads_(), | 25 threads_(), |
26 modules_(), | 26 modules_(), |
27 // TODO(scottmg): exception_(), | 27 // TODO(scottmg): exception_(), |
28 process_reader_(), | 28 process_reader_(), |
29 report_id_(), | 29 report_id_(), |
30 client_id_(), | 30 client_id_(), |
31 annotations_simple_map_(), | 31 annotations_simple_map_(), |
32 snapshot_time_(), | 32 snapshot_time_(), |
33 initialized_() { | 33 initialized_() { |
34 } | 34 } |
35 | 35 |
36 ProcessSnapshotWin::~ProcessSnapshotWin() { | 36 ProcessSnapshotWin::~ProcessSnapshotWin() { |
37 } | 37 } |
38 | 38 |
39 bool ProcessSnapshotWin::Initialize(HANDLE process) { | 39 bool ProcessSnapshotWin::Initialize(HANDLE process) { |
40 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); | 40 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); |
41 | 41 |
42 GetTimeOfDay(&snapshot_time_); | 42 GetTimeOfDay(&snapshot_time_); |
43 | 43 |
44 if (!process_reader_.Initialize(process)) | 44 if (!process_reader_.Initialize(process)) |
45 return false; | 45 return false; |
46 | 46 |
47 system_.Initialize(&process_reader_); | 47 system_.Initialize(&process_reader_); |
48 | 48 |
49 // TODO(scottmg): InitializeThreads(); | 49 InitializeThreads(); |
50 InitializeModules(); | 50 InitializeModules(); |
51 | 51 |
52 INITIALIZATION_STATE_SET_VALID(initialized_); | 52 INITIALIZATION_STATE_SET_VALID(initialized_); |
53 return true; | 53 return true; |
54 } | 54 } |
55 | 55 |
56 void ProcessSnapshotWin::GetCrashpadOptions( | 56 void ProcessSnapshotWin::GetCrashpadOptions( |
57 CrashpadInfoClientOptions* options) { | 57 CrashpadInfoClientOptions* options) { |
58 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 58 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
59 | 59 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 124 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
125 return annotations_simple_map_; | 125 return annotations_simple_map_; |
126 } | 126 } |
127 | 127 |
128 const SystemSnapshot* ProcessSnapshotWin::System() const { | 128 const SystemSnapshot* ProcessSnapshotWin::System() const { |
129 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 129 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
130 return &system_; | 130 return &system_; |
131 } | 131 } |
132 | 132 |
133 std::vector<const ThreadSnapshot*> ProcessSnapshotWin::Threads() const { | 133 std::vector<const ThreadSnapshot*> ProcessSnapshotWin::Threads() const { |
134 CHECK(false) << "TODO(scottmg)"; | 134 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
135 return std::vector<const ThreadSnapshot*>(); | 135 std::vector<const ThreadSnapshot*> threads; |
| 136 for (internal::ThreadSnapshotWin* thread : threads_) { |
| 137 threads.push_back(thread); |
| 138 } |
| 139 return threads; |
136 } | 140 } |
137 | 141 |
138 std::vector<const ModuleSnapshot*> ProcessSnapshotWin::Modules() const { | 142 std::vector<const ModuleSnapshot*> ProcessSnapshotWin::Modules() const { |
139 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 143 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
140 std::vector<const ModuleSnapshot*> modules; | 144 std::vector<const ModuleSnapshot*> modules; |
141 for (internal::ModuleSnapshotWin* module : modules_) { | 145 for (internal::ModuleSnapshotWin* module : modules_) { |
142 modules.push_back(module); | 146 modules.push_back(module); |
143 } | 147 } |
144 return modules; | 148 return modules; |
145 } | 149 } |
146 | 150 |
147 const ExceptionSnapshot* ProcessSnapshotWin::Exception() const { | 151 const ExceptionSnapshot* ProcessSnapshotWin::Exception() const { |
148 CHECK(false) << "TODO(scottmg)"; | 152 CHECK(false) << "TODO(scottmg): Exception()"; |
149 return nullptr; | 153 return nullptr; |
150 } | 154 } |
151 | 155 |
| 156 void ProcessSnapshotWin::InitializeThreads() { |
| 157 const std::vector<ProcessReaderWin::Thread>& process_reader_threads = |
| 158 process_reader_.Threads(); |
| 159 for (const ProcessReaderWin::Thread& process_reader_thread : |
| 160 process_reader_threads) { |
| 161 auto thread = make_scoped_ptr(new internal::ThreadSnapshotWin()); |
| 162 if (thread->Initialize(&process_reader_, process_reader_thread)) { |
| 163 threads_.push_back(thread.release()); |
| 164 } |
| 165 } |
| 166 } |
| 167 |
152 void ProcessSnapshotWin::InitializeModules() { | 168 void ProcessSnapshotWin::InitializeModules() { |
153 const std::vector<ProcessInfo::Module>& process_reader_modules = | 169 const std::vector<ProcessInfo::Module>& process_reader_modules = |
154 process_reader_.Modules(); | 170 process_reader_.Modules(); |
155 for (const ProcessInfo::Module& process_reader_module : | 171 for (const ProcessInfo::Module& process_reader_module : |
156 process_reader_modules) { | 172 process_reader_modules) { |
157 auto module = make_scoped_ptr(new internal::ModuleSnapshotWin()); | 173 auto module = make_scoped_ptr(new internal::ModuleSnapshotWin()); |
158 if (module->Initialize(&process_reader_, process_reader_module)) { | 174 if (module->Initialize(&process_reader_, process_reader_module)) { |
159 modules_.push_back(module.release()); | 175 modules_.push_back(module.release()); |
160 } | 176 } |
161 } | 177 } |
162 } | 178 } |
163 | 179 |
164 } // namespace crashpad | 180 } // namespace crashpad |
OLD | NEW |