Home | History | Annotate | Download | only in asan
      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 
     19 namespace __asan {
     20 
     21 static 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 
     27 void PrintStack(StackTrace *stack) {
     28   stack->PrintStack(stack->trace, stack->size, common_flags()->symbolize,
     29                     common_flags()->strip_path_prefix, MaybeCallAsanSymbolize);
     30 }
     31 
     32 }  // namespace __asan
     33 
     34 // ------------------ Interface -------------- {{{1
     35 
     36 // Provide default implementation of __asan_symbolize that does nothing
     37 // and may be overriden by user if he wants to use his own symbolization.
     38 // ASan on Windows has its own implementation of this.
     39 #if !SANITIZER_WINDOWS && !SANITIZER_SUPPORTS_WEAK_HOOKS
     40 SANITIZER_WEAK_ATTRIBUTE SANITIZER_INTERFACE_ATTRIBUTE NOINLINE
     41 bool __asan_symbolize(const void *pc, char *out_buffer, int out_size) {
     42   return false;
     43 }
     44 #endif
     45