Crashpad
|
Maintains a memory-mapped region created by mmap()
.
More...
#include "util/posix/scoped_mmap.h"
Public Member Functions | |
bool | Reset () |
Releases the memory-mapped region by calling munmap() . More... | |
bool | ResetAddrLen (void *addr, size_t len) |
Releases any existing memory-mapped region and sets the object to maintain an already-established mapping. More... | |
bool | ResetMmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset) |
Releases any existing memory-mapped region and establishes a new one by calling mmap() . More... | |
bool | Mprotect (int prot) |
Sets the protection of the memory-mapped region by calling mprotect() . More... | |
bool | is_valid () const |
void * | addr () const |
Returns the base address of the memory-mapped region. | |
template<typename T > | |
T | addr_as () const |
Returns the base address of the memory-mapped region, casted to a type of the caller’s choosing. | |
size_t | len () const |
Returns the size of the memory-mapped region. More... | |
Maintains a memory-mapped region created by mmap()
.
On destruction, any memory-mapped region managed by an object of this class will be released by calling munmap()
.
|
inline |
|
inline |
Returns the size of the memory-mapped region.
This is the value originally passed to ResetAddrLen() or ResetMmap(), or after Reset(), 0
. It may not be a round number of pages. Providing the passed-in value is intended to ease tracking the intended lengths of memory-mapped regions backed by files whose sizes are not whole pages.
bool crashpad::ScopedMmap::Mprotect | ( | int | prot | ) |
Sets the protection of the memory-mapped region by calling mprotect()
.
prot is passed directly to mprotect()
.
true
on success. false
on failure, with a message logged. bool crashpad::ScopedMmap::Reset | ( | ) |
Releases the memory-mapped region by calling munmap()
.
true
on success. false
on failure, with a message logged. bool crashpad::ScopedMmap::ResetAddrLen | ( | void * | addr, |
size_t | len | ||
) |
Releases any existing memory-mapped region and sets the object to maintain an already-established mapping.
If addr and len indicate a region that overlaps with the existing memory-mapped region, only the portion of the existing memory-mapped region that does not overlap the new region, if any, will be released.
[in] | addr | The base address of the existing memory-mapped region to maintain. |
[in] | len | The size of the existing memory-mapped region to maintain. |
true
on success. false
on failure, with a message logged. bool crashpad::ScopedMmap::ResetMmap | ( | void * | addr, |
size_t | len, | ||
int | prot, | ||
int | flags, | ||
int | fd, | ||
off_t | offset | ||
) |
Releases any existing memory-mapped region and establishes a new one by calling mmap()
.
The parameters to this method are passed directly to mmap()
.
true
on success. false
on failure, with a message logged. A message will also be logged on failure to release any existing memory-mapped region, but this will not preclude mmap()
from being called or a new mapping from being established, and if such a call to mmap()
is successful, this method will return true
.