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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 bool ProcessReader::Initialize(task_t task) { | 112 bool ProcessReader::Initialize(task_t task) { |
113 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); | 113 INITIALIZATION_STATE_SET_INITIALIZING(initialized_); |
114 | 114 |
115 if (!process_info_.InitializeFromTask(task)) { | 115 if (!process_info_.InitializeFromTask(task)) { |
116 return false; | 116 return false; |
117 } | 117 } |
118 | 118 |
119 is_64_bit_ = process_info_.Is64Bit(); | 119 if (!process_info_.Is64Bit(&is_64_bit_)) { |
| 120 return false; |
| 121 } |
120 | 122 |
121 task_memory_.reset(new TaskMemory(task)); | 123 task_memory_.reset(new TaskMemory(task)); |
122 task_ = task; | 124 task_ = task; |
123 | 125 |
124 INITIALIZATION_STATE_SET_VALID(initialized_); | 126 INITIALIZATION_STATE_SET_VALID(initialized_); |
125 return true; | 127 return true; |
126 } | 128 } |
127 | 129 |
| 130 void ProcessReader::StartTime(timeval* start_time) const { |
| 131 bool rv = process_info_.StartTime(start_time); |
| 132 DCHECK(rv); |
| 133 } |
| 134 |
128 bool ProcessReader::CPUTimes(timeval* user_time, timeval* system_time) const { | 135 bool ProcessReader::CPUTimes(timeval* user_time, timeval* system_time) const { |
129 INITIALIZATION_STATE_DCHECK_VALID(initialized_); | 136 INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
130 | 137 |
131 // Calculate user and system time the same way the kernel does for | 138 // Calculate user and system time the same way the kernel does for |
132 // getrusage(). See 10.9.2 xnu-2422.90.20/bsd/kern/kern_resource.c calcru(). | 139 // getrusage(). See 10.9.2 xnu-2422.90.20/bsd/kern/kern_resource.c calcru(). |
133 timerclear(user_time); | 140 timerclear(user_time); |
134 timerclear(system_time); | 141 timerclear(system_time); |
135 | 142 |
136 // As of the 10.8 SDK, the preferred routine is MACH_TASK_BASIC_INFO. | 143 // As of the 10.8 SDK, the preferred routine is MACH_TASK_BASIC_INFO. |
137 // TASK_BASIC_INFO_64 is equivalent and works on earlier systems. | 144 // TASK_BASIC_INFO_64 is equivalent and works on earlier systems. |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 // The red zone would go lower into another region in memory, but no | 715 // The red zone would go lower into another region in memory, but no |
709 // region was found. Memory can only be captured to an address as low as | 716 // region was found. Memory can only be captured to an address as low as |
710 // the base address of the region already found. | 717 // the base address of the region already found. |
711 *start_address = *region_base; | 718 *start_address = *region_base; |
712 } | 719 } |
713 } | 720 } |
714 #endif | 721 #endif |
715 } | 722 } |
716 | 723 |
717 } // namespace crashpad | 724 } // namespace crashpad |
OLD | NEW |