asan_stack.cc revision 274201
1238106Sdes//===-- asan_stack.cc -----------------------------------------------------===//
2238106Sdes//
3238106Sdes//                     The LLVM Compiler Infrastructure
4238106Sdes//
5238106Sdes// This file is distributed under the University of Illinois Open Source
6238106Sdes// License. See LICENSE.TXT for details.
7238106Sdes//
8238106Sdes//===----------------------------------------------------------------------===//
9238106Sdes//
10238106Sdes// This file is a part of AddressSanitizer, an address sanity checker.
11238106Sdes//
12238106Sdes// Code for ASan stack trace.
13238106Sdes//===----------------------------------------------------------------------===//
14238106Sdes#include "asan_internal.h"
15238106Sdes#include "asan_flags.h"
16238106Sdes#include "asan_stack.h"
17238106Sdes#include "sanitizer_common/sanitizer_flags.h"
18238106Sdes
19238106Sdesnamespace __asan {
20238106Sdes
21238106Sdesstatic bool MaybeCallAsanSymbolize(const void *pc, char *out_buffer,
22238106Sdes                                   int out_size) {
23238106Sdes  return (&__asan_symbolize) ? __asan_symbolize(pc, out_buffer, out_size)
24238106Sdes                             : false;
25238106Sdes}
26238106Sdes
27238106Sdesvoid PrintStack(const uptr *trace, uptr size) {
28238106Sdes  StackTrace::PrintStack(trace, size, MaybeCallAsanSymbolize);
29238106Sdes}
30238106Sdes
31238106Sdesvoid PrintStack(StackTrace *stack) {
32238106Sdes  PrintStack(stack->trace, stack->size);
33238106Sdes}
34238106Sdes
35238106Sdes}  // namespace __asan
36238106Sdes
37238106Sdes// ------------------ Interface -------------- {{{1
38238106Sdes
39238106Sdes// Provide default implementation of __asan_symbolize that does nothing
40238106Sdes// and may be overriden by user if he wants to use his own symbolization.
41238106Sdes// ASan on Windows has its own implementation of this.
42238106Sdes#if !SANITIZER_WINDOWS && !SANITIZER_SUPPORTS_WEAK_HOOKS
43238106SdesSANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE NOINLINE
44238106Sdesbool __asan_symbolize(const void *pc, char *out_buffer, int out_size) {
45238106Sdes  return false;
46238106Sdes}
47238106Sdes#endif
48238106Sdes