146ba9697SNico Weber //===-- ubsan_diag_standalone.cpp -----------------------------------------===// 246ba9697SNico Weber // 346ba9697SNico Weber // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 446ba9697SNico Weber // See https://llvm.org/LICENSE.txt for license information. 546ba9697SNico Weber // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 646ba9697SNico Weber // 746ba9697SNico Weber //===----------------------------------------------------------------------===// 846ba9697SNico Weber // 946ba9697SNico Weber // Diagnostic reporting for the standalone UBSan runtime. 1046ba9697SNico Weber // 1146ba9697SNico Weber //===----------------------------------------------------------------------===// 1246ba9697SNico Weber 1346ba9697SNico Weber #include "ubsan_platform.h" 1446ba9697SNico Weber #if CAN_SANITIZE_UB 1546ba9697SNico Weber #include "ubsan_diag.h" 1646ba9697SNico Weber 1746ba9697SNico Weber using namespace __ubsan; 1846ba9697SNico Weber 1946ba9697SNico Weber void __sanitizer::BufferedStackTrace::UnwindImpl( 2046ba9697SNico Weber uptr pc, uptr bp, void *context, bool request_fast, u32 max_depth) { 2146ba9697SNico Weber uptr top = 0; 2246ba9697SNico Weber uptr bottom = 0; 2346ba9697SNico Weber GetThreadStackTopAndBottom(false, &top, &bottom); 24261d6e05SFangrui Song bool fast = StackTrace::WillUseFastUnwind(request_fast); 25261d6e05SFangrui Song Unwind(max_depth, pc, bp, context, top, bottom, fast); 2646ba9697SNico Weber } 2746ba9697SNico Weber 2846ba9697SNico Weber extern "C" { 2946ba9697SNico Weber SANITIZER_INTERFACE_ATTRIBUTE 3046ba9697SNico Weber void __sanitizer_print_stack_trace() { 3146ba9697SNico Weber GET_CURRENT_PC_BP; 32*aacd1afaSFlorian Mayer UNINITIALIZED BufferedStackTrace stack; 3346ba9697SNico Weber stack.Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_fatal); 3446ba9697SNico Weber stack.Print(); 3546ba9697SNico Weber } 3646ba9697SNico Weber } // extern "C" 3746ba9697SNico Weber 3846ba9697SNico Weber #endif // CAN_SANITIZE_UB 39