memprof_internal.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //===-- memprof_internal.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, a memory profiler.
  10. //
  11. // MemProf-private header which defines various general utilities.
  12. //===----------------------------------------------------------------------===//
  13. #ifndef MEMPROF_INTERNAL_H
  14. #define MEMPROF_INTERNAL_H
  15. #include "memprof_flags.h"
  16. #include "memprof_interface_internal.h"
  17. #include "sanitizer_common/sanitizer_common.h"
  18. #include "sanitizer_common/sanitizer_internal_defs.h"
  19. #include "sanitizer_common/sanitizer_libc.h"
  20. #include "sanitizer_common/sanitizer_stacktrace.h"
  21. #if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
  22. #error "The MemProfiler run-time should not be instrumented by MemProfiler"
  23. #endif
  24. // Build-time configuration options.
  25. // If set, memprof will intercept C++ exception api call(s).
  26. #ifndef MEMPROF_HAS_EXCEPTIONS
  27. #define MEMPROF_HAS_EXCEPTIONS 1
  28. #endif
  29. #ifndef MEMPROF_DYNAMIC
  30. #ifdef PIC
  31. #define MEMPROF_DYNAMIC 1
  32. #else
  33. #define MEMPROF_DYNAMIC 0
  34. #endif
  35. #endif
  36. // All internal functions in memprof reside inside the __memprof namespace
  37. // to avoid namespace collisions with the user programs.
  38. // Separate namespace also makes it simpler to distinguish the memprof
  39. // run-time functions from the instrumented user code in a profile.
  40. namespace __memprof {
  41. class MemprofThread;
  42. using __sanitizer::StackTrace;
  43. void MemprofInitFromRtl();
  44. // memprof_rtl.cpp
  45. void PrintAddressSpaceLayout();
  46. // memprof_shadow_setup.cpp
  47. void InitializeShadowMemory();
  48. // memprof_malloc_linux.cpp
  49. void ReplaceSystemMalloc();
  50. // memprof_linux.cpp
  51. uptr FindDynamicShadowStart();
  52. void *MemprofDoesNotSupportStaticLinkage();
  53. // memprof_thread.cpp
  54. MemprofThread *CreateMainThread();
  55. // Wrapper for TLS/TSD.
  56. void TSDInit(void (*destructor)(void *tsd));
  57. void *TSDGet();
  58. void TSDSet(void *tsd);
  59. void PlatformTSDDtor(void *tsd);
  60. void *MemprofDlSymNext(const char *sym);
  61. extern int memprof_inited;
  62. extern int memprof_timestamp_inited;
  63. extern int memprof_init_done;
  64. // Used to avoid infinite recursion in __memprof_init().
  65. extern bool memprof_init_is_running;
  66. extern void (*death_callback)(void);
  67. extern long memprof_init_timestamp_s;
  68. } // namespace __memprof
  69. #endif // MEMPROF_INTERNAL_H