73 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8//9// This file is a part of MemProfiler (MemProf).10//11// Public interface header.12//===----------------------------------------------------------------------===//13#ifndef SANITIZER_MEMPROF_INTERFACE_H14#define SANITIZER_MEMPROF_INTERFACE_H15 16#include <sanitizer/common_interface_defs.h>17 18#ifdef __cplusplus19extern "C" {20#endif21/// 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.27void 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 address35void 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 MemProf40/// detects an error. This is useful in cases when MemProf detects an error but41/// your program crashes before the MemProf report is printed.42void SANITIZER_CDECL __memprof_on_error(void);43 44/// Prints accumulated statistics to <c>stderr</c> (useful for calling from the45/// debugger).46void SANITIZER_CDECL __memprof_print_accumulated_stats(void);47 48/// User-provided default option settings.49///50/// You can set these options via the -memprof-runtime-default-options LLVM flag51/// or you can provide your own implementation of this function. See52/// memprof_flags.h for more info.53///54/// \returns Default options string.55const char *SANITIZER_CDECL __memprof_default_options(void);56 57/// Prints the memory profile to the current profile file.58///59/// \returns 0 on success.60int SANITIZER_CDECL __memprof_profile_dump(void);61 62/// Closes the existing file descriptor, if it is valid and not stdout or63/// stderr, and resets the internal state such that the profile filename is64/// reopened on the next profile dump attempt. This can be used to enable65/// multiple rounds of profiling on the same binary.66void SANITIZER_CDECL __memprof_profile_reset(void);67 68#ifdef __cplusplus69} // extern "C"70#endif71 72#endif // SANITIZER_MEMPROF_INTERFACE_H73