1 //===-- asan_stack.h --------------------------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of AddressSanitizer, an address sanity checker.
10 // ASan-private header for asan_stack.cc.
11 //===----------------------------------------------------------------------===//
15 #include "sanitizer_common/sanitizer_stacktrace.h"
19 void GetStackTrace(StackTrace
*stack
, uptr max_s
, uptr pc
, uptr bp
);
20 void PrintStack(StackTrace
*stack
);
24 // Get the stack trace with the given pc and bp.
25 // The pc will be in the position 0 of the resulting stack trace.
26 // The bp may refer to the current frame or to the caller's frame.
27 // fast_unwind is currently unused.
28 #define GET_STACK_TRACE_WITH_PC_AND_BP(max_s, pc, bp) \
30 GetStackTrace(&stack, max_s, pc, bp)
32 // NOTE: A Rule of thumb is to retrieve stack trace in the interceptors
33 // as early as possible (in functions exposed to the user), as we generally
34 // don't want stack trace to contain functions from ASan internals.
36 #define GET_STACK_TRACE_HERE(max_size) \
37 GET_STACK_TRACE_WITH_PC_AND_BP(max_size, \
38 StackTrace::GetCurrentPc(), GET_CURRENT_FRAME())
40 #define GET_STACK_TRACE_HERE_FOR_MALLOC \
41 GET_STACK_TRACE_HERE(flags()->malloc_context_size)
43 #define GET_STACK_TRACE_HERE_FOR_FREE(ptr) \
44 GET_STACK_TRACE_HERE(flags()->malloc_context_size)
46 #define PRINT_CURRENT_STACK() \
48 GET_STACK_TRACE_HERE(kStackTraceMax); \
52 #endif // ASAN_STACK_H