2014-10-24 Richard Biener <rguenther@suse.de>
[official-gcc.git] / libsanitizer / tsan / tsan_report.h
blob0bde59b16754eb650c05a06d0bc9a1530530db4f
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 "tsan_defs.h"
15 #include "tsan_vector.h"
17 namespace __tsan {
19 enum ReportType {
20 ReportTypeRace,
21 ReportTypeVptrRace,
22 ReportTypeUseAfterFree,
23 ReportTypeThreadLeak,
24 ReportTypeMutexDestroyLocked,
25 ReportTypeMutexDoubleLock,
26 ReportTypeMutexBadUnlock,
27 ReportTypeMutexBadReadLock,
28 ReportTypeMutexBadReadUnlock,
29 ReportTypeSignalUnsafe,
30 ReportTypeErrnoInSignal,
31 ReportTypeDeadlock
34 struct ReportStack {
35 ReportStack *next;
36 char *module;
37 uptr offset;
38 uptr pc;
39 char *func;
40 char *file;
41 int line;
42 int col;
43 bool suppressable;
46 struct ReportMopMutex {
47 u64 id;
48 bool write;
51 struct ReportMop {
52 int tid;
53 uptr addr;
54 int size;
55 bool write;
56 bool atomic;
57 Vector<ReportMopMutex> mset;
58 ReportStack *stack;
60 ReportMop();
63 enum ReportLocationType {
64 ReportLocationGlobal,
65 ReportLocationHeap,
66 ReportLocationStack,
67 ReportLocationTLS,
68 ReportLocationFD
71 struct ReportLocation {
72 ReportLocationType type;
73 uptr addr;
74 uptr size;
75 char *module;
76 uptr offset;
77 int tid;
78 int fd;
79 char *name;
80 char *file;
81 int line;
82 bool suppressable;
83 ReportStack *stack;
86 struct ReportThread {
87 int id;
88 uptr pid;
89 bool running;
90 char *name;
91 int parent_tid;
92 ReportStack *stack;
95 struct ReportMutex {
96 u64 id;
97 uptr addr;
98 bool destroyed;
99 ReportStack *stack;
102 class ReportDesc {
103 public:
104 ReportType typ;
105 Vector<ReportStack*> stacks;
106 Vector<ReportMop*> mops;
107 Vector<ReportLocation*> locs;
108 Vector<ReportMutex*> mutexes;
109 Vector<ReportThread*> threads;
110 Vector<int> unique_tids;
111 ReportStack *sleep;
112 int count;
114 ReportDesc();
115 ~ReportDesc();
117 private:
118 ReportDesc(const ReportDesc&);
119 void operator = (const ReportDesc&);
122 // Format and output the report to the console/log. No additional logic.
123 void PrintReport(const ReportDesc *rep);
124 void PrintStack(const ReportStack *stack);
126 } // namespace __tsan
128 #endif // TSAN_REPORT_H