1*7c3d14c8STreehugger Robot //=-- lsan.h --------------------------------------------------------------===// 2*7c3d14c8STreehugger Robot // 3*7c3d14c8STreehugger Robot // The LLVM Compiler Infrastructure 4*7c3d14c8STreehugger Robot // 5*7c3d14c8STreehugger Robot // This file is distributed under the University of Illinois Open Source 6*7c3d14c8STreehugger Robot // License. See LICENSE.TXT for details. 7*7c3d14c8STreehugger Robot // 8*7c3d14c8STreehugger Robot //===----------------------------------------------------------------------===// 9*7c3d14c8STreehugger Robot // 10*7c3d14c8STreehugger Robot // This file is a part of LeakSanitizer. 11*7c3d14c8STreehugger Robot // Private header for standalone LSan RTL. 12*7c3d14c8STreehugger Robot // 13*7c3d14c8STreehugger Robot //===----------------------------------------------------------------------===// 14*7c3d14c8STreehugger Robot 15*7c3d14c8STreehugger Robot #include "sanitizer_common/sanitizer_flags.h" 16*7c3d14c8STreehugger Robot #include "sanitizer_common/sanitizer_stacktrace.h" 17*7c3d14c8STreehugger Robot 18*7c3d14c8STreehugger Robot #define GET_STACK_TRACE(max_size, fast) \ 19*7c3d14c8STreehugger Robot BufferedStackTrace stack; \ 20*7c3d14c8STreehugger Robot { \ 21*7c3d14c8STreehugger Robot uptr stack_top = 0, stack_bottom = 0; \ 22*7c3d14c8STreehugger Robot ThreadContext *t; \ 23*7c3d14c8STreehugger Robot if (fast && (t = CurrentThreadContext())) { \ 24*7c3d14c8STreehugger Robot stack_top = t->stack_end(); \ 25*7c3d14c8STreehugger Robot stack_bottom = t->stack_begin(); \ 26*7c3d14c8STreehugger Robot } \ 27*7c3d14c8STreehugger Robot if (!SANITIZER_MIPS || \ 28*7c3d14c8STreehugger Robot IsValidFrame(GET_CURRENT_FRAME(), stack_top, stack_bottom)) { \ 29*7c3d14c8STreehugger Robot stack.Unwind(max_size, StackTrace::GetCurrentPc(), GET_CURRENT_FRAME(), \ 30*7c3d14c8STreehugger Robot /* context */ 0, stack_top, stack_bottom, fast); \ 31*7c3d14c8STreehugger Robot } \ 32*7c3d14c8STreehugger Robot } 33*7c3d14c8STreehugger Robot 34*7c3d14c8STreehugger Robot #define GET_STACK_TRACE_FATAL \ 35*7c3d14c8STreehugger Robot GET_STACK_TRACE(kStackTraceMax, common_flags()->fast_unwind_on_fatal) 36*7c3d14c8STreehugger Robot 37*7c3d14c8STreehugger Robot #define GET_STACK_TRACE_MALLOC \ 38*7c3d14c8STreehugger Robot GET_STACK_TRACE(__sanitizer::common_flags()->malloc_context_size, \ 39*7c3d14c8STreehugger Robot common_flags()->fast_unwind_on_malloc) 40*7c3d14c8STreehugger Robot 41*7c3d14c8STreehugger Robot namespace __lsan { 42*7c3d14c8STreehugger Robot 43*7c3d14c8STreehugger Robot void InitializeInterceptors(); 44*7c3d14c8STreehugger Robot 45*7c3d14c8STreehugger Robot } // namespace __lsan 46*7c3d14c8STreehugger Robot 47*7c3d14c8STreehugger Robot extern bool lsan_inited; 48*7c3d14c8STreehugger Robot extern bool lsan_init_is_running; 49*7c3d14c8STreehugger Robot 50*7c3d14c8STreehugger Robot extern "C" void __lsan_init(); 51