lsan.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //=-- lsan.cc -------------------------------------------------------------===//
  2. //
  3. // This file is distributed under the University of Illinois Open Source
  4. // License. See LICENSE.TXT for details.
  5. //
  6. //===----------------------------------------------------------------------===//
  7. //
  8. // This file is a part of LeakSanitizer.
  9. // Standalone LSan RTL.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "lsan.h"
  13. #include "sanitizer_common/sanitizer_flags.h"
  14. #include "sanitizer_common/sanitizer_stacktrace.h"
  15. #include "lsan_allocator.h"
  16. #include "lsan_common.h"
  17. #include "lsan_thread.h"
  18. bool lsan_inited;
  19. bool lsan_init_is_running;
  20. namespace __lsan {
  21. ///// Interface to the common LSan module. /////
  22. bool WordIsPoisoned(uptr addr) {
  23. return false;
  24. }
  25. } // namespace __lsan
  26. using namespace __lsan; // NOLINT
  27. extern "C" void __lsan_init() {
  28. CHECK(!lsan_init_is_running);
  29. if (lsan_inited)
  30. return;
  31. lsan_init_is_running = true;
  32. SanitizerToolName = "LeakSanitizer";
  33. InitCommonLsan(true);
  34. InitializeAllocator();
  35. InitTlsSize();
  36. InitializeInterceptors();
  37. InitializeThreadRegistry();
  38. u32 tid = ThreadCreate(0, 0, true);
  39. CHECK_EQ(tid, 0);
  40. ThreadStart(tid, GetTid());
  41. SetCurrentThread(tid);
  42. if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit)
  43. Atexit(DoLeakCheck);
  44. lsan_inited = true;
  45. lsan_init_is_running = false;
  46. }
  47. extern "C" SANITIZER_INTERFACE_ATTRIBUTE
  48. void __sanitizer_print_stack_trace() {
  49. GET_STACK_TRACE_FATAL;
  50. stack.Print();
  51. }