1 //===-- tsan_trace.h --------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file is a part of ThreadSanitizer (TSan), a race detector.
11 //===----------------------------------------------------------------------===//
15 #include "tsan_defs.h"
16 #include "tsan_mutex.h"
17 #include "tsan_stack_trace.h"
18 #include "tsan_mutexset.h"
22 const int kTracePartSizeBits
= 13;
23 const int kTracePartSize
= 1 << kTracePartSizeBits
;
24 const int kTraceParts
= 2 * 1024 * 1024 / kTracePartSize
;
25 const int kTraceSize
= kTracePartSize
* kTraceParts
;
27 // Must fit into 3 bits.
38 // Represents a thread event (from most significant bit):
39 // u64 typ : 3; // EventType.
40 // u64 addr : 61; // Associated pc.
43 const uptr kEventPCBits
= 61;
47 BufferedStackTrace stack0
; // Start stack for the trace.
49 VarSizeStackTrace stack0
;
51 u64 epoch0
; // Start epoch for the trace.
54 TraceHeader() : stack0(), epoch0() {}
60 // Must be last to catch overflow as paging fault.
61 // Go shadow stack is dynamically allocated.
62 uptr shadow_stack
[kShadowStackSize
];
64 // Must be the last field, because we unmap the unused part in
65 // CreateThreadContext.
66 TraceHeader headers
[kTraceParts
];
69 : mtx(MutexTypeTrace
, StatMtxTrace
) {
75 #endif // TSAN_TRACE_H