| 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 for (const MEMORY_BASIC_INFORMATION64& mbi : |
| 66 process_reader_.GetProcessInfo().MemoryInfo()) { |
| 67 memory_map_.push_back(new internal::MemoryMapRegionSnapshotWin(mbi)); |
| 68 } |
| 69 |
| 63 INITIALIZATION_STATE_SET_VALID(initialized_); | 70 INITIALIZATION_STATE_SET_VALID(initialized_); |
| 64 return true; | 71 return true; |
| 65 } | 72 } |
| 66 | 73 |
| 67 bool ProcessSnapshotWin::InitializeException( | 74 bool ProcessSnapshotWin::InitializeException( |
| 68 WinVMAddress exception_information_address) { | 75 WinVMAddress exception_information_address) { |
| 69 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 76 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 70 DCHECK(!exception_); | 77 DCHECK(!exception_); |
| 71 | 78 |
| 72 ExceptionInformation exception_information; | 79 ExceptionInformation exception_information; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 for (internal::ModuleSnapshotWin* module : modules_) { | 187 for (internal::ModuleSnapshotWin* module : modules_) { |
| 181 modules.push_back(module); | 188 modules.push_back(module); |
| 182 } | 189 } |
| 183 return modules; | 190 return modules; |
| 184 } | 191 } |
| 185 | 192 |
| 186 const ExceptionSnapshot* ProcessSnapshotWin::Exception() const { | 193 const ExceptionSnapshot* ProcessSnapshotWin::Exception() const { |
| 187 return exception_.get(); | 194 return exception_.get(); |
| 188 } | 195 } |
| 189 | 196 |
| 197 std::vector<const MemoryMapRegionSnapshot*> ProcessSnapshotWin::MemoryMap() |
| 198 const { |
| 199 std::vector<const MemoryMapRegionSnapshot*> memory_map; |
| 200 for (const auto& item : memory_map_) |
| 201 memory_map.push_back(item); |
| 202 return memory_map; |
| 203 } |
| 204 |
| 190 std::vector<const MemorySnapshot*> ProcessSnapshotWin::ExtraMemory() const { | 205 std::vector<const MemorySnapshot*> ProcessSnapshotWin::ExtraMemory() const { |
| 191 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 206 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 192 std::vector<const MemorySnapshot*> extra_memory; | 207 std::vector<const MemorySnapshot*> extra_memory; |
| 193 for (const auto& peb_memory : peb_memory_) | 208 for (const auto& peb_memory : peb_memory_) |
| 194 extra_memory.push_back(peb_memory); | 209 extra_memory.push_back(peb_memory); |
| 195 return extra_memory; | 210 return extra_memory; |
| 196 } | 211 } |
| 197 | 212 |
| 198 void ProcessSnapshotWin::InitializeThreads() { | 213 void ProcessSnapshotWin::InitializeThreads() { |
| 199 const std::vector<ProcessReaderWin::Thread>& process_reader_threads = | 214 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]))); | 393 static_cast<unsigned int>(bytes_read / sizeof(env_block[0]))); |
| 379 const wchar_t terminator[] = { 0, 0 }; | 394 const wchar_t terminator[] = { 0, 0 }; |
| 380 size_t at = env_block.find(std::wstring(terminator, arraysize(terminator))); | 395 size_t at = env_block.find(std::wstring(terminator, arraysize(terminator))); |
| 381 if (at != std::wstring::npos) | 396 if (at != std::wstring::npos) |
| 382 env_block.resize(at + arraysize(terminator)); | 397 env_block.resize(at + arraysize(terminator)); |
| 383 | 398 |
| 384 return env_block.size() * sizeof(env_block[0]); | 399 return env_block.size() * sizeof(env_block[0]); |
| 385 } | 400 } |
| 386 | 401 |
| 387 } // namespace crashpad | 402 } // namespace crashpad |
| OLD | NEW |