Alexey Samsonov | e5f5895 | 2012-06-04 13:50:10 +0000 | [diff] [blame] | 1 | //===-- asan_stack.cc -----------------------------------------------------===// |
Kostya Serebryany | 1e172b4 | 2011-11-30 01:07:02 +0000 | [diff] [blame] | 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 | //===----------------------------------------------------------------------===// |
Alexey Samsonov | c70fa28 | 2013-01-31 13:46:14 +0000 | [diff] [blame] | 14 | #include "asan_internal.h" |
Kostya Serebryany | 1b5ea8f | 2012-08-28 14:11:57 +0000 | [diff] [blame] | 15 | #include "asan_flags.h" |
Kostya Serebryany | 1e172b4 | 2011-11-30 01:07:02 +0000 | [diff] [blame] | 16 | #include "asan_stack.h" |
Sergey Matveev | ed20ebe | 2013-05-06 11:27:58 +0000 | [diff] [blame] | 17 | #include "sanitizer_common/sanitizer_flags.h" |
Alexey Samsonov | 5f2fe37 | 2012-06-04 11:20:17 +0000 | [diff] [blame] | 18 | |
Kostya Serebryany | 1e172b4 | 2011-11-30 01:07:02 +0000 | [diff] [blame] | 19 | namespace __asan { |
| 20 | |
Alexey Samsonov | 6a08d29 | 2012-12-07 22:01:28 +0000 | [diff] [blame] | 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 | |
Kostya Serebryany | 6d95869 | 2013-10-18 14:50:44 +0000 | [diff] [blame] | 27 | void PrintStack(const uptr *trace, uptr size) { |
Alexey Samsonov | 7996a2e | 2013-10-29 05:31:25 +0000 | [diff] [blame] | 28 | StackTrace::PrintStack(trace, size, MaybeCallAsanSymbolize); |
Kostya Serebryany | cc34722 | 2012-08-28 13:49:49 +0000 | [diff] [blame] | 29 | } |
Dmitry Vyukov | db92faf | 2013-10-28 13:05:32 +0000 | [diff] [blame] | 30 | |
Kostya Serebryany | 6d95869 | 2013-10-18 14:50:44 +0000 | [diff] [blame] | 31 | void PrintStack(StackTrace *stack) { |
| 32 | PrintStack(stack->trace, stack->size); |
| 33 | } |
Kostya Serebryany | cc34722 | 2012-08-28 13:49:49 +0000 | [diff] [blame] | 34 | |
Kostya Serebryany | 1e172b4 | 2011-11-30 01:07:02 +0000 | [diff] [blame] | 35 | } // namespace __asan |
Alexey Samsonov | c93d3e2 | 2012-08-22 13:31:37 +0000 | [diff] [blame] | 36 | |
| 37 | // ------------------ Interface -------------- {{{1 |
Alexey Samsonov | c93d3e2 | 2012-08-22 13:31:37 +0000 | [diff] [blame] | 38 | |
Alexey Samsonov | 1ca5357 | 2012-10-02 12:11:17 +0000 | [diff] [blame] | 39 | // Provide default implementation of __asan_symbolize that does nothing |
| 40 | // and may be overriden by user if he wants to use his own symbolization. |
| 41 | // ASan on Windows has its own implementation of this. |
Evgeniy Stepanov | 24e1372 | 2013-03-19 14:33:38 +0000 | [diff] [blame] | 42 | #if !SANITIZER_WINDOWS && !SANITIZER_SUPPORTS_WEAK_HOOKS |
Timur Iskhodzhanov | 3c80c6c | 2013-08-13 11:42:45 +0000 | [diff] [blame] | 43 | SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE NOINLINE |
Alexey Samsonov | 1ca5357 | 2012-10-02 12:11:17 +0000 | [diff] [blame] | 44 | bool __asan_symbolize(const void *pc, char *out_buffer, int out_size) { |
| 45 | return false; |
Alexey Samsonov | c93d3e2 | 2012-08-22 13:31:37 +0000 | [diff] [blame] | 46 | } |
Alexey Samsonov | 1ca5357 | 2012-10-02 12:11:17 +0000 | [diff] [blame] | 47 | #endif |