1//===-- ubsan_diag_standalone.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// Diagnostic reporting for the standalone UBSan runtime.
11//
12//===----------------------------------------------------------------------===//
13
14#include "ubsan_platform.h"
15#if CAN_SANITIZE_UB
16#include "ubsan_diag.h"
17
18using namespace __ubsan;
19
20extern "C" {
21SANITIZER_INTERFACE_ATTRIBUTE
22void __sanitizer_print_stack_trace() {
23  uptr top = 0;
24  uptr bottom = 0;
25  bool request_fast_unwind = common_flags()->fast_unwind_on_fatal;
26  if (request_fast_unwind)
27    __sanitizer::GetThreadStackTopAndBottom(false, &top, &bottom);
28
29  GET_CURRENT_PC_BP_SP;
30  (void)sp;
31  BufferedStackTrace stack;
32  stack.Unwind(kStackTraceMax, pc, bp, nullptr, top, bottom,
33               request_fast_unwind);
34  stack.Print();
35}
36} // extern "C"
37
38#endif  // CAN_SANITIZE_UB
39