111
|
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
|
|
14 #include "sanitizer_common/sanitizer_symbolizer.h"
|
|
15 #include "tsan_defs.h"
|
|
16 #include "tsan_vector.h"
|
|
17
|
|
18 namespace __tsan {
|
|
19
|
|
20 enum ReportType {
|
|
21 ReportTypeRace,
|
|
22 ReportTypeVptrRace,
|
|
23 ReportTypeUseAfterFree,
|
|
24 ReportTypeVptrUseAfterFree,
|
|
25 ReportTypeExternalRace,
|
|
26 ReportTypeThreadLeak,
|
|
27 ReportTypeMutexDestroyLocked,
|
|
28 ReportTypeMutexDoubleLock,
|
|
29 ReportTypeMutexInvalidAccess,
|
|
30 ReportTypeMutexBadUnlock,
|
|
31 ReportTypeMutexBadReadLock,
|
|
32 ReportTypeMutexBadReadUnlock,
|
|
33 ReportTypeSignalUnsafe,
|
|
34 ReportTypeErrnoInSignal,
|
|
35 ReportTypeDeadlock
|
|
36 };
|
|
37
|
|
38 struct ReportStack {
|
|
39 SymbolizedStack *frames;
|
|
40 bool suppressable;
|
|
41 static ReportStack *New();
|
|
42
|
|
43 private:
|
|
44 ReportStack();
|
|
45 };
|
|
46
|
|
47 struct ReportMopMutex {
|
|
48 u64 id;
|
|
49 bool write;
|
|
50 };
|
|
51
|
|
52 struct ReportMop {
|
|
53 int tid;
|
|
54 uptr addr;
|
|
55 int size;
|
|
56 bool write;
|
|
57 bool atomic;
|
|
58 uptr external_tag;
|
|
59 Vector<ReportMopMutex> mset;
|
|
60 ReportStack *stack;
|
|
61
|
|
62 ReportMop();
|
|
63 };
|
|
64
|
|
65 enum ReportLocationType {
|
|
66 ReportLocationGlobal,
|
|
67 ReportLocationHeap,
|
|
68 ReportLocationStack,
|
|
69 ReportLocationTLS,
|
|
70 ReportLocationFD
|
|
71 };
|
|
72
|
|
73 struct ReportLocation {
|
|
74 ReportLocationType type;
|
|
75 DataInfo global;
|
|
76 uptr heap_chunk_start;
|
|
77 uptr heap_chunk_size;
|
|
78 uptr external_tag;
|
|
79 int tid;
|
|
80 int fd;
|
|
81 bool suppressable;
|
|
82 ReportStack *stack;
|
|
83
|
|
84 static ReportLocation *New(ReportLocationType type);
|
|
85 private:
|
|
86 explicit ReportLocation(ReportLocationType type);
|
|
87 };
|
|
88
|
|
89 struct ReportThread {
|
|
90 int id;
|
|
91 tid_t os_id;
|
|
92 bool running;
|
|
93 bool workerthread;
|
|
94 char *name;
|
|
95 u32 parent_tid;
|
|
96 ReportStack *stack;
|
|
97 };
|
|
98
|
|
99 struct ReportMutex {
|
|
100 u64 id;
|
|
101 uptr addr;
|
|
102 bool destroyed;
|
|
103 ReportStack *stack;
|
|
104 };
|
|
105
|
|
106 class ReportDesc {
|
|
107 public:
|
|
108 ReportType typ;
|
|
109 uptr tag;
|
|
110 Vector<ReportStack*> stacks;
|
|
111 Vector<ReportMop*> mops;
|
|
112 Vector<ReportLocation*> locs;
|
|
113 Vector<ReportMutex*> mutexes;
|
|
114 Vector<ReportThread*> threads;
|
|
115 Vector<int> unique_tids;
|
|
116 ReportStack *sleep;
|
|
117 int count;
|
|
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
|