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

Unified Diff: util/mac/checked_mach_address_range.h

Issue 1052813002: win: make CrashpadInfo retrievable (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: more fixes Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « snapshot/win/process_snapshot_win.cc ('k') | util/mac/checked_mach_address_range.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/mac/checked_mach_address_range.h
diff --git a/util/mac/checked_mach_address_range.h b/util/mac/checked_mach_address_range.h
index 717bb8d915c52378debab671b114f394026a1cee..e64e3d1ec7789ae2d4165b3731824406b907b529 100644
--- a/util/mac/checked_mach_address_range.h
+++ b/util/mac/checked_mach_address_range.h
@@ -17,7 +17,7 @@
#include <mach/mach.h>
-#include "util/numeric/checked_range.h"
+#include "util/numeric/checked_address_range.h"
namespace crashpad {
@@ -30,101 +30,8 @@ namespace crashpad {
//!
//! Aside from varying the overall range on the basis of a process’ pointer type
//! width, this class functions very similarly to CheckedRange.
-class CheckedMachAddressRange {
- public:
- //! \brief Initializes a default range.
- //!
- //! The default range has base 0, size 0, and appears to be from a 32-bit
- //! process.
- CheckedMachAddressRange();
-
- //! \brief Initializes a range.
- //!
- //! See SetRange().
- CheckedMachAddressRange(bool is_64_bit,
- mach_vm_address_t base,
- mach_vm_size_t size);
-
- //! \brief Sets a range’s fields.
- //!
- //! \param[in] is_64_bit `true` if \a base and \a size refer to addresses in a
- //! 64-bit process; `false` if they refer to addresses in a 32-bit
- //! process.
- //! \param[in] base The range’s base address.
- //! \param[in] size The range’s size.
- void SetRange(bool is_64_bit, mach_vm_address_t base, mach_vm_size_t size);
-
- //! \brief The range’s base address.
- mach_vm_address_t Base() const;
-
- //! \brief The range’s size.
- mach_vm_size_t Size() const;
-
- //! \brief The range’s end address (its base address plus its size).
- mach_vm_address_t End() const;
-
- //! \brief Returns the validity of the address range.
- //!
- //! \return `true` if the address range is valid, `false` otherwise.
- //!
- //! An address range is valid if its size can be converted to the address
- //! range’s data type without data loss, and if its end (base plus size) can
- //! be computed without overflowing its data type.
- bool IsValid() const;
-
- //! \brief Returns whether the address range contains another address.
- //!
- //! \param[in] value The (possibly) contained address.
- //!
- //! \return `true` if the address range contains \a value, `false` otherwise.
- //!
- //! An address range contains a value if the value is greater than or equal to
- //! its base address, and less than its end address (base address plus size).
- //!
- //! This method must only be called if IsValid() would return `true`.
- bool ContainsValue(const mach_vm_address_t value) const;
-
- //! \brief Returns whether the address range contains another address range.
- //!
- //! \param[in] that The (possibly) contained address range.
- //!
- //! \return `true` if `this` address range, the containing address range,
- //! contains \a that, the contained address range. `false` otherwise.
- //!
- //! An address range contains another address range when the contained address
- //! range’s base is greater than or equal to the containing address range’s
- //! base, and the contained address range’s end is less than or equal to the
- //! containing address range’s end.
- //!
- //! This method should only be called on two CheckedMachAddressRange objects
- //! representing address ranges in the same process.
- //!
- //! This method must only be called if IsValid() would return `true` for both
- //! CheckedMachAddressRange objects involved.
- bool ContainsRange(const CheckedMachAddressRange& that) const;
-
- private:
- // The field of the union that is expressed is determined by is_64_bit_.
- union {
- CheckedRange<uint32_t> range_32_;
- CheckedRange<uint64_t> range_64_;
- };
-
- // Determines which field of the union is expressed.
- bool is_64_bit_;
-
- // Whether the base and size were valid for their data type when set. This is
- // always true when is_64_bit_ is true because the underlying data types are
- // 64 bits wide and there is no possibility for range and size to overflow.
- // When is_64_bit_ is false, range_ok_ will be false if SetRange() was passed
- // a base or size that overflowed the underlying 32-bit data type. This field
- // is necessary because the interface exposes mach_vm_address_t and
- // mach_vm_size_t uniformly, but these types are too wide for the underlying
- // pointer and size types in 32-bit processes.
- bool range_ok_;
-
- DISALLOW_COPY_AND_ASSIGN(CheckedMachAddressRange);
-};
+using CheckedMachAddressRange =
+ internal::CheckedAddressRangeGeneric<mach_vm_address_t, mach_vm_size_t>;
} // namespace crashpad
« no previous file with comments | « snapshot/win/process_snapshot_win.cc ('k') | util/mac/checked_mach_address_range.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698