xref: /netbsd-src/external/gpl3/gcc.old/dist/libsanitizer/ubsan/ubsan_diag_standalone.cc (revision cef8759bd76c1b621f8eab8faa6f208faabc2e15)
1 //===-- ubsan_diag_standalone.cc ------------------------------------------===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // Diagnostic reporting for the standalone UBSan runtime.
9 //
10 //===----------------------------------------------------------------------===//
11 
12 #include "ubsan_platform.h"
13 #if CAN_SANITIZE_UB
14 #include "ubsan_diag.h"
15 
16 using namespace __ubsan;
17 
18 extern "C" {
19 SANITIZER_INTERFACE_ATTRIBUTE
__sanitizer_print_stack_trace()20 void __sanitizer_print_stack_trace() {
21   uptr top = 0;
22   uptr bottom = 0;
23   bool request_fast_unwind = common_flags()->fast_unwind_on_fatal;
24   if (request_fast_unwind)
25     __sanitizer::GetThreadStackTopAndBottom(false, &top, &bottom);
26 
27   GET_CURRENT_PC_BP_SP;
28   (void)sp;
29   BufferedStackTrace stack;
30   stack.Unwind(kStackTraceMax, pc, bp, nullptr, top, bottom,
31                request_fast_unwind);
32   stack.Print();
33 }
34 } // extern "C"
35 
36 #endif  // CAN_SANITIZE_UB
37