1*68d75effSDimitry Andric //===-- ubsan_diag_standalone.cpp -----------------------------------------===// 2*68d75effSDimitry Andric // 3*68d75effSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*68d75effSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*68d75effSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*68d75effSDimitry Andric // 7*68d75effSDimitry Andric //===----------------------------------------------------------------------===// 8*68d75effSDimitry Andric // 9*68d75effSDimitry Andric // Diagnostic reporting for the standalone UBSan runtime. 10*68d75effSDimitry Andric // 11*68d75effSDimitry Andric //===----------------------------------------------------------------------===// 12*68d75effSDimitry Andric 13*68d75effSDimitry Andric #include "ubsan_platform.h" 14*68d75effSDimitry Andric #if CAN_SANITIZE_UB 15*68d75effSDimitry Andric #include "ubsan_diag.h" 16*68d75effSDimitry Andric 17*68d75effSDimitry Andric using namespace __ubsan; 18*68d75effSDimitry Andric 19*68d75effSDimitry Andric void __sanitizer::BufferedStackTrace::UnwindImpl( 20*68d75effSDimitry Andric uptr pc, uptr bp, void *context, bool request_fast, u32 max_depth) { 21*68d75effSDimitry Andric uptr top = 0; 22*68d75effSDimitry Andric uptr bottom = 0; 23*68d75effSDimitry Andric if (StackTrace::WillUseFastUnwind(request_fast)) { 24*68d75effSDimitry Andric GetThreadStackTopAndBottom(false, &top, &bottom); 25*68d75effSDimitry Andric Unwind(max_depth, pc, bp, nullptr, top, bottom, true); 26*68d75effSDimitry Andric } else 27*68d75effSDimitry Andric Unwind(max_depth, pc, bp, context, 0, 0, false); 28*68d75effSDimitry Andric } 29*68d75effSDimitry Andric 30*68d75effSDimitry Andric extern "C" { 31*68d75effSDimitry Andric SANITIZER_INTERFACE_ATTRIBUTE 32*68d75effSDimitry Andric void __sanitizer_print_stack_trace() { 33*68d75effSDimitry Andric GET_CURRENT_PC_BP; 34*68d75effSDimitry Andric BufferedStackTrace stack; 35*68d75effSDimitry Andric stack.Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_fatal); 36*68d75effSDimitry Andric stack.Print(); 37*68d75effSDimitry Andric } 38*68d75effSDimitry Andric } // extern "C" 39*68d75effSDimitry Andric 40*68d75effSDimitry Andric #endif // CAN_SANITIZE_UB 41