OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 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, |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 144 |
145 bool ProcessReader::CPUTimes(timeval* user_time, timeval* system_time) const { | 145 bool ProcessReader::CPUTimes(timeval* user_time, timeval* system_time) const { |
146 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 146 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
147 | 147 |
148 // Calculate user and system time the same way the kernel does for | 148 // Calculate user and system time the same way the kernel does for |
149 // getrusage(). See 10.9.2 xnu-2422.90.20/bsd/kern/kern_resource.c calcru(). | 149 // getrusage(). See 10.9.2 xnu-2422.90.20/bsd/kern/kern_resource.c calcru(). |
150 timerclear(user_time); | 150 timerclear(user_time); |
151 timerclear(system_time); | 151 timerclear(system_time); |
152 | 152 |
153 // As of the 10.8 SDK, the preferred routine is MACH_TASK_BASIC_INFO. | 153 // As of the 10.8 SDK, the preferred routine is MACH_TASK_BASIC_INFO. |
154 // TASK_BASIC_INFO_64_COUNT is equivalent and works on earlier systems. | 154 // TASK_BASIC_INFO_64 is equivalent and works on earlier systems. |
155 task_basic_info_64 task_basic_info; | 155 task_basic_info_64 task_basic_info; |
156 mach_msg_type_number_t task_basic_info_count = TASK_BASIC_INFO_64_COUNT; | 156 mach_msg_type_number_t task_basic_info_count = TASK_BASIC_INFO_64_COUNT; |
157 kern_return_t kr = task_info(task_, | 157 kern_return_t kr = task_info(task_, |
158 TASK_BASIC_INFO_64, | 158 TASK_BASIC_INFO_64, |
159 reinterpret_cast<task_info_t>(&task_basic_info), | 159 reinterpret_cast<task_info_t>(&task_basic_info), |
160 &task_basic_info_count); | 160 &task_basic_info_count); |
161 if (kr != KERN_SUCCESS) { | 161 if (kr != KERN_SUCCESS) { |
162 MACH_LOG(WARNING, kr) << "task_info TASK_BASIC_INFO_64"; | 162 MACH_LOG(WARNING, kr) << "task_info TASK_BASIC_INFO_64"; |
163 return false; | 163 return false; |
164 } | 164 } |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 // The red zone would go lower into another region in memory, but no | 707 // The red zone would go lower into another region in memory, but no |
708 // region was found. Memory can only be captured to an address as low as | 708 // region was found. Memory can only be captured to an address as low as |
709 // the base address of the region already found. | 709 // the base address of the region already found. |
710 *start_address = *region_base; | 710 *start_address = *region_base; |
711 } | 711 } |
712 } | 712 } |
713 #endif | 713 #endif |
714 } | 714 } |
715 | 715 |
716 } // namespace crashpad | 716 } // namespace crashpad |
OLD | NEW |