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