2013-05-30 Ed Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / libsanitizer / tsan / tsan_report.h
blobeae2b3c721f677b4ab879a4caeef406af709cd73
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 ReportTypeUseAfterFree,
22 ReportTypeThreadLeak,
23 ReportTypeMutexDestroyLocked,
24 ReportTypeSignalUnsafe,
25 ReportTypeErrnoInSignal
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;
39 struct ReportMopMutex {
40 u64 id;
41 bool write;
44 struct ReportMop {
45 int tid;
46 uptr addr;
47 int size;
48 bool write;
49 bool atomic;
50 Vector<ReportMopMutex> mset;
51 ReportStack *stack;
53 ReportMop();
56 enum ReportLocationType {
57 ReportLocationGlobal,
58 ReportLocationHeap,
59 ReportLocationStack,
60 ReportLocationTLS,
61 ReportLocationFD
64 struct ReportLocation {
65 ReportLocationType type;
66 uptr addr;
67 uptr size;
68 char *module;
69 uptr offset;
70 int tid;
71 int fd;
72 char *name;
73 char *file;
74 int line;
75 ReportStack *stack;
78 struct ReportThread {
79 int id;
80 uptr pid;
81 bool running;
82 char *name;
83 int parent_tid;
84 ReportStack *stack;
87 struct ReportMutex {
88 u64 id;
89 bool destroyed;
90 ReportStack *stack;
93 class ReportDesc {
94 public:
95 ReportType typ;
96 Vector<ReportStack*> stacks;
97 Vector<ReportMop*> mops;
98 Vector<ReportLocation*> locs;
99 Vector<ReportMutex*> mutexes;
100 Vector<ReportThread*> threads;
101 ReportStack *sleep;
103 ReportDesc();
104 ~ReportDesc();
106 private:
107 ReportDesc(const ReportDesc&);
108 void operator = (const ReportDesc&);
111 // Format and output the report to the console/log. No additional logic.
112 void PrintReport(const ReportDesc *rep);
113 void PrintStack(const ReportStack *stack);
115 } // namespace __tsan
117 #endif // TSAN_REPORT_H