| 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 "base/logging.h" |
| 17 #include "snapshot/win/module_snapshot_win.h" | 18 #include "snapshot/win/module_snapshot_win.h" |
| 18 #include "util/win/time.h" | 19 #include "util/win/time.h" |
| 19 | 20 |
| 20 namespace crashpad { | 21 namespace crashpad { |
| 21 | 22 |
| 22 ProcessSnapshotWin::ProcessSnapshotWin() | 23 ProcessSnapshotWin::ProcessSnapshotWin() |
| 23 : ProcessSnapshot(), | 24 : ProcessSnapshot(), |
| 24 system_(), | 25 system_(), |
| 25 threads_(), | 26 threads_(), |
| 26 modules_(), | 27 modules_(), |
| 27 // TODO(scottmg): exception_(), | 28 exception_(), |
| 28 process_reader_(), | 29 process_reader_(), |
| 29 report_id_(), | 30 report_id_(), |
| 30 client_id_(), | 31 client_id_(), |
| 31 annotations_simple_map_(), | 32 annotations_simple_map_(), |
| 32 snapshot_time_(), | 33 snapshot_time_(), |
| 33 initialized_() { | 34 initialized_() { |
| 34 } | 35 } |
| 35 | 36 |
| 36 ProcessSnapshotWin::~ProcessSnapshotWin() { | 37 ProcessSnapshotWin::~ProcessSnapshotWin() { |
| 37 } | 38 } |
| 38 | 39 |
| 39 bool ProcessSnapshotWin::Initialize(HANDLE process) { | 40 bool ProcessSnapshotWin::Initialize(HANDLE process) { |
| 40 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); | 41 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); |
| 41 | 42 |
| 42 GetTimeOfDay(&snapshot_time_); | 43 GetTimeOfDay(&snapshot_time_); |
| 43 | 44 |
| 44 if (!process_reader_.Initialize(process)) | 45 if (!process_reader_.Initialize(process)) |
| 45 return false; | 46 return false; |
| 46 | 47 |
| 47 system_.Initialize(&process_reader_); | 48 system_.Initialize(&process_reader_); |
| 48 | 49 |
| 49 InitializeThreads(); | 50 InitializeThreads(); |
| 50 InitializeModules(); | 51 InitializeModules(); |
| 51 | 52 |
| 52 INITIALIZATION_STATE_SET_VALID(initialized_); | 53 INITIALIZATION_STATE_SET_VALID(initialized_); |
| 53 return true; | 54 return true; |
| 54 } | 55 } |
| 55 | 56 |
| 57 bool ProcessSnapshotWin::InitializeException( |
| 58 DWORD thread_id, |
| 59 WinVMAddress exception_pointers) { |
| 60 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 61 DCHECK(!exception_); |
| 62 |
| 63 exception_.reset(new internal::ExceptionSnapshotWin()); |
| 64 if (!exception_->Initialize( |
| 65 &process_reader_, thread_id, exception_pointers)) { |
| 66 exception_.reset(); |
| 67 return false; |
| 68 } |
| 69 |
| 70 return true; |
| 71 } |
| 72 |
| 56 void ProcessSnapshotWin::GetCrashpadOptions( | 73 void ProcessSnapshotWin::GetCrashpadOptions( |
| 57 CrashpadInfoClientOptions* options) { | 74 CrashpadInfoClientOptions* options) { |
| 58 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 75 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 59 | 76 |
| 60 CrashpadInfoClientOptions local_options; | 77 CrashpadInfoClientOptions local_options; |
| 61 | 78 |
| 62 for (internal::ModuleSnapshotWin* module : modules_) { | 79 for (internal::ModuleSnapshotWin* module : modules_) { |
| 63 CrashpadInfoClientOptions module_options; | 80 CrashpadInfoClientOptions module_options; |
| 64 module->GetCrashpadOptions(&module_options); | 81 module->GetCrashpadOptions(&module_options); |
| 65 | 82 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 std::vector<const ModuleSnapshot*> ProcessSnapshotWin::Modules() const { | 159 std::vector<const ModuleSnapshot*> ProcessSnapshotWin::Modules() const { |
| 143 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 160 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 144 std::vector<const ModuleSnapshot*> modules; | 161 std::vector<const ModuleSnapshot*> modules; |
| 145 for (internal::ModuleSnapshotWin* module : modules_) { | 162 for (internal::ModuleSnapshotWin* module : modules_) { |
| 146 modules.push_back(module); | 163 modules.push_back(module); |
| 147 } | 164 } |
| 148 return modules; | 165 return modules; |
| 149 } | 166 } |
| 150 | 167 |
| 151 const ExceptionSnapshot* ProcessSnapshotWin::Exception() const { | 168 const ExceptionSnapshot* ProcessSnapshotWin::Exception() const { |
| 152 CHECK(false) << "TODO(scottmg): Exception()"; | 169 return exception_.get(); |
| 153 return nullptr; | |
| 154 } | 170 } |
| 155 | 171 |
| 156 void ProcessSnapshotWin::InitializeThreads() { | 172 void ProcessSnapshotWin::InitializeThreads() { |
| 157 const std::vector<ProcessReaderWin::Thread>& process_reader_threads = | 173 const std::vector<ProcessReaderWin::Thread>& process_reader_threads = |
| 158 process_reader_.Threads(); | 174 process_reader_.Threads(); |
| 159 for (const ProcessReaderWin::Thread& process_reader_thread : | 175 for (const ProcessReaderWin::Thread& process_reader_thread : |
| 160 process_reader_threads) { | 176 process_reader_threads) { |
| 161 auto thread = make_scoped_ptr(new internal::ThreadSnapshotWin()); | 177 auto thread = make_scoped_ptr(new internal::ThreadSnapshotWin()); |
| 162 if (thread->Initialize(&process_reader_, process_reader_thread)) { | 178 if (thread->Initialize(&process_reader_, process_reader_thread)) { |
| 163 threads_.push_back(thread.release()); | 179 threads_.push_back(thread.release()); |
| 164 } | 180 } |
| 165 } | 181 } |
| 166 } | 182 } |
| 167 | 183 |
| 168 void ProcessSnapshotWin::InitializeModules() { | 184 void ProcessSnapshotWin::InitializeModules() { |
| 169 const std::vector<ProcessInfo::Module>& process_reader_modules = | 185 const std::vector<ProcessInfo::Module>& process_reader_modules = |
| 170 process_reader_.Modules(); | 186 process_reader_.Modules(); |
| 171 for (const ProcessInfo::Module& process_reader_module : | 187 for (const ProcessInfo::Module& process_reader_module : |
| 172 process_reader_modules) { | 188 process_reader_modules) { |
| 173 auto module = make_scoped_ptr(new internal::ModuleSnapshotWin()); | 189 auto module = make_scoped_ptr(new internal::ModuleSnapshotWin()); |
| 174 if (module->Initialize(&process_reader_, process_reader_module)) { | 190 if (module->Initialize(&process_reader_, process_reader_module)) { |
| 175 modules_.push_back(module.release()); | 191 modules_.push_back(module.release()); |
| 176 } | 192 } |
| 177 } | 193 } |
| 178 } | 194 } |
| 179 | 195 |
| 180 } // namespace crashpad | 196 } // namespace crashpad |
| OLD | NEW |