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