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, |
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 "util/mac/checked_mach_address_range.h" | 15 #include "util/mac/checked_mach_address_range.h" |
16 | 16 |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/numerics/safe_conversions.h" | 18 #include "base/numerics/safe_conversions.h" |
19 #include "util/mac/process_reader.h" | |
20 | 19 |
21 namespace crashpad { | 20 namespace crashpad { |
22 | 21 |
23 CheckedMachAddressRange::CheckedMachAddressRange() | 22 CheckedMachAddressRange::CheckedMachAddressRange() |
24 : range_32_(0, 0), is_64_bit_(false), range_ok_(true) { | 23 : range_32_(0, 0), is_64_bit_(false), range_ok_(true) { |
25 } | 24 } |
26 | 25 |
27 CheckedMachAddressRange::CheckedMachAddressRange( | 26 CheckedMachAddressRange::CheckedMachAddressRange( |
28 const ProcessReader* process_reader, | 27 bool is_64_bit, |
29 mach_vm_address_t base, | 28 mach_vm_address_t base, |
30 mach_vm_size_t size) { | 29 mach_vm_size_t size) { |
31 SetRange(process_reader, base, size); | 30 SetRange(is_64_bit, base, size); |
32 } | 31 } |
33 | 32 |
34 void CheckedMachAddressRange::SetRange(const ProcessReader* process_reader, | 33 void CheckedMachAddressRange::SetRange(bool is_64_bit, |
35 mach_vm_address_t base, | 34 mach_vm_address_t base, |
36 mach_vm_size_t size) { | 35 mach_vm_size_t size) { |
37 is_64_bit_ = process_reader->Is64Bit(); | 36 is_64_bit_ = is_64_bit; |
38 if (is_64_bit_) { | 37 if (is_64_bit_) { |
39 range_64_.SetRange(base, size); | 38 range_64_.SetRange(base, size); |
40 range_ok_ = true; | 39 range_ok_ = true; |
41 } else { | 40 } else { |
42 range_32_.SetRange(base, size); | 41 range_32_.SetRange(base, size); |
43 range_ok_ = base::IsValueInRangeForNumericType<uint32_t>(base) && | 42 range_ok_ = base::IsValueInRangeForNumericType<uint32_t>(base) && |
44 base::IsValueInRangeForNumericType<uint32_t>(size); | 43 base::IsValueInRangeForNumericType<uint32_t>(size); |
45 } | 44 } |
46 } | 45 } |
47 | 46 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 const CheckedMachAddressRange& that) const { | 78 const CheckedMachAddressRange& that) const { |
80 DCHECK_EQ(is_64_bit_, that.is_64_bit_); | 79 DCHECK_EQ(is_64_bit_, that.is_64_bit_); |
81 DCHECK(range_ok_); | 80 DCHECK(range_ok_); |
82 DCHECK(that.range_ok_); | 81 DCHECK(that.range_ok_); |
83 | 82 |
84 return is_64_bit_ ? range_64_.ContainsRange(that.range_64_) | 83 return is_64_bit_ ? range_64_.ContainsRange(that.range_64_) |
85 : range_32_.ContainsRange(that.range_32_); | 84 : range_32_.ContainsRange(that.range_32_); |
86 } | 85 } |
87 | 86 |
88 } // namespace crashpad | 87 } // namespace crashpad |
OLD | NEW |