[PATCH c++/86881] -Wshadow-local-compatible ICE
[official-gcc.git] / libsanitizer / tsan / tsan_stack_trace.cc
blob3734e0e4975bda589ce01f00ad3e028831ba986b
1 //===-- tsan_stack_trace.cc -----------------------------------------------===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of ThreadSanitizer (TSan), a race detector.
9 //
10 //===----------------------------------------------------------------------===//
11 #include "tsan_stack_trace.h"
12 #include "tsan_rtl.h"
13 #include "tsan_mman.h"
15 namespace __tsan {
17 VarSizeStackTrace::VarSizeStackTrace()
18 : StackTrace(nullptr, 0), trace_buffer(nullptr) {}
20 VarSizeStackTrace::~VarSizeStackTrace() {
21 ResizeBuffer(0);
24 void VarSizeStackTrace::ResizeBuffer(uptr new_size) {
25 if (trace_buffer) {
26 internal_free(trace_buffer);
28 trace_buffer =
29 (new_size > 0)
30 ? (uptr *)internal_alloc(MBlockStackTrace,
31 new_size * sizeof(trace_buffer[0]))
32 : nullptr;
33 trace = trace_buffer;
34 size = new_size;
37 void VarSizeStackTrace::Init(const uptr *pcs, uptr cnt, uptr extra_top_pc) {
38 ResizeBuffer(cnt + !!extra_top_pc);
39 internal_memcpy(trace_buffer, pcs, cnt * sizeof(trace_buffer[0]));
40 if (extra_top_pc)
41 trace_buffer[cnt] = extra_top_pc;
44 } // namespace __tsan