lsan.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //=-- lsan.h --------------------------------------------------------------===//
  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 LeakSanitizer.
  10. // Private header for standalone LSan RTL.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "lsan_thread.h"
  14. #if SANITIZER_POSIX
  15. # include "lsan_posix.h"
  16. #elif SANITIZER_FUCHSIA
  17. # include "lsan_fuchsia.h"
  18. #endif
  19. #include "sanitizer_common/sanitizer_flags.h"
  20. #include "sanitizer_common/sanitizer_stacktrace.h"
  21. #define GET_STACK_TRACE(max_size, fast) \
  22. __sanitizer::BufferedStackTrace stack; \
  23. stack.Unwind(StackTrace::GetCurrentPc(), GET_CURRENT_FRAME(), nullptr, fast, \
  24. max_size);
  25. #define GET_STACK_TRACE_FATAL \
  26. GET_STACK_TRACE(kStackTraceMax, common_flags()->fast_unwind_on_fatal)
  27. #define GET_STACK_TRACE_MALLOC \
  28. GET_STACK_TRACE(__sanitizer::common_flags()->malloc_context_size, \
  29. common_flags()->fast_unwind_on_malloc)
  30. #define GET_STACK_TRACE_THREAD GET_STACK_TRACE(kStackTraceMax, true)
  31. namespace __lsan {
  32. void InitializeInterceptors();
  33. void ReplaceSystemMalloc();
  34. void LsanOnDeadlySignal(int signo, void *siginfo, void *context);
  35. #define ENSURE_LSAN_INITED \
  36. do { \
  37. CHECK(!lsan_init_is_running); \
  38. if (!lsan_inited) \
  39. __lsan_init(); \
  40. } while (0)
  41. } // namespace __lsan
  42. extern bool lsan_inited;
  43. extern bool lsan_init_is_running;
  44. extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __lsan_init();