Merge trunk version 208955 into gupc branch.
[official-gcc.git] / libsanitizer / tsan / tsan_report.h
blobc0eef9eb023b5fe3b880b82c80345e9761d594ce
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 ReportTypeSignalUnsafe,
26 ReportTypeErrnoInSignal
29 struct ReportStack {
30 ReportStack *next;
31 char *module;
32 uptr offset;
33 uptr pc;
34 char *func;
35 char *file;
36 int line;
37 int col;
40 struct ReportMopMutex {
41 u64 id;
42 bool write;
45 struct ReportMop {
46 int tid;
47 uptr addr;
48 int size;
49 bool write;
50 bool atomic;
51 Vector<ReportMopMutex> mset;
52 ReportStack *stack;
54 ReportMop();
57 enum ReportLocationType {
58 ReportLocationGlobal,
59 ReportLocationHeap,
60 ReportLocationStack,
61 ReportLocationTLS,
62 ReportLocationFD
65 struct ReportLocation {
66 ReportLocationType type;
67 uptr addr;
68 uptr size;
69 char *module;
70 uptr offset;
71 int tid;
72 int fd;
73 char *name;
74 char *file;
75 int line;
76 ReportStack *stack;
79 struct ReportThread {
80 int id;
81 uptr pid;
82 bool running;
83 char *name;
84 int parent_tid;
85 ReportStack *stack;
88 struct ReportMutex {
89 u64 id;
90 bool destroyed;
91 ReportStack *stack;
94 class ReportDesc {
95 public:
96 ReportType typ;
97 Vector<ReportStack*> stacks;
98 Vector<ReportMop*> mops;
99 Vector<ReportLocation*> locs;
100 Vector<ReportMutex*> mutexes;
101 Vector<ReportThread*> threads;
102 ReportStack *sleep;
103 int count;
105 ReportDesc();
106 ~ReportDesc();
108 private:
109 ReportDesc(const ReportDesc&);
110 void operator = (const ReportDesc&);
113 // Format and output the report to the console/log. No additional logic.
114 void PrintReport(const ReportDesc *rep);
115 void PrintStack(const ReportStack *stack);
117 } // namespace __tsan
119 #endif // TSAN_REPORT_H