asan_stack.cc revision 547f9dd4c0302fe9a571e1811a4a92dd82ef89f6
1//===-- asan_stack.cc -----------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file is a part of AddressSanitizer, an address sanity checker. 11// 12// Code for ASan stack trace. 13//===----------------------------------------------------------------------===// 14#include "asan_internal.h" 15#include "asan_flags.h" 16#include "asan_stack.h" 17#include "sanitizer_common/sanitizer_flags.h" 18 19namespace __asan { 20 21static bool MaybeCallAsanSymbolize(const void *pc, char *out_buffer, 22 int out_size) { 23 return (&__asan_symbolize) ? __asan_symbolize(pc, out_buffer, out_size) 24 : false; 25} 26 27void PrintStack(const uptr *trace, uptr size) { 28 if (!trace) { 29 Printf("<empty stack>\n"); 30 return; 31 } 32 StackTrace::PrintStack(trace, size, common_flags()->symbolize, 33 MaybeCallAsanSymbolize); 34} 35void PrintStack(StackTrace *stack) { 36 PrintStack(stack->trace, stack->size); 37} 38 39} // namespace __asan 40 41// ------------------ Interface -------------- {{{1 42 43// Provide default implementation of __asan_symbolize that does nothing 44// and may be overriden by user if he wants to use his own symbolization. 45// ASan on Windows has its own implementation of this. 46#if !SANITIZER_WINDOWS && !SANITIZER_SUPPORTS_WEAK_HOOKS 47SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE NOINLINE 48bool __asan_symbolize(const void *pc, char *out_buffer, int out_size) { 49 return false; 50} 51#endif 52