Path: blob/main/contrib/llvm-project/compiler-rt/lib/memprof/memprof_interceptors.h
35236 views
//===-- memprof_interceptors.h ---------------------------------*- C++ -*-===//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 MemProfiler, a memory profiler.9//10// MemProf-private header for memprof_interceptors.cpp11//===----------------------------------------------------------------------===//12#ifndef MEMPROF_INTERCEPTORS_H13#define MEMPROF_INTERCEPTORS_H1415#include "interception/interception.h"16#include "memprof_interceptors_memintrinsics.h"17#include "memprof_internal.h"18#include "sanitizer_common/sanitizer_platform_interceptors.h"1920namespace __memprof {2122void InitializeMemprofInterceptors();23void InitializePlatformInterceptors();2425#define ENSURE_MEMPROF_INITED() \26do { \27CHECK(!memprof_init_is_running); \28if (UNLIKELY(!memprof_inited)) { \29MemprofInitFromRtl(); \30} \31} while (0)3233} // namespace __memprof3435DECLARE_REAL(int, memcmp, const void *a1, const void *a2, uptr size)36DECLARE_REAL(char *, strchr, const char *str, int c)37DECLARE_REAL(SIZE_T, strlen, const char *s)38DECLARE_REAL(char *, strncpy, char *to, const char *from, uptr size)39DECLARE_REAL(uptr, strnlen, const char *s, uptr maxlen)40DECLARE_REAL(char *, strstr, const char *s1, const char *s2)4142#define MEMPROF_INTERCEPT_FUNC(name) \43do { \44if (!INTERCEPT_FUNCTION(name)) \45VReport(1, "MemProfiler: failed to intercept '%s'\n'", #name); \46} while (0)47#define MEMPROF_INTERCEPT_FUNC_VER(name, ver) \48do { \49if (!INTERCEPT_FUNCTION_VER(name, ver)) \50VReport(1, "MemProfiler: failed to intercept '%s@@%s'\n", #name, ver); \51} while (0)52#define MEMPROF_INTERCEPT_FUNC_VER_UNVERSIONED_FALLBACK(name, ver) \53do { \54if (!INTERCEPT_FUNCTION_VER(name, ver) && !INTERCEPT_FUNCTION(name)) \55VReport(1, "MemProfiler: failed to intercept '%s@@%s' or '%s'\n", #name, \56ver, #name); \57} while (0)5859#define MEMPROF_INTERCEPTOR_ENTER(ctx, func) \60ctx = 0; \61(void)ctx;6263#define COMMON_INTERCEPT_FUNCTION(name) MEMPROF_INTERCEPT_FUNC(name)6465#endif // MEMPROF_INTERCEPTORS_H666768