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