2016-10-21 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / libsanitizer / tsan / tsan_report.h
blob68924edb54790ae3e3c2284c82fba9313794a449
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
14 #include "sanitizer_common/sanitizer_symbolizer.h"
15 #include "tsan_defs.h"
16 #include "tsan_vector.h"
18 namespace __tsan {
20 enum ReportType {
21 ReportTypeRace,
22 ReportTypeVptrRace,
23 ReportTypeUseAfterFree,
24 ReportTypeVptrUseAfterFree,
25 ReportTypeThreadLeak,
26 ReportTypeMutexDestroyLocked,
27 ReportTypeMutexDoubleLock,
28 ReportTypeMutexBadUnlock,
29 ReportTypeMutexBadReadLock,
30 ReportTypeMutexBadReadUnlock,
31 ReportTypeSignalUnsafe,
32 ReportTypeErrnoInSignal,
33 ReportTypeDeadlock
36 struct ReportStack {
37 SymbolizedStack *frames;
38 bool suppressable;
39 static ReportStack *New();
41 private:
42 ReportStack();
45 struct ReportMopMutex {
46 u64 id;
47 bool write;
50 struct ReportMop {
51 int tid;
52 uptr addr;
53 int size;
54 bool write;
55 bool atomic;
56 Vector<ReportMopMutex> mset;
57 ReportStack *stack;
59 ReportMop();
62 enum ReportLocationType {
63 ReportLocationGlobal,
64 ReportLocationHeap,
65 ReportLocationStack,
66 ReportLocationTLS,
67 ReportLocationFD
70 struct ReportLocation {
71 ReportLocationType type;
72 DataInfo global;
73 uptr heap_chunk_start;
74 uptr heap_chunk_size;
75 int tid;
76 int fd;
77 bool suppressable;
78 ReportStack *stack;
80 static ReportLocation *New(ReportLocationType type);
81 private:
82 explicit ReportLocation(ReportLocationType type);
85 struct ReportThread {
86 int id;
87 uptr pid;
88 bool running;
89 char *name;
90 int parent_tid;
91 ReportStack *stack;
94 struct ReportMutex {
95 u64 id;
96 uptr addr;
97 bool destroyed;
98 ReportStack *stack;
101 class ReportDesc {
102 public:
103 ReportType typ;
104 Vector<ReportStack*> stacks;
105 Vector<ReportMop*> mops;
106 Vector<ReportLocation*> locs;
107 Vector<ReportMutex*> mutexes;
108 Vector<ReportThread*> threads;
109 Vector<int> unique_tids;
110 ReportStack *sleep;
111 int count;
113 ReportDesc();
114 ~ReportDesc();
116 private:
117 ReportDesc(const ReportDesc&);
118 void operator = (const ReportDesc&);
121 // Format and output the report to the console/log. No additional logic.
122 void PrintReport(const ReportDesc *rep);
123 void PrintStack(const ReportStack *stack);
125 } // namespace __tsan
127 #endif // TSAN_REPORT_H