asan_stack.cc revision c70fa28caaaec2134f2c2230821fcc0f0d7ac27e
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
18namespace __asan {
19
20static bool MaybeCallAsanSymbolize(const void *pc, char *out_buffer,
21                                   int out_size) {
22  return (&__asan_symbolize) ? __asan_symbolize(pc, out_buffer, out_size)
23                             : false;
24}
25
26void PrintStack(StackTrace *stack) {
27  stack->PrintStack(stack->trace, stack->size, flags()->symbolize,
28                    flags()->strip_path_prefix, MaybeCallAsanSymbolize);
29}
30
31}  // namespace __asan
32
33// ------------------ Interface -------------- {{{1
34
35// Provide default implementation of __asan_symbolize that does nothing
36// and may be overriden by user if he wants to use his own symbolization.
37// ASan on Windows has its own implementation of this.
38#if !defined(_WIN32) && !SANITIZER_SUPPORTS_WEAK_HOOKS
39SANITIZER_WEAK_ATTRIBUTE SANITIZER_INTERFACE_ATTRIBUTE NOINLINE
40bool __asan_symbolize(const void *pc, char *out_buffer, int out_size) {
41  return false;
42}
43#endif
44