Home | History | Annotate | Download | only in rtl
      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   ReportTypeMutexDoubleLock,
     28   ReportTypeMutexBadUnlock,
     29   ReportTypeMutexBadReadLock,
     30   ReportTypeMutexBadReadUnlock,
     31   ReportTypeSignalUnsafe,
     32   ReportTypeErrnoInSignal,
     33   ReportTypeDeadlock
     34 };
     35 
     36 struct 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   bool suppressable;
     46 };
     47 
     48 struct ReportMopMutex {
     49   u64 id;
     50   bool write;
     51 };
     52 
     53 struct ReportMop {
     54   int tid;
     55   uptr addr;
     56   int size;
     57   bool write;
     58   bool atomic;
     59   Vector<ReportMopMutex> mset;
     60   ReportStack *stack;
     61 
     62   ReportMop();
     63 };
     64 
     65 enum ReportLocationType {
     66   ReportLocationGlobal,
     67   ReportLocationHeap,
     68   ReportLocationStack,
     69   ReportLocationTLS,
     70   ReportLocationFD
     71 };
     72 
     73 struct ReportLocation {
     74   ReportLocationType type;
     75   uptr addr;
     76   uptr size;
     77   char *module;
     78   uptr offset;
     79   int tid;
     80   int fd;
     81   char *name;
     82   char *file;
     83   int line;
     84   bool suppressable;
     85   ReportStack *stack;
     86 };
     87 
     88 struct ReportThread {
     89   int id;
     90   uptr pid;
     91   bool running;
     92   char *name;
     93   int parent_tid;
     94   ReportStack *stack;
     95 };
     96 
     97 struct ReportMutex {
     98   u64 id;
     99   uptr addr;
    100   bool destroyed;
    101   ReportStack *stack;
    102 };
    103 
    104 class ReportDesc {
    105  public:
    106   ReportType typ;
    107   Vector<ReportStack*> stacks;
    108   Vector<ReportMop*> mops;
    109   Vector<ReportLocation*> locs;
    110   Vector<ReportMutex*> mutexes;
    111   Vector<ReportThread*> threads;
    112   Vector<int> unique_tids;
    113   ReportStack *sleep;
    114   int count;
    115 
    116   ReportDesc();
    117   ~ReportDesc();
    118 
    119  private:
    120   ReportDesc(const ReportDesc&);
    121   void operator = (const ReportDesc&);
    122 };
    123 
    124 // Format and output the report to the console/log. No additional logic.
    125 void PrintReport(const ReportDesc *rep);
    126 void PrintStack(const ReportStack *stack);
    127 
    128 }  // namespace __tsan
    129 
    130 #endif  // TSAN_REPORT_H
    131