#include <sys/mman.h>
#include <unistd.h>
#include <memory>
#include <string>
|
| bool | ExcludeFromCoreDump (void *address, size_t size) |
| | Mark the memory address range provided to be excluded from core dumps, if this is supported by the platform. The range must be page-aligned.
|
| |
| template<typename T > |
| UniqueAlignedDataPtr< T > | MakeUniqueAlignedDataPtr (size_t size, bool exclude_from_core_dump=true) |
| | Create a UniqueAlignedDataPtr and optionally mark its data to be excluded from core dumps.
|
| |
◆ UniqueAlignedDataPtr
Alias for a std::unique_ptr that manages a page-aligned dynamic array and has a custom deleter.
- Template Parameters
-
| T | The type of the data in the array managed by the pointer. |
◆ ExcludeFromCoreDump()
| bool ExcludeFromCoreDump |
( |
void * |
address, |
|
|
size_t |
size |
|
) |
| |
Mark the memory address range provided to be excluded from core dumps, if this is supported by the platform. The range must be page-aligned.
- Parameters
-
| address | The starting address of the memory range, which must be page-aligned. |
| size | The size of the memory range, which must be an exact multiple of the page size. |
- Returns
- Whether the address range was successfully marked.
Mark the memory address range provided to be excluded from core dumps, using the madvise system function, if this is supported by the platform (either MADV_DONTDUMP nor MADV_NOCORE must be defined). The address range must be page-aligned.
- Note
- If the functionality is unsupported or the address range is invalid, this function prints a warning message.
◆ MakeUniqueAlignedDataPtr()
template<typename T >
| UniqueAlignedDataPtr< T > MakeUniqueAlignedDataPtr |
( |
size_t |
size, |
|
|
bool |
exclude_from_core_dump = true |
|
) |
| |
Create a UniqueAlignedDataPtr and optionally mark its data to be excluded from core dumps.
This function allocates page-aligned memory using std::aligned_alloc. The array size is automatically converted to the raw memory size for the given data type and padded to a multiple of the page size. The custom deleter of the returned pointer automatically handles deallocation correctly when the pointer is destroyed.
- Note
- This function calls ExcludeFromCoreDump internally if exclude_from_core_dump is true, but ignores a failure result.
- Template Parameters
-
| T | The type of the data in the array managed by the pointer. |
- Parameters
-
| size | The size of the array. |
| exclude_from_core_dump | Whether the data should be excluded from core dumps. |
- Returns
- The constructed UniqueAlignedDataPtr.