1*3cab2bb3Spatrick //===-- tsan_stack_trace.h --------------------------------------*- C++ -*-===// 2*3cab2bb3Spatrick // 3*3cab2bb3Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*3cab2bb3Spatrick // See https://llvm.org/LICENSE.txt for license information. 5*3cab2bb3Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*3cab2bb3Spatrick // 7*3cab2bb3Spatrick //===----------------------------------------------------------------------===// 8*3cab2bb3Spatrick // 9*3cab2bb3Spatrick // This file is a part of ThreadSanitizer (TSan), a race detector. 10*3cab2bb3Spatrick // 11*3cab2bb3Spatrick //===----------------------------------------------------------------------===// 12*3cab2bb3Spatrick #ifndef TSAN_STACK_TRACE_H 13*3cab2bb3Spatrick #define TSAN_STACK_TRACE_H 14*3cab2bb3Spatrick 15*3cab2bb3Spatrick #include "sanitizer_common/sanitizer_stacktrace.h" 16*3cab2bb3Spatrick #include "tsan_defs.h" 17*3cab2bb3Spatrick 18*3cab2bb3Spatrick namespace __tsan { 19*3cab2bb3Spatrick 20*3cab2bb3Spatrick // StackTrace which calls malloc/free to allocate the buffer for 21*3cab2bb3Spatrick // addresses in stack traces. 22*3cab2bb3Spatrick struct VarSizeStackTrace : public StackTrace { 23*3cab2bb3Spatrick uptr *trace_buffer; // Owned. 24*3cab2bb3Spatrick 25*3cab2bb3Spatrick VarSizeStackTrace(); 26*3cab2bb3Spatrick ~VarSizeStackTrace(); 27*3cab2bb3Spatrick void Init(const uptr *pcs, uptr cnt, uptr extra_top_pc = 0); 28*3cab2bb3Spatrick 29*3cab2bb3Spatrick // Reverses the current stack trace order, the top frame goes to the bottom, 30*3cab2bb3Spatrick // the last frame goes to the top. 31*3cab2bb3Spatrick void ReverseOrder(); 32*3cab2bb3Spatrick 33*3cab2bb3Spatrick private: 34*3cab2bb3Spatrick void ResizeBuffer(uptr new_size); 35*3cab2bb3Spatrick 36*3cab2bb3Spatrick VarSizeStackTrace(const VarSizeStackTrace &); 37*3cab2bb3Spatrick void operator=(const VarSizeStackTrace &); 38*3cab2bb3Spatrick }; 39*3cab2bb3Spatrick 40*3cab2bb3Spatrick } // namespace __tsan 41*3cab2bb3Spatrick 42*3cab2bb3Spatrick #endif // TSAN_STACK_TRACE_H 43