ubsan_diag_standalone.cpp 1.2 KB

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