[libsanitizer] merge from upstream r169371
[gcc.git] / libsanitizer / tsan / tsan_report.h
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 "tsan_defs.h"
15 #include "tsan_vector.h"
16
17 namespace __tsan {
18
19 enum ReportType {
20 ReportTypeRace,
21 ReportTypeUseAfterFree,
22 ReportTypeThreadLeak,
23 ReportTypeMutexDestroyLocked,
24 ReportTypeSignalUnsafe,
25 ReportTypeErrnoInSignal
26 };
27
28 struct ReportStack {
29 ReportStack *next;
30 char *module;
31 uptr offset;
32 uptr pc;
33 char *func;
34 char *file;
35 int line;
36 int col;
37 };
38
39 struct ReportMop {
40 int tid;
41 uptr addr;
42 int size;
43 bool write;
44 int nmutex;
45 int *mutex;
46 ReportStack *stack;
47 };
48
49 enum ReportLocationType {
50 ReportLocationGlobal,
51 ReportLocationHeap,
52 ReportLocationStack
53 };
54
55 struct ReportLocation {
56 ReportLocationType type;
57 uptr addr;
58 uptr size;
59 char *module;
60 uptr offset;
61 int tid;
62 char *name;
63 char *file;
64 int line;
65 ReportStack *stack;
66 };
67
68 struct ReportThread {
69 int id;
70 uptr pid;
71 bool running;
72 char *name;
73 ReportStack *stack;
74 };
75
76 struct ReportMutex {
77 int id;
78 ReportStack *stack;
79 };
80
81 class ReportDesc {
82 public:
83 ReportType typ;
84 Vector<ReportStack*> stacks;
85 Vector<ReportMop*> mops;
86 Vector<ReportLocation*> locs;
87 Vector<ReportMutex*> mutexes;
88 Vector<ReportThread*> threads;
89 ReportStack *sleep;
90
91 ReportDesc();
92 ~ReportDesc();
93
94 private:
95 ReportDesc(const ReportDesc&);
96 void operator = (const ReportDesc&);
97 };
98
99 // Format and output the report to the console/log. No additional logic.
100 void PrintReport(const ReportDesc *rep);
101 void PrintStack(const ReportStack *stack);
102
103 } // namespace __tsan
104
105 #endif // TSAN_REPORT_H