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