[ARM 4/5 big.LITTLE] Add support for -mcpu=cortex-a57
[official-gcc.git] / libsanitizer / asan / asan_stack.h
blobdf7a9805f92f0bfbf872c2b499287b3fef513dc0
1 //===-- asan_stack.h --------------------------------------------*- C++ -*-===//
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 AddressSanitizer, an address sanity checker.
9 //
10 // ASan-private header for asan_stack.cc.
11 //===----------------------------------------------------------------------===//
12 #ifndef ASAN_STACK_H
13 #define ASAN_STACK_H
15 #include "asan_flags.h"
16 #include "asan_thread.h"
17 #include "sanitizer_common/sanitizer_flags.h"
18 #include "sanitizer_common/sanitizer_stacktrace.h"
20 namespace __asan {
22 void PrintStack(StackTrace *stack);
23 void PrintStack(const uptr *trace, uptr size);
25 } // namespace __asan
27 // Get the stack trace with the given pc and bp.
28 // The pc will be in the position 0 of the resulting stack trace.
29 // The bp may refer to the current frame or to the caller's frame.
30 #if SANITIZER_WINDOWS
31 #define GET_STACK_TRACE_WITH_PC_AND_BP(max_s, pc, bp, fast) \
32 StackTrace stack; \
33 stack.Unwind(max_s, pc, bp, 0, 0, fast)
34 #else
35 #define GET_STACK_TRACE_WITH_PC_AND_BP(max_s, pc, bp, fast) \
36 StackTrace stack; \
37 { \
38 AsanThread *t; \
39 stack.size = 0; \
40 if (asan_inited) { \
41 if ((t = GetCurrentThread()) && !t->isUnwinding()) { \
42 uptr stack_top = t->stack_top(); \
43 uptr stack_bottom = t->stack_bottom(); \
44 ScopedUnwinding unwind_scope(t); \
45 stack.Unwind(max_s, pc, bp, stack_top, stack_bottom, fast); \
46 } else if (t == 0 && !fast) { \
47 /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ \
48 stack.Unwind(max_s, pc, bp, 0, 0, false); \
49 } \
50 } \
52 #endif // SANITIZER_WINDOWS
54 // NOTE: A Rule of thumb is to retrieve stack trace in the interceptors
55 // as early as possible (in functions exposed to the user), as we generally
56 // don't want stack trace to contain functions from ASan internals.
58 #define GET_STACK_TRACE(max_size, fast) \
59 GET_STACK_TRACE_WITH_PC_AND_BP(max_size, \
60 StackTrace::GetCurrentPc(), GET_CURRENT_FRAME(), fast)
62 #define GET_STACK_TRACE_FATAL(pc, bp) \
63 GET_STACK_TRACE_WITH_PC_AND_BP(kStackTraceMax, pc, bp, \
64 common_flags()->fast_unwind_on_fatal)
66 #define GET_STACK_TRACE_FATAL_HERE \
67 GET_STACK_TRACE(kStackTraceMax, common_flags()->fast_unwind_on_fatal)
69 #define GET_STACK_TRACE_THREAD \
70 GET_STACK_TRACE(kStackTraceMax, true)
72 #define GET_STACK_TRACE_MALLOC \
73 GET_STACK_TRACE(common_flags()->malloc_context_size, \
74 common_flags()->fast_unwind_on_malloc)
76 #define GET_STACK_TRACE_FREE GET_STACK_TRACE_MALLOC
78 #define PRINT_CURRENT_STACK() \
79 { \
80 GET_STACK_TRACE_FATAL_HERE; \
81 PrintStack(&stack); \
84 #endif // ASAN_STACK_H