1 //===-- tsan_stack_trace.cc -----------------------------------------------===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of ThreadSanitizer (TSan), a race detector.
10 //===----------------------------------------------------------------------===//
11 #include "tsan_stack_trace.h"
13 #include "tsan_mman.h"
17 VarSizeStackTrace::VarSizeStackTrace()
18 : StackTrace(nullptr, 0), trace_buffer(nullptr) {}
20 VarSizeStackTrace::~VarSizeStackTrace() {
24 void VarSizeStackTrace::ResizeBuffer(uptr new_size
) {
26 internal_free(trace_buffer
);
30 ? (uptr
*)internal_alloc(MBlockStackTrace
,
31 new_size
* sizeof(trace_buffer
[0]))
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]));
41 trace_buffer
[cnt
] = extra_top_pc
;