1 //===-- memprof_interceptors.h ---------------------------------*- C++ -*-===//
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-exception
7 //===----------------------------------------------------------------------===//
9 // This file is a part of MemProfiler, a memory profiler.
11 // MemProf-private header for memprof_interceptors.cpp
12 //===----------------------------------------------------------------------===//
13 #ifndef MEMPROF_INTERCEPTORS_H
14 #define MEMPROF_INTERCEPTORS_H
16 #include "interception/interception.h"
17 #include "memprof_interceptors_memintrinsics.h"
18 #include "memprof_internal.h"
19 #include "sanitizer_common/sanitizer_platform_interceptors.h"
23 void InitializeMemprofInterceptors();
24 void InitializePlatformInterceptors();
26 #define ENSURE_MEMPROF_INITED() \
28 CHECK(!memprof_init_is_running); \
29 if (UNLIKELY(!memprof_inited)) { \
30 MemprofInitFromRtl(); \
34 } // namespace __memprof
36 DECLARE_REAL(int, memcmp
, const void *a1
, const void *a2
, uptr size
)
37 DECLARE_REAL(char *, strchr
, const char *str
, int c
)
38 DECLARE_REAL(SIZE_T
, strlen
, const char *s
)
39 DECLARE_REAL(char *, strncpy
, char *to
, const char *from
, uptr size
)
40 DECLARE_REAL(uptr
, strnlen
, const char *s
, uptr maxlen
)
41 DECLARE_REAL(char *, strstr
, const char *s1
, const char *s2
)
43 #define MEMPROF_INTERCEPT_FUNC(name) \
45 if (!INTERCEPT_FUNCTION(name)) \
46 VReport(1, "MemProfiler: failed to intercept '%s'\n'", #name); \
48 #define MEMPROF_INTERCEPT_FUNC_VER(name, ver) \
50 if (!INTERCEPT_FUNCTION_VER(name, ver)) \
51 VReport(1, "MemProfiler: failed to intercept '%s@@%s'\n", #name, ver); \
53 #define MEMPROF_INTERCEPT_FUNC_VER_UNVERSIONED_FALLBACK(name, ver) \
55 if (!INTERCEPT_FUNCTION_VER(name, ver) && !INTERCEPT_FUNCTION(name)) \
56 VReport(1, "MemProfiler: failed to intercept '%s@@%s' or '%s'\n", #name, \
60 #define MEMPROF_INTERCEPTOR_ENTER(ctx, func) \
64 #define COMMON_INTERCEPT_FUNCTION(name) MEMPROF_INTERCEPT_FUNC(name)
66 #endif // MEMPROF_INTERCEPTORS_H