blob: 0bc5a5f2d0366bad801b2a1ff287cde8b068232c [file] [log] [blame]
Alexey Samsonove5f58952012-06-04 13:50:10 +00001//===-- asan_stack.cc -----------------------------------------------------===//
Kostya Serebryany1e172b42011-11-30 01:07:02 +00002//
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 Samsonovc70fa282013-01-31 13:46:14 +000014#include "asan_internal.h"
Kostya Serebryany1b5ea8f2012-08-28 14:11:57 +000015#include "asan_flags.h"
Kostya Serebryany1e172b42011-11-30 01:07:02 +000016#include "asan_stack.h"
Sergey Matveeved20ebe2013-05-06 11:27:58 +000017#include "sanitizer_common/sanitizer_flags.h"
Alexey Samsonov5f2fe372012-06-04 11:20:17 +000018
Kostya Serebryany1e172b42011-11-30 01:07:02 +000019namespace __asan {
20
Alexey Samsonov6a08d292012-12-07 22:01:28 +000021static 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 Serebryany6d958692013-10-18 14:50:44 +000027void PrintStack(const uptr *trace, uptr size) {
Alexey Samsonov7996a2e2013-10-29 05:31:25 +000028 StackTrace::PrintStack(trace, size, MaybeCallAsanSymbolize);
Kostya Serebryanycc347222012-08-28 13:49:49 +000029}
Dmitry Vyukovdb92faf2013-10-28 13:05:32 +000030
Kostya Serebryany6d958692013-10-18 14:50:44 +000031void PrintStack(StackTrace *stack) {
32 PrintStack(stack->trace, stack->size);
33}
Kostya Serebryanycc347222012-08-28 13:49:49 +000034
Kostya Serebryany1e172b42011-11-30 01:07:02 +000035} // namespace __asan
Alexey Samsonovc93d3e22012-08-22 13:31:37 +000036
37// ------------------ Interface -------------- {{{1
Alexey Samsonovc93d3e22012-08-22 13:31:37 +000038
Alexey Samsonov1ca53572012-10-02 12:11:17 +000039// 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 Stepanov24e13722013-03-19 14:33:38 +000042#if !SANITIZER_WINDOWS && !SANITIZER_SUPPORTS_WEAK_HOOKS
Timur Iskhodzhanov3c80c6c2013-08-13 11:42:45 +000043SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE NOINLINE
Alexey Samsonov1ca53572012-10-02 12:11:17 +000044bool __asan_symbolize(const void *pc, char *out_buffer, int out_size) {
45 return false;
Alexey Samsonovc93d3e22012-08-22 13:31:37 +000046}
Alexey Samsonov1ca53572012-10-02 12:11:17 +000047#endif