* c-parser.c (c_parser_omp_requires): Call sorry_at on requires
[official-gcc.git] / libsanitizer / lsan / lsan.h
bloba40493c88793478510ee3c1c2e9b2472e82d37d2
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 GetStackTrace(&stack, max_size, StackTrace::GetCurrentPc(), \
20 GET_CURRENT_FRAME(), nullptr, fast);
22 #define GET_STACK_TRACE_FATAL \
23 GET_STACK_TRACE(kStackTraceMax, common_flags()->fast_unwind_on_fatal)
25 #define GET_STACK_TRACE_MALLOC \
26 GET_STACK_TRACE(__sanitizer::common_flags()->malloc_context_size, \
27 common_flags()->fast_unwind_on_malloc)
29 #define GET_STACK_TRACE_THREAD GET_STACK_TRACE(kStackTraceMax, true)
31 namespace __lsan {
33 void InitializeInterceptors();
34 void ReplaceSystemMalloc();
36 #define ENSURE_LSAN_INITED do { \
37 CHECK(!lsan_init_is_running); \
38 if (!lsan_inited) \
39 __lsan_init(); \
40 } while (0)
42 // Get the stack trace with the given pc and bp.
43 // The pc will be in the position 0 of the resulting stack trace.
44 // The bp may refer to the current frame or to the caller's frame.
45 ALWAYS_INLINE
46 void GetStackTrace(__sanitizer::BufferedStackTrace *stack,
47 __sanitizer::uptr max_depth, __sanitizer::uptr pc,
48 __sanitizer::uptr bp, void *context, bool fast) {
49 uptr stack_top = 0, stack_bottom = 0;
50 ThreadContext *t;
51 if (fast && (t = CurrentThreadContext())) {
52 stack_top = t->stack_end();
53 stack_bottom = t->stack_begin();
55 if (!SANITIZER_MIPS || IsValidFrame(bp, stack_top, stack_bottom)) {
56 stack->Unwind(max_depth, pc, bp, context, stack_top, stack_bottom, fast);
60 } // namespace __lsan
62 extern bool lsan_inited;
63 extern bool lsan_init_is_running;
65 extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __lsan_init();