]> git.ipfire.org Git - thirdparty/gcc.git/blame - libsanitizer/tsan/tsan_report.h
[Ada] Improved support for aspect alignment in CCG
[thirdparty/gcc.git] / libsanitizer / tsan / tsan_report.h
CommitLineData
cd0be65c
WM
1//===-- tsan_report.h -------------------------------------------*- C++ -*-===//
2//
b667dd70
ML
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
cd0be65c
WM
6//
7//===----------------------------------------------------------------------===//
8//
9// This file is a part of ThreadSanitizer (TSan), a race detector.
10//
11//===----------------------------------------------------------------------===//
12#ifndef TSAN_REPORT_H
13#define TSAN_REPORT_H
14
c5be964a 15#include "sanitizer_common/sanitizer_symbolizer.h"
b667dd70 16#include "sanitizer_common/sanitizer_thread_registry.h"
eac97531 17#include "sanitizer_common/sanitizer_vector.h"
cd0be65c 18#include "tsan_defs.h"
cd0be65c
WM
19
20namespace __tsan {
21
22enum ReportType {
23 ReportTypeRace,
ef1b3fda 24 ReportTypeVptrRace,
cd0be65c 25 ReportTypeUseAfterFree,
c5be964a 26 ReportTypeVptrUseAfterFree,
5d3805fc 27 ReportTypeExternalRace,
cd0be65c
WM
28 ReportTypeThreadLeak,
29 ReportTypeMutexDestroyLocked,
dee5ea7a 30 ReportTypeMutexDoubleLock,
10189819 31 ReportTypeMutexInvalidAccess,
dee5ea7a
KS
32 ReportTypeMutexBadUnlock,
33 ReportTypeMutexBadReadLock,
34 ReportTypeMutexBadReadUnlock,
cd0be65c 35 ReportTypeSignalUnsafe,
dee5ea7a
KS
36 ReportTypeErrnoInSignal,
37 ReportTypeDeadlock
cd0be65c
WM
38};
39
40struct ReportStack {
696d846a 41 SymbolizedStack *frames;
866e32ad 42 bool suppressable;
696d846a 43 static ReportStack *New();
c5be964a
KS
44
45 private:
46 ReportStack();
cd0be65c
WM
47};
48
e9772e16
KS
49struct ReportMopMutex {
50 u64 id;
51 bool write;
52};
53
cd0be65c
WM
54struct ReportMop {
55 int tid;
56 uptr addr;
57 int size;
58 bool write;
b4ab7d34 59 bool atomic;
5d3805fc 60 uptr external_tag;
e9772e16 61 Vector<ReportMopMutex> mset;
cd0be65c 62 ReportStack *stack;
e9772e16
KS
63
64 ReportMop();
cd0be65c
WM
65};
66
67enum ReportLocationType {
68 ReportLocationGlobal,
69 ReportLocationHeap,
e9772e16 70 ReportLocationStack,
2660d12d 71 ReportLocationTLS,
e9772e16 72 ReportLocationFD
cd0be65c
WM
73};
74
75struct ReportLocation {
76 ReportLocationType type;
c5be964a
KS
77 DataInfo global;
78 uptr heap_chunk_start;
79 uptr heap_chunk_size;
5d3805fc 80 uptr external_tag;
cd0be65c 81 int tid;
e9772e16 82 int fd;
866e32ad 83 bool suppressable;
cd0be65c 84 ReportStack *stack;
c5be964a
KS
85
86 static ReportLocation *New(ReportLocationType type);
87 private:
88 explicit ReportLocation(ReportLocationType type);
cd0be65c
WM
89};
90
91struct ReportThread {
92 int id;
5d3805fc 93 tid_t os_id;
cd0be65c 94 bool running;
b667dd70 95 ThreadType thread_type;
cd0be65c 96 char *name;
5d3805fc 97 u32 parent_tid;
cd0be65c
WM
98 ReportStack *stack;
99};
100
101struct ReportMutex {
e9772e16 102 u64 id;
dee5ea7a 103 uptr addr;
e9772e16 104 bool destroyed;
cd0be65c
WM
105 ReportStack *stack;
106};
107
108class ReportDesc {
109 public:
110 ReportType typ;
5d3805fc 111 uptr tag;
cd0be65c
WM
112 Vector<ReportStack*> stacks;
113 Vector<ReportMop*> mops;
114 Vector<ReportLocation*> locs;
115 Vector<ReportMutex*> mutexes;
116 Vector<ReportThread*> threads;
dee5ea7a 117 Vector<int> unique_tids;
cd0be65c 118 ReportStack *sleep;
ef1b3fda 119 int count;
cd0be65c
WM
120
121 ReportDesc();
122 ~ReportDesc();
123
124 private:
125 ReportDesc(const ReportDesc&);
126 void operator = (const ReportDesc&);
127};
128
129// Format and output the report to the console/log. No additional logic.
130void PrintReport(const ReportDesc *rep);
131void PrintStack(const ReportStack *stack);
132
133} // namespace __tsan
134
135#endif // TSAN_REPORT_H