168d75effSDimitry Andric //===-- ubsan_diag_standalone.cpp -----------------------------------------===//
268d75effSDimitry Andric //
368d75effSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
468d75effSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
568d75effSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
668d75effSDimitry Andric //
768d75effSDimitry Andric //===----------------------------------------------------------------------===//
868d75effSDimitry Andric //
968d75effSDimitry Andric // Diagnostic reporting for the standalone UBSan runtime.
1068d75effSDimitry Andric //
1168d75effSDimitry Andric //===----------------------------------------------------------------------===//
1268d75effSDimitry Andric
1368d75effSDimitry Andric #include "ubsan_platform.h"
1468d75effSDimitry Andric #if CAN_SANITIZE_UB
1568d75effSDimitry Andric #include "ubsan_diag.h"
1668d75effSDimitry Andric
1768d75effSDimitry Andric using namespace __ubsan;
1868d75effSDimitry Andric
UnwindImpl(uptr pc,uptr bp,void * context,bool request_fast,u32 max_depth)1968d75effSDimitry Andric void __sanitizer::BufferedStackTrace::UnwindImpl(
2068d75effSDimitry Andric uptr pc, uptr bp, void *context, bool request_fast, u32 max_depth) {
2168d75effSDimitry Andric uptr top = 0;
2268d75effSDimitry Andric uptr bottom = 0;
2368d75effSDimitry Andric GetThreadStackTopAndBottom(false, &top, &bottom);
24*fe6060f1SDimitry Andric bool fast = StackTrace::WillUseFastUnwind(request_fast);
25*fe6060f1SDimitry Andric Unwind(max_depth, pc, bp, context, top, bottom, fast);
2668d75effSDimitry Andric }
2768d75effSDimitry Andric
2868d75effSDimitry Andric extern "C" {
2968d75effSDimitry Andric SANITIZER_INTERFACE_ATTRIBUTE
__sanitizer_print_stack_trace()3068d75effSDimitry Andric void __sanitizer_print_stack_trace() {
3168d75effSDimitry Andric GET_CURRENT_PC_BP;
3268d75effSDimitry Andric BufferedStackTrace stack;
3368d75effSDimitry Andric stack.Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_fatal);
3468d75effSDimitry Andric stack.Print();
3568d75effSDimitry Andric }
3668d75effSDimitry Andric } // extern "C"
3768d75effSDimitry Andric
3868d75effSDimitry Andric #endif // CAN_SANITIZE_UB
39