| 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 <algorithm> | 17 #include <algorithm> |
| 18 | 18 |
| 19 #include "base/logging.h" | 19 #include "base/logging.h" |
| 20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 21 #include "snapshot/win/memory_snapshot_win.h" |
| 21 #include "snapshot/win/module_snapshot_win.h" | 22 #include "snapshot/win/module_snapshot_win.h" |
| 22 #include "util/win/registration_protocol_win.h" | 23 #include "util/win/registration_protocol_win.h" |
| 23 #include "util/win/time.h" | 24 #include "util/win/time.h" |
| 24 | 25 |
| 25 namespace crashpad { | 26 namespace crashpad { |
| 26 | 27 |
| 27 ProcessSnapshotWin::ProcessSnapshotWin() | 28 ProcessSnapshotWin::ProcessSnapshotWin() |
| 28 : ProcessSnapshot(), | 29 : ProcessSnapshot(), |
| 29 system_(), | 30 system_(), |
| 30 threads_(), | 31 threads_(), |
| 31 modules_(), | 32 modules_(), |
| 32 exception_(), | 33 exception_(), |
| 34 memory_map_(), |
| 33 process_reader_(), | 35 process_reader_(), |
| 34 report_id_(), | 36 report_id_(), |
| 35 client_id_(), | 37 client_id_(), |
| 36 annotations_simple_map_(), | 38 annotations_simple_map_(), |
| 37 snapshot_time_(), | 39 snapshot_time_(), |
| 38 initialized_() { | 40 initialized_() { |
| 39 } | 41 } |
| 40 | 42 |
| 41 ProcessSnapshotWin::~ProcessSnapshotWin() { | 43 ProcessSnapshotWin::~ProcessSnapshotWin() { |
| 42 } | 44 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 53 system_.Initialize(&process_reader_); | 55 system_.Initialize(&process_reader_); |
| 54 | 56 |
| 55 if (process_reader_.Is64Bit()) | 57 if (process_reader_.Is64Bit()) |
| 56 InitializePebData<process_types::internal::Traits64>(); | 58 InitializePebData<process_types::internal::Traits64>(); |
| 57 else | 59 else |
| 58 InitializePebData<process_types::internal::Traits32>(); | 60 InitializePebData<process_types::internal::Traits32>(); |
| 59 | 61 |
| 60 InitializeThreads(); | 62 InitializeThreads(); |
| 61 InitializeModules(); | 63 InitializeModules(); |
| 62 | 64 |
| 65 memory_map_.Initialize(&process_reader_); |
| 66 |
| 63 INITIALIZATION_STATE_SET_VALID(initialized_); | 67 INITIALIZATION_STATE_SET_VALID(initialized_); |
| 64 return true; | 68 return true; |
| 65 } | 69 } |
| 66 | 70 |
| 67 bool ProcessSnapshotWin::InitializeException( | 71 bool ProcessSnapshotWin::InitializeException( |
| 68 WinVMAddress exception_information_address) { | 72 WinVMAddress exception_information_address) { |
| 69 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 73 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 70 DCHECK(!exception_); | 74 DCHECK(!exception_); |
| 71 | 75 |
| 72 ExceptionInformation exception_information; | 76 ExceptionInformation exception_information; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 for (internal::ModuleSnapshotWin* module : modules_) { | 184 for (internal::ModuleSnapshotWin* module : modules_) { |
| 181 modules.push_back(module); | 185 modules.push_back(module); |
| 182 } | 186 } |
| 183 return modules; | 187 return modules; |
| 184 } | 188 } |
| 185 | 189 |
| 186 const ExceptionSnapshot* ProcessSnapshotWin::Exception() const { | 190 const ExceptionSnapshot* ProcessSnapshotWin::Exception() const { |
| 187 return exception_.get(); | 191 return exception_.get(); |
| 188 } | 192 } |
| 189 | 193 |
| 194 const MemoryMapSnapshot* ProcessSnapshotWin::MemoryMap() const { |
| 195 return &memory_map_; |
| 196 } |
| 197 |
| 190 std::vector<const MemorySnapshot*> ProcessSnapshotWin::ExtraMemory() const { | 198 std::vector<const MemorySnapshot*> ProcessSnapshotWin::ExtraMemory() const { |
| 191 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 199 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 192 std::vector<const MemorySnapshot*> extra_memory; | 200 std::vector<const MemorySnapshot*> extra_memory; |
| 193 for (const auto& peb_memory : peb_memory_) | 201 for (const auto& peb_memory : peb_memory_) |
| 194 extra_memory.push_back(peb_memory); | 202 extra_memory.push_back(peb_memory); |
| 195 return extra_memory; | 203 return extra_memory; |
| 196 } | 204 } |
| 197 | 205 |
| 198 void ProcessSnapshotWin::InitializeThreads() { | 206 void ProcessSnapshotWin::InitializeThreads() { |
| 199 const std::vector<ProcessReaderWin::Thread>& process_reader_threads = | 207 const std::vector<ProcessReaderWin::Thread>& process_reader_threads = |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 static_cast<unsigned int>(bytes_read / sizeof(env_block[0]))); | 386 static_cast<unsigned int>(bytes_read / sizeof(env_block[0]))); |
| 379 const wchar_t terminator[] = { 0, 0 }; | 387 const wchar_t terminator[] = { 0, 0 }; |
| 380 size_t at = env_block.find(std::wstring(terminator, arraysize(terminator))); | 388 size_t at = env_block.find(std::wstring(terminator, arraysize(terminator))); |
| 381 if (at != std::wstring::npos) | 389 if (at != std::wstring::npos) |
| 382 env_block.resize(at + arraysize(terminator)); | 390 env_block.resize(at + arraysize(terminator)); |
| 383 | 391 |
| 384 return env_block.size() * sizeof(env_block[0]); | 392 return env_block.size() * sizeof(env_block[0]); |
| 385 } | 393 } |
| 386 | 394 |
| 387 } // namespace crashpad | 395 } // namespace crashpad |
| OLD | NEW |