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 #ifndef CRASHPAD_UTIL_NUMERIC_CHECKED_ADDRESS_RANGE_H_ | 15 #ifndef CRASHPAD_UTIL_NUMERIC_CHECKED_ADDRESS_RANGE_H_ |
16 #define CRASHPAD_UTIL_NUMERIC_CHECKED_ADDRESS_RANGE_H_ | 16 #define CRASHPAD_UTIL_NUMERIC_CHECKED_ADDRESS_RANGE_H_ |
17 | 17 |
18 #include <stdint.h> | 18 #include <stdint.h> |
19 | 19 |
| 20 #include <string> |
| 21 |
20 #include "build/build_config.h" | 22 #include "build/build_config.h" |
21 #include "util/numeric/checked_range.h" | 23 #include "util/numeric/checked_range.h" |
22 | 24 |
23 namespace crashpad { | 25 namespace crashpad { |
24 namespace internal { | 26 namespace internal { |
25 | 27 |
26 //! \brief Ensures that a range, composed of a base and a size, does not | 28 //! \brief Ensures that a range, composed of a base and a size, does not |
27 //! overflow the pointer type of the process it describes a range in. | 29 //! overflow the pointer type of the process it describes a range in. |
28 //! | 30 //! |
29 //! This class checks bases of type `ValueType` and sizes of type `SizeType` | 31 //! This class checks bases of type `ValueType` and sizes of type `SizeType` |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 //! base, and the contained address range’s end is less than or equal to the | 103 //! base, and the contained address range’s end is less than or equal to the |
102 //! containing address range’s end. | 104 //! containing address range’s end. |
103 //! | 105 //! |
104 //! This method should only be called on two CheckedAddressRangeGeneric | 106 //! This method should only be called on two CheckedAddressRangeGeneric |
105 //! objects representing address ranges in the same process. | 107 //! objects representing address ranges in the same process. |
106 //! | 108 //! |
107 //! This method must only be called if IsValid() would return `true` for both | 109 //! This method must only be called if IsValid() would return `true` for both |
108 //! CheckedAddressRangeGeneric objects involved. | 110 //! CheckedAddressRangeGeneric objects involved. |
109 bool ContainsRange(const CheckedAddressRangeGeneric& that) const; | 111 bool ContainsRange(const CheckedAddressRangeGeneric& that) const; |
110 | 112 |
| 113 //! \brief Returns a string describing the address range. |
| 114 //! |
| 115 //! The string will be formatted as `"0x123 + 0x45 (64)"`, where the |
| 116 //! individual components are the address, size, and bitness. |
| 117 std::string AsString() const; |
| 118 |
111 private: | 119 private: |
112 #if defined(COMPILER_MSVC) | 120 #if defined(COMPILER_MSVC) |
113 // MSVC cannot handle a union containing CheckedRange (with constructor, etc.) | 121 // MSVC cannot handle a union containing CheckedRange (with constructor, etc.) |
114 // currently. | 122 // currently. |
115 CheckedRange<uint32_t> range_32_; | 123 CheckedRange<uint32_t> range_32_; |
116 CheckedRange<uint64_t> range_64_; | 124 CheckedRange<uint64_t> range_64_; |
117 #else | 125 #else |
118 // The field of the union that is expressed is determined by is_64_bit_. | 126 // The field of the union that is expressed is determined by is_64_bit_. |
119 union { | 127 union { |
120 CheckedRange<uint32_t> range_32_; | 128 CheckedRange<uint32_t> range_32_; |
(...skipping 14 matching lines...) Expand all Loading... |
135 // types in 32-bit processes. | 143 // types in 32-bit processes. |
136 bool range_ok_; | 144 bool range_ok_; |
137 | 145 |
138 DISALLOW_COPY_AND_ASSIGN(CheckedAddressRangeGeneric); | 146 DISALLOW_COPY_AND_ASSIGN(CheckedAddressRangeGeneric); |
139 }; | 147 }; |
140 | 148 |
141 } // namespace internal | 149 } // namespace internal |
142 } // namespace crashpad | 150 } // namespace crashpad |
143 | 151 |
144 #endif // CRASHPAD_UTIL_NUMERIC_CHECKED_ADDRESS_RANGE_H_ | 152 #endif // CRASHPAD_UTIL_NUMERIC_CHECKED_ADDRESS_RANGE_H_ |
OLD | NEW |