| Index: base/allocator/allocator_extension.h
|
| diff --git a/base/allocator/allocator_extension.h b/base/allocator/allocator_extension.h
|
| index 64bfd1cc4acaa3fe2a8fc1e8f80ab1fe674f3856..e234f1cf22c87c31e5f1347ecba07efd48639e74 100644
|
| --- a/base/allocator/allocator_extension.h
|
| +++ b/base/allocator/allocator_extension.h
|
| @@ -7,12 +7,18 @@
|
|
|
| #include <stddef.h> // for size_t
|
|
|
| +#include <type_traits> // for std::add_pointer
|
| +
|
| #include "base/base_export.h"
|
| #include "build/build_config.h"
|
|
|
| namespace base {
|
| namespace allocator {
|
|
|
| +// Callback types for alloc and free.
|
| +using AllocHookFunc = std::add_pointer<void(const void*, size_t)>::type;
|
| +using FreeHookFunc = std::add_pointer<void(const void*)>::type;
|
| +
|
| // Request that the allocator release any free memory it knows about to the
|
| // system.
|
| BASE_EXPORT void ReleaseFreeMemory();
|
| @@ -25,6 +31,32 @@ BASE_EXPORT bool GetNumericProperty(const char* name, size_t* value);
|
|
|
| BASE_EXPORT bool IsHeapProfilerRunning();
|
|
|
| +// Register callbacks for alloc and free. Can only store one callback at a time
|
| +// for each of alloc and free. Returns the previously stored hook function, or
|
| +// nullptr if none was stored.
|
| +BASE_EXPORT AllocHookFunc SetSingleAllocHook(AllocHookFunc func);
|
| +BASE_EXPORT FreeHookFunc SetSingleFreeHook(FreeHookFunc func);
|
| +
|
| +// Returns the currently stored alloc/free callbacks that were registered by
|
| +// calling SetSingle{Alloc,Free}Hook().
|
| +BASE_EXPORT AllocHookFunc GetSingleAllocHook();
|
| +BASE_EXPORT FreeHookFunc GetSingleFreeHook();
|
| +
|
| +// Attempts to unwind the call stack from the current location where this
|
| +// function is being called from. Must be called from a hook function registered
|
| +// by calling SetSingle{Alloc,Free}Hook, directly or indirectly.
|
| +//
|
| +// Arguments:
|
| +// stack: pointer to a pre-allocated array of void*'s.
|
| +// max_stack_size: indicates the size of the array in |stack|.
|
| +// skip_count: Indicates how many initial call stack levels to skip before
|
| +// storing the caller of alloc/free. This value might not be
|
| +// used, depending on the specific implementation.
|
| +//
|
| +// Returns the number of call stack frames stored in |stack|, or 0 if no call
|
| +// stack information is available.
|
| +BASE_EXPORT int GetCallStack(void** stack, int max_stack_size, int skip_count);
|
| +
|
| } // namespace allocator
|
| } // namespace base
|
|
|
|
|