brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · 53d6857 Raw
67 lines · c
1//===-- memprof_interceptors.h ---------------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// This file is a part of MemProfiler, a memory profiler.10//11// MemProf-private header for memprof_interceptors.cpp12//===----------------------------------------------------------------------===//13#ifndef MEMPROF_INTERCEPTORS_H14#define MEMPROF_INTERCEPTORS_H15 16#include "interception/interception.h"17#include "memprof_interceptors_memintrinsics.h"18#include "memprof_internal.h"19#include "sanitizer_common/sanitizer_platform_interceptors.h"20 21namespace __memprof {22 23void InitializeMemprofInterceptors();24void InitializePlatformInterceptors();25 26#define ENSURE_MEMPROF_INITED()                                                \27  do {                                                                         \28    CHECK(!memprof_init_is_running);                                           \29    if (UNLIKELY(!memprof_inited)) {                                           \30      MemprofInitFromRtl();                                                    \31    }                                                                          \32  } while (0)33 34} // namespace __memprof35 36DECLARE_REAL(int, memcmp, const void *a1, const void *a2, SIZE_T size)37DECLARE_REAL(char *, strchr, const char *str, int c)38DECLARE_REAL(SIZE_T, strlen, const char *s)39DECLARE_REAL(char *, strncpy, char *to, const char *from, SIZE_T size)40DECLARE_REAL(SIZE_T, strnlen, const char *s, SIZE_T maxlen)41DECLARE_REAL(char *, strstr, const char *s1, const char *s2)42 43#define MEMPROF_INTERCEPT_FUNC(name)                                           \44  do {                                                                         \45    if (!INTERCEPT_FUNCTION(name))                                             \46      VReport(1, "MemProfiler: failed to intercept '%s'\n'", #name);           \47  } while (0)48#define MEMPROF_INTERCEPT_FUNC_VER(name, ver)                                  \49  do {                                                                         \50    if (!INTERCEPT_FUNCTION_VER(name, ver))                                    \51      VReport(1, "MemProfiler: failed to intercept '%s@@%s'\n", #name, ver);   \52  } while (0)53#define MEMPROF_INTERCEPT_FUNC_VER_UNVERSIONED_FALLBACK(name, ver)             \54  do {                                                                         \55    if (!INTERCEPT_FUNCTION_VER(name, ver) && !INTERCEPT_FUNCTION(name))       \56      VReport(1, "MemProfiler: failed to intercept '%s@@%s' or '%s'\n", #name, \57              ver, #name);                                                     \58  } while (0)59 60#define MEMPROF_INTERCEPTOR_ENTER(ctx, func)                                   \61  ctx = 0;                                                                     \62  (void)ctx;63 64#define COMMON_INTERCEPT_FUNCTION(name) MEMPROF_INTERCEPT_FUNC(name)65 66#endif // MEMPROF_INTERCEPTORS_H67