memprof_interface.h 2.6 KB

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