1 //===-- tsan_report.h -------------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file is a part of ThreadSanitizer (TSan), a race detector. 11 // 12 //===----------------------------------------------------------------------===// 13 #ifndef TSAN_REPORT_H 14 #define TSAN_REPORT_H 15 16 #include "tsan_defs.h" 17 #include "tsan_vector.h" 18 19 namespace __tsan { 20 21 enum ReportType { 22 ReportTypeRace, 23 ReportTypeVptrRace, 24 ReportTypeUseAfterFree, 25 ReportTypeThreadLeak, 26 ReportTypeMutexDestroyLocked, 27 ReportTypeSignalUnsafe, 28 ReportTypeErrnoInSignal 29 }; 30 31 struct ReportStack { 32 ReportStack *next; 33 char *module; 34 uptr offset; 35 uptr pc; 36 char *func; 37 char *file; 38 int line; 39 int col; 40 }; 41 42 struct ReportMopMutex { 43 u64 id; 44 bool write; 45 }; 46 47 struct ReportMop { 48 int tid; 49 uptr addr; 50 int size; 51 bool write; 52 bool atomic; 53 Vector<ReportMopMutex> mset; 54 ReportStack *stack; 55 56 ReportMop(); 57 }; 58 59 enum ReportLocationType { 60 ReportLocationGlobal, 61 ReportLocationHeap, 62 ReportLocationStack, 63 ReportLocationTLS, 64 ReportLocationFD 65 }; 66 67 struct ReportLocation { 68 ReportLocationType type; 69 uptr addr; 70 uptr size; 71 char *module; 72 uptr offset; 73 int tid; 74 int fd; 75 char *name; 76 char *file; 77 int line; 78 ReportStack *stack; 79 }; 80 81 struct ReportThread { 82 int id; 83 uptr pid; 84 bool running; 85 char *name; 86 int parent_tid; 87 ReportStack *stack; 88 }; 89 90 struct ReportMutex { 91 u64 id; 92 bool destroyed; 93 ReportStack *stack; 94 }; 95 96 class ReportDesc { 97 public: 98 ReportType typ; 99 Vector<ReportStack*> stacks; 100 Vector<ReportMop*> mops; 101 Vector<ReportLocation*> locs; 102 Vector<ReportMutex*> mutexes; 103 Vector<ReportThread*> threads; 104 ReportStack *sleep; 105 int count; 106 107 ReportDesc(); 108 ~ReportDesc(); 109 110 private: 111 ReportDesc(const ReportDesc&); 112 void operator = (const ReportDesc&); 113 }; 114 115 // Format and output the report to the console/log. No additional logic. 116 void PrintReport(const ReportDesc *rep); 117 void PrintStack(const ReportStack *stack); 118 119 } // namespace __tsan 120 121 #endif // TSAN_REPORT_H 122