#include "lsan_allocator.h"
#include "sanitizer_common/sanitizer_allocator.h"
#include "sanitizer_common/sanitizer_allocator_checks.h"
#include "sanitizer_common/sanitizer_allocator_interface.h"
#include "sanitizer_common/sanitizer_allocator_report.h"
#include "sanitizer_common/sanitizer_errno.h"
#include "sanitizer_common/sanitizer_internal_defs.h"
#include "sanitizer_common/sanitizer_stackdepot.h"
#include "sanitizer_common/sanitizer_stacktrace.h"
#include "lsan_common.h"
extern "C" void *memset(void *ptr, int value, uptr num);
namespace __lsan {
#if defined(__i386__) || defined(__arm__)
static const uptr kMaxAllowedMallocSize = 1ULL << 30;
#elif defined(__mips64) || defined(__aarch64__)
static const uptr kMaxAllowedMallocSize = 4ULL << 30;
#else
static const uptr kMaxAllowedMallocSize = …;
#endif
static Allocator allocator;
static uptr max_malloc_size;
void InitializeAllocator() { … }
void AllocatorThreadStart() { … }
void AllocatorThreadFinish() { … }
static ChunkMetadata *Metadata(const void *p) { … }
static void RegisterAllocation(const StackTrace &stack, void *p, uptr size) { … }
static void RegisterDeallocation(void *p) { … }
static void *ReportAllocationSizeTooBig(uptr size, const StackTrace &stack) { … }
void *Allocate(const StackTrace &stack, uptr size, uptr alignment,
bool cleared) { … }
static void *Calloc(uptr nmemb, uptr size, const StackTrace &stack) { … }
void Deallocate(void *p) { … }
void *Reallocate(const StackTrace &stack, void *p, uptr new_size,
uptr alignment) { … }
void GetAllocatorCacheRange(uptr *begin, uptr *end) { … }
static const void *GetMallocBegin(const void *p) { … }
uptr GetMallocUsableSize(const void *p) { … }
uptr GetMallocUsableSizeFast(const void *p) { … }
int lsan_posix_memalign(void **memptr, uptr alignment, uptr size,
const StackTrace &stack) { … }
void *lsan_aligned_alloc(uptr alignment, uptr size, const StackTrace &stack) { … }
void *lsan_memalign(uptr alignment, uptr size, const StackTrace &stack) { … }
void *lsan_malloc(uptr size, const StackTrace &stack) { … }
void lsan_free(void *p) { … }
void *lsan_realloc(void *p, uptr size, const StackTrace &stack) { … }
void *lsan_reallocarray(void *ptr, uptr nmemb, uptr size,
const StackTrace &stack) { … }
void *lsan_calloc(uptr nmemb, uptr size, const StackTrace &stack) { … }
void *lsan_valloc(uptr size, const StackTrace &stack) { … }
void *lsan_pvalloc(uptr size, const StackTrace &stack) { … }
uptr lsan_mz_size(const void *p) { … }
void LockAllocator() { … }
void UnlockAllocator() { … }
void GetAllocatorGlobalRange(uptr *begin, uptr *end) { … }
uptr PointsIntoChunk(void* p) { … }
uptr GetUserBegin(uptr chunk) { … }
uptr GetUserAddr(uptr chunk) { … }
LsanMetadata::LsanMetadata(uptr chunk) { … }
bool LsanMetadata::allocated() const { … }
ChunkTag LsanMetadata::tag() const { … }
void LsanMetadata::set_tag(ChunkTag value) { … }
uptr LsanMetadata::requested_size() const { … }
u32 LsanMetadata::stack_trace_id() const { … }
void ForEachChunk(ForEachChunkCallback callback, void *arg) { … }
IgnoreObjectResult IgnoreObject(const void *p) { … }
}
usingnamespace__lsan;
extern "C" {
SANITIZER_INTERFACE_ATTRIBUTE
uptr __sanitizer_get_current_allocated_bytes() { … }
SANITIZER_INTERFACE_ATTRIBUTE
uptr __sanitizer_get_heap_size() { … }
SANITIZER_INTERFACE_ATTRIBUTE
uptr __sanitizer_get_free_bytes() { … }
SANITIZER_INTERFACE_ATTRIBUTE
uptr __sanitizer_get_unmapped_bytes() { … }
SANITIZER_INTERFACE_ATTRIBUTE
uptr __sanitizer_get_estimated_allocated_size(uptr size) { … }
SANITIZER_INTERFACE_ATTRIBUTE
int __sanitizer_get_ownership(const void *p) { … }
SANITIZER_INTERFACE_ATTRIBUTE
const void * __sanitizer_get_allocated_begin(const void *p) { … }
SANITIZER_INTERFACE_ATTRIBUTE
uptr __sanitizer_get_allocated_size(const void *p) { … }
SANITIZER_INTERFACE_ATTRIBUTE
uptr __sanitizer_get_allocated_size_fast(const void *p) { … }
SANITIZER_INTERFACE_ATTRIBUTE
void __sanitizer_purge_allocator() { … }
}