tsan_report.h revision 2d1fdb26e458c4ddc04155c1d421bced3ba90cd0
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 19namespace __tsan { 20 21enum ReportType { 22 ReportTypeRace, 23 ReportTypeVptrRace, 24 ReportTypeUseAfterFree, 25 ReportTypeThreadLeak, 26 ReportTypeMutexDestroyLocked, 27 ReportTypeMutexDoubleLock, 28 ReportTypeMutexBadUnlock, 29 ReportTypeMutexBadReadLock, 30 ReportTypeMutexBadReadUnlock, 31 ReportTypeSignalUnsafe, 32 ReportTypeErrnoInSignal, 33 ReportTypeDeadlock 34}; 35 36struct ReportStack { 37 ReportStack *next; 38 char *module; 39 uptr offset; 40 uptr pc; 41 char *func; 42 char *file; 43 int line; 44 int col; 45}; 46 47struct ReportMopMutex { 48 u64 id; 49 bool write; 50}; 51 52struct ReportMop { 53 int tid; 54 uptr addr; 55 int size; 56 bool write; 57 bool atomic; 58 Vector<ReportMopMutex> mset; 59 ReportStack *stack; 60 61 ReportMop(); 62}; 63 64enum ReportLocationType { 65 ReportLocationGlobal, 66 ReportLocationHeap, 67 ReportLocationStack, 68 ReportLocationTLS, 69 ReportLocationFD 70}; 71 72struct ReportLocation { 73 ReportLocationType type; 74 uptr addr; 75 uptr size; 76 char *module; 77 uptr offset; 78 int tid; 79 int fd; 80 char *name; 81 char *file; 82 int line; 83 ReportStack *stack; 84}; 85 86struct ReportThread { 87 int id; 88 uptr pid; 89 bool running; 90 char *name; 91 int parent_tid; 92 ReportStack *stack; 93}; 94 95struct ReportMutex { 96 u64 id; 97 uptr addr; 98 bool destroyed; 99 ReportStack *stack; 100}; 101 102class 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; 113 114 ReportDesc(); 115 ~ReportDesc(); 116 117 private: 118 ReportDesc(const ReportDesc&); 119 void operator = (const ReportDesc&); 120}; 121 122// Format and output the report to the console/log. No additional logic. 123void PrintReport(const ReportDesc *rep); 124void PrintStack(const ReportStack *stack); 125 126} // namespace __tsan 127 128#endif // TSAN_REPORT_H 129