xref: /aosp_15_r20/prebuilts/clang-tools/linux-x86/clang-headers/sanitizer/memprof_interface.h (revision bed243d3d9cd544cfb038bfa7be843dedc6e6bf7)
1*bed243d3SAndroid Build Coastguard Worker //===-- sanitizer/memprof_interface.h --------------------------*- C++ -*-===//
2*bed243d3SAndroid Build Coastguard Worker //
3*bed243d3SAndroid Build Coastguard Worker // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*bed243d3SAndroid Build Coastguard Worker // See https://llvm.org/LICENSE.txt for license information.
5*bed243d3SAndroid Build Coastguard Worker // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*bed243d3SAndroid Build Coastguard Worker //
7*bed243d3SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
8*bed243d3SAndroid Build Coastguard Worker //
9*bed243d3SAndroid Build Coastguard Worker // This file is a part of MemProfiler (MemProf).
10*bed243d3SAndroid Build Coastguard Worker //
11*bed243d3SAndroid Build Coastguard Worker // Public interface header.
12*bed243d3SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
13*bed243d3SAndroid Build Coastguard Worker #ifndef SANITIZER_MEMPROF_INTERFACE_H
14*bed243d3SAndroid Build Coastguard Worker #define SANITIZER_MEMPROF_INTERFACE_H
15*bed243d3SAndroid Build Coastguard Worker 
16*bed243d3SAndroid Build Coastguard Worker #include <sanitizer/common_interface_defs.h>
17*bed243d3SAndroid Build Coastguard Worker 
18*bed243d3SAndroid Build Coastguard Worker #ifdef __cplusplus
19*bed243d3SAndroid Build Coastguard Worker extern "C" {
20*bed243d3SAndroid Build Coastguard Worker #endif
21*bed243d3SAndroid Build Coastguard Worker /// Records access to a memory region (<c>[addr, addr+size)</c>).
22*bed243d3SAndroid Build Coastguard Worker ///
23*bed243d3SAndroid Build Coastguard Worker /// This memory must be previously allocated by your program.
24*bed243d3SAndroid Build Coastguard Worker ///
25*bed243d3SAndroid Build Coastguard Worker /// \param addr Start of memory region.
26*bed243d3SAndroid Build Coastguard Worker /// \param size Size of memory region.
27*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __memprof_record_access_range(void const volatile *addr,
28*bed243d3SAndroid Build Coastguard Worker                                                    size_t size);
29*bed243d3SAndroid Build Coastguard Worker 
30*bed243d3SAndroid Build Coastguard Worker /// Records access to a memory address <c><i>addr</i></c>.
31*bed243d3SAndroid Build Coastguard Worker ///
32*bed243d3SAndroid Build Coastguard Worker /// This memory must be previously allocated by your program.
33*bed243d3SAndroid Build Coastguard Worker ///
34*bed243d3SAndroid Build Coastguard Worker /// \param addr Accessed memory address
35*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __memprof_record_access(void const volatile *addr);
36*bed243d3SAndroid Build Coastguard Worker 
37*bed243d3SAndroid Build Coastguard Worker /// User-provided callback on MemProf errors.
38*bed243d3SAndroid Build Coastguard Worker ///
39*bed243d3SAndroid Build Coastguard Worker /// You can provide a function that would be called immediately when MemProf
40*bed243d3SAndroid Build Coastguard Worker /// detects an error. This is useful in cases when MemProf detects an error but
41*bed243d3SAndroid Build Coastguard Worker /// your program crashes before the MemProf report is printed.
42*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __memprof_on_error(void);
43*bed243d3SAndroid Build Coastguard Worker 
44*bed243d3SAndroid Build Coastguard Worker /// Prints accumulated statistics to <c>stderr</c> (useful for calling from the
45*bed243d3SAndroid Build Coastguard Worker /// debugger).
46*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __memprof_print_accumulated_stats(void);
47*bed243d3SAndroid Build Coastguard Worker 
48*bed243d3SAndroid Build Coastguard Worker /// User-provided default option settings.
49*bed243d3SAndroid Build Coastguard Worker ///
50*bed243d3SAndroid Build Coastguard Worker /// You can provide your own implementation of this function to return a string
51*bed243d3SAndroid Build Coastguard Worker /// containing MemProf runtime options (for example,
52*bed243d3SAndroid Build Coastguard Worker /// <c>verbosity=1:print_stats=1</c>).
53*bed243d3SAndroid Build Coastguard Worker ///
54*bed243d3SAndroid Build Coastguard Worker /// \returns Default options string.
55*bed243d3SAndroid Build Coastguard Worker const char *SANITIZER_CDECL __memprof_default_options(void);
56*bed243d3SAndroid Build Coastguard Worker 
57*bed243d3SAndroid Build Coastguard Worker /// Prints the memory profile to the current profile file.
58*bed243d3SAndroid Build Coastguard Worker ///
59*bed243d3SAndroid Build Coastguard Worker /// \returns 0 on success.
60*bed243d3SAndroid Build Coastguard Worker int SANITIZER_CDECL __memprof_profile_dump(void);
61*bed243d3SAndroid Build Coastguard Worker 
62*bed243d3SAndroid Build Coastguard Worker /// Closes the existing file descriptor, if it is valid and not stdout or
63*bed243d3SAndroid Build Coastguard Worker /// stderr, and resets the internal state such that the profile filename is
64*bed243d3SAndroid Build Coastguard Worker /// reopened on the next profile dump attempt. This can be used to enable
65*bed243d3SAndroid Build Coastguard Worker /// multiple rounds of profiling on the same binary.
66*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __memprof_profile_reset(void);
67*bed243d3SAndroid Build Coastguard Worker 
68*bed243d3SAndroid Build Coastguard Worker #ifdef __cplusplus
69*bed243d3SAndroid Build Coastguard Worker } // extern "C"
70*bed243d3SAndroid Build Coastguard Worker #endif
71*bed243d3SAndroid Build Coastguard Worker 
72*bed243d3SAndroid Build Coastguard Worker #endif // SANITIZER_MEMPROF_INTERFACE_H
73