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 __memprof_record_access_range(void const volatile *addr, size_t size); 28 29 /// Records access to a memory address <c><i>addr</i></c>. 30 /// 31 /// This memory must be previously allocated by your program. 32 /// 33 /// \param addr Accessed memory address 34 void __memprof_record_access(void const volatile *addr); 35 36 /// User-provided callback on MemProf errors. 37 /// 38 /// You can provide a function that would be called immediately when MemProf 39 /// detects an error. This is useful in cases when MemProf detects an error but 40 /// your program crashes before the MemProf report is printed. 41 void __memprof_on_error(void); 42 43 /// Prints accumulated statistics to <c>stderr</c> (useful for calling from the 44 /// debugger). 45 void __memprof_print_accumulated_stats(void); 46 47 /// User-provided default option settings. 48 /// 49 /// You can provide your own implementation of this function to return a string 50 /// containing MemProf runtime options (for example, 51 /// <c>verbosity=1:print_stats=1</c>). 52 /// 53 /// \returns Default options string. 54 const char *__memprof_default_options(void); 55 56 /// Prints the memory profile to the current profile file. 57 /// 58 /// \returns 0 on success. 59 int __memprof_profile_dump(void); 60 61 #ifdef __cplusplus 62 } // extern "C" 63 #endif 64 65 #endif // SANITIZER_MEMPROF_INTERFACE_H 66