Path: blob/main/contrib/llvm-project/compiler-rt/lib/rtsan/rtsan_stack.cpp
35234 views
//===--- rtsan_stack.cpp - Realtime Sanitizer -------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8//===----------------------------------------------------------------------===//910#include "rtsan_stack.h"1112#include <sanitizer_common/sanitizer_flags.h>13#include <sanitizer_common/sanitizer_stacktrace.h>1415using namespace __sanitizer;16using namespace __rtsan;1718// We must define our own implementation of this method for our runtime.19// This one is just copied from UBSan.20namespace __sanitizer {21void BufferedStackTrace::UnwindImpl(uptr pc, uptr bp, void *context,22bool request_fast, u32 max_depth) {23uptr top = 0;24uptr bottom = 0;25GetThreadStackTopAndBottom(false, &top, &bottom);26bool fast = StackTrace::WillUseFastUnwind(request_fast);27Unwind(max_depth, pc, bp, context, top, bottom, fast);28}29} // namespace __sanitizer3031static void SetGlobalStackTraceFormat() {32SetCommonFlagsDefaults();33CommonFlags cf;34cf.CopyFrom(*common_flags());35cf.stack_trace_format = "DEFAULT";36cf.external_symbolizer_path = GetEnv("RTSAN_SYMBOLIZER_PATH");37OverrideCommonFlags(cf);38}3940void __rtsan::PrintStackTrace() {4142BufferedStackTrace stack{};4344GET_CURRENT_PC_BP;45stack.Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_fatal);4647SetGlobalStackTraceFormat();48stack.Print();49}505152