* gcc-interface/trans.c (Subprogram_Body_to_gnu): Initialize locus.
[official-gcc.git] / libsanitizer / lsan / lsan.h
blob42d4214ed0fda15607b4e417ab03de10e427da86
1 //=-- lsan.h --------------------------------------------------------------===//
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 // Private header for standalone LSan RTL.
11 //===----------------------------------------------------------------------===//
13 #include "lsan_thread.h"
14 #include "sanitizer_common/sanitizer_flags.h"
15 #include "sanitizer_common/sanitizer_stacktrace.h"
17 #define GET_STACK_TRACE(max_size, fast) \
18 __sanitizer::BufferedStackTrace stack; \
19 GetStackTraceWithPcBpAndContext(&stack, max_size, \
20 StackTrace::GetCurrentPc(), \
21 GET_CURRENT_FRAME(), nullptr, fast);
23 #define GET_STACK_TRACE_FATAL \
24 GET_STACK_TRACE(kStackTraceMax, common_flags()->fast_unwind_on_fatal)
26 #define GET_STACK_TRACE_MALLOC \
27 GET_STACK_TRACE(__sanitizer::common_flags()->malloc_context_size, \
28 common_flags()->fast_unwind_on_malloc)
30 #define GET_STACK_TRACE_THREAD GET_STACK_TRACE(kStackTraceMax, true)
32 namespace __lsan {
34 void InitializeInterceptors();
35 void ReplaceSystemMalloc();
37 #define ENSURE_LSAN_INITED do { \
38 CHECK(!lsan_init_is_running); \
39 if (!lsan_inited) \
40 __lsan_init(); \
41 } while (0)
43 // Get the stack trace with the given pc and bp.
44 // The pc will be in the position 0 of the resulting stack trace.
45 // The bp may refer to the current frame or to the caller's frame.
46 ALWAYS_INLINE
47 void GetStackTraceWithPcBpAndContext(__sanitizer::BufferedStackTrace *stack,
48 __sanitizer::uptr max_depth,
49 __sanitizer::uptr pc, __sanitizer::uptr bp,
50 void *context, bool fast) {
51 uptr stack_top = 0, stack_bottom = 0;
52 ThreadContext *t;
53 if (fast && (t = CurrentThreadContext())) {
54 stack_top = t->stack_end();
55 stack_bottom = t->stack_begin();
57 if (!SANITIZER_MIPS || IsValidFrame(bp, stack_top, stack_bottom)) {
58 stack->Unwind(max_depth, pc, bp, context, stack_top, stack_bottom, fast);
62 } // namespace __lsan
64 extern bool lsan_inited;
65 extern bool lsan_init_is_running;
67 extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __lsan_init();