Path: blob/main/contrib/llvm-project/compiler-rt/lib/lsan/lsan_malloc_mac.cpp
35233 views
//===-- lsan_malloc_mac.cpp -----------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file is a part of LeakSanitizer (LSan), a memory leak detector.9//10// Mac-specific malloc interception.11//===----------------------------------------------------------------------===//1213#include "sanitizer_common/sanitizer_platform.h"14#if SANITIZER_APPLE1516#include "lsan.h"17#include "lsan_allocator.h"18#include "lsan_thread.h"1920using namespace __lsan;21#define COMMON_MALLOC_ZONE_NAME "lsan"22#define COMMON_MALLOC_ENTER() ENSURE_LSAN_INITED23#define COMMON_MALLOC_SANITIZER_INITIALIZED lsan_inited24#define COMMON_MALLOC_FORCE_LOCK()25#define COMMON_MALLOC_FORCE_UNLOCK()26#define COMMON_MALLOC_MEMALIGN(alignment, size) \27GET_STACK_TRACE_MALLOC; \28void *p = lsan_memalign(alignment, size, stack)29#define COMMON_MALLOC_MALLOC(size) \30GET_STACK_TRACE_MALLOC; \31void *p = lsan_malloc(size, stack)32#define COMMON_MALLOC_REALLOC(ptr, size) \33GET_STACK_TRACE_MALLOC; \34void *p = lsan_realloc(ptr, size, stack)35#define COMMON_MALLOC_CALLOC(count, size) \36GET_STACK_TRACE_MALLOC; \37void *p = lsan_calloc(count, size, stack)38#define COMMON_MALLOC_POSIX_MEMALIGN(memptr, alignment, size) \39GET_STACK_TRACE_MALLOC; \40int res = lsan_posix_memalign(memptr, alignment, size, stack)41#define COMMON_MALLOC_VALLOC(size) \42GET_STACK_TRACE_MALLOC; \43void *p = lsan_valloc(size, stack)44#define COMMON_MALLOC_FREE(ptr) \45lsan_free(ptr)46#define COMMON_MALLOC_SIZE(ptr) \47uptr size = lsan_mz_size(ptr)48#define COMMON_MALLOC_FILL_STATS(zone, stats)49#define COMMON_MALLOC_REPORT_UNKNOWN_REALLOC(ptr, zone_ptr, zone_name) \50(void)zone_name; \51Report("mz_realloc(%p) -- attempting to realloc unallocated memory.\n", ptr);52#define COMMON_MALLOC_NAMESPACE __lsan53#define COMMON_MALLOC_HAS_ZONE_ENUMERATOR 054#define COMMON_MALLOC_HAS_EXTRA_INTROSPECTION_INIT 05556#include "sanitizer_common/sanitizer_malloc_mac.inc"5758#endif // SANITIZER_APPLE596061