| 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_reader_win.h" | 15 #include "snapshot/win/process_reader_win.h" |
| 16 | 16 |
| 17 #include "base/numerics/safe_conversions.h" | 17 #include "base/numerics/safe_conversions.h" |
| 18 #include "util/win/time.h" |
| 18 | 19 |
| 19 namespace crashpad { | 20 namespace crashpad { |
| 20 | 21 |
| 21 ProcessReaderWin::ProcessReaderWin() | 22 ProcessReaderWin::ProcessReaderWin() |
| 22 : process_(INVALID_HANDLE_VALUE), | 23 : process_(INVALID_HANDLE_VALUE), |
| 23 process_info_(), | 24 process_info_(), |
| 24 modules_(), | 25 modules_(), |
| 25 initialized_() { | 26 initialized_() { |
| 26 } | 27 } |
| 27 | 28 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 47 into, | 48 into, |
| 48 base::checked_cast<SIZE_T>(num_bytes), | 49 base::checked_cast<SIZE_T>(num_bytes), |
| 49 &bytes_read) || | 50 &bytes_read) || |
| 50 num_bytes != bytes_read) { | 51 num_bytes != bytes_read) { |
| 51 PLOG(ERROR) << "ReadMemory at " << at << " of " << num_bytes << " failed"; | 52 PLOG(ERROR) << "ReadMemory at " << at << " of " << num_bytes << " failed"; |
| 52 return false; | 53 return false; |
| 53 } | 54 } |
| 54 return true; | 55 return true; |
| 55 } | 56 } |
| 56 | 57 |
| 58 bool ProcessReaderWin::StartTime(timeval* start_time) const { |
| 59 FILETIME creation, exit, kernel, user; |
| 60 if (!GetProcessTimes(process_, &creation, &exit, &kernel, &user)) { |
| 61 PLOG(ERROR) << "GetProcessTimes"; |
| 62 return false; |
| 63 } |
| 64 *start_time = FiletimeToTimevalEpoch(creation); |
| 65 return true; |
| 66 } |
| 67 |
| 68 bool ProcessReaderWin::CPUTimes(timeval* user_time, |
| 69 timeval* system_time) const { |
| 70 FILETIME creation, exit, kernel, user; |
| 71 if (!GetProcessTimes(process_, &creation, &exit, &kernel, &user)) { |
| 72 PLOG(ERROR) << "GetProcessTimes"; |
| 73 return false; |
| 74 } |
| 75 *user_time = FiletimeToTimevalInterval(user); |
| 76 *system_time = FiletimeToTimevalInterval(kernel); |
| 77 return true; |
| 78 } |
| 79 |
| 57 const std::vector<ProcessInfo::Module>& ProcessReaderWin::Modules() { | 80 const std::vector<ProcessInfo::Module>& ProcessReaderWin::Modules() { |
| 58 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 81 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
| 59 | 82 |
| 60 if (!process_info_.Modules(&modules_)) { | 83 if (!process_info_.Modules(&modules_)) { |
| 61 LOG(ERROR) << "couldn't retrieve modules"; | 84 LOG(ERROR) << "couldn't retrieve modules"; |
| 62 } | 85 } |
| 63 | 86 |
| 64 return modules_; | 87 return modules_; |
| 65 } | 88 } |
| 66 | 89 |
| 67 } // namespace crashpad | 90 } // namespace crashpad |
| OLD | NEW |