Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: util/mac/checked_mach_address_range.cc

Issue 666483002: Create snapshot/mac and move some files from snapshot and util to there (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad/+/master
Patch Set: Move process_reader, process_types, and mach_o_image*_reader from util/mac to snapshot/mac Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « util/mac/checked_mach_address_range.h ('k') | util/mac/checked_mach_address_range_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « util/mac/checked_mach_address_range.h ('k') | util/mac/checked_mach_address_range_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698