summaryrefslogtreecommitdiffstats
path: root/contrib/compiler-rt/lib/ubsan/ubsan_diag_standalone.cc
blob: df8ed5fcdf6d1d21a60c692430997b6cc40927fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//===-- ubsan_diag_standalone.cc ------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Diagnostic reporting for the standalone UBSan runtime.
//
//===----------------------------------------------------------------------===//

#include "ubsan_platform.h"
#if CAN_SANITIZE_UB
#include "ubsan_diag.h"

using namespace __ubsan;

extern "C" {
SANITIZER_INTERFACE_ATTRIBUTE
void __sanitizer_print_stack_trace() {
  uptr top = 0;
  uptr bottom = 0;
  bool request_fast_unwind = common_flags()->fast_unwind_on_fatal;
  if (request_fast_unwind)
    __sanitizer::GetThreadStackTopAndBottom(false, &top, &bottom);

  GET_REPORT_OPTIONS(false);
  BufferedStackTrace stack;
  stack.Unwind(kStackTraceMax, Opts.pc, Opts.bp, nullptr, top, bottom,
               request_fast_unwind);
  stack.Print();
}
} // extern "C"

#endif  // CAN_SANITIZE_UB
OpenPOWER on IntegriCloud