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 "sanitizer_common/sanitizer_symbolizer.h"
     17 #include "tsan_defs.h"
     18 #include "tsan_vector.h"
     19 
     20 namespace __tsan {
     21 
     22 enum ReportType {
     23   ReportTypeRace,
     24   ReportTypeVptrRace,
     25   ReportTypeUseAfterFree,
     26   ReportTypeVptrUseAfterFree,
     27   ReportTypeThreadLeak,
     28   ReportTypeMutexDestroyLocked,
     29   ReportTypeMutexDoubleLock,
     30   ReportTypeMutexInvalidAccess,
     31   ReportTypeMutexBadUnlock,
     32   ReportTypeMutexBadReadLock,
     33   ReportTypeMutexBadReadUnlock,
     34   ReportTypeSignalUnsafe,
     35   ReportTypeErrnoInSignal,
     36   ReportTypeDeadlock
     37 };
     38 
     39 struct ReportStack {
     40   SymbolizedStack *frames;
     41   bool suppressable;
     42   static ReportStack *New();
     43 
     44  private:
     45   ReportStack();
     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   DataInfo global;
     76   uptr heap_chunk_start;
     77   uptr heap_chunk_size;
     78   int tid;
     79   int fd;
     80   bool suppressable;
     81   ReportStack *stack;
     82 
     83   static ReportLocation *New(ReportLocationType type);
     84  private:
     85   explicit ReportLocation(ReportLocationType type);
     86 };
     87 
     88 struct ReportThread {
     89   int id;
     90   uptr os_id;
     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