• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   ReportTypeUseAfterFree,
24   ReportTypeThreadLeak,
25   ReportTypeMutexDestroyLocked,
26   ReportTypeSignalUnsafe,
27   ReportTypeErrnoInSignal,
28 };
29 
30 struct ReportStack {
31   ReportStack *next;
32   char *module;
33   uptr offset;
34   uptr pc;
35   char *func;
36   char *file;
37   int line;
38   int col;
39 };
40 
41 struct ReportMop {
42   int tid;
43   uptr addr;
44   int size;
45   bool write;
46   int nmutex;
47   int *mutex;
48   ReportStack *stack;
49 };
50 
51 enum ReportLocationType {
52   ReportLocationGlobal,
53   ReportLocationHeap,
54   ReportLocationStack,
55 };
56 
57 struct ReportLocation {
58   ReportLocationType type;
59   uptr addr;
60   uptr size;
61   int tid;
62   char *name;
63   char *file;
64   int line;
65   ReportStack *stack;
66 };
67 
68 struct ReportThread {
69   int id;
70   bool running;
71   char *name;
72   ReportStack *stack;
73 };
74 
75 struct ReportMutex {
76   int id;
77   ReportStack *stack;
78 };
79 
80 class ReportDesc {
81  public:
82   ReportType typ;
83   Vector<ReportStack*> stacks;
84   Vector<ReportMop*> mops;
85   Vector<ReportLocation*> locs;
86   Vector<ReportMutex*> mutexes;
87   Vector<ReportThread*> threads;
88   ReportStack *sleep;
89 
90   ReportDesc();
91   ~ReportDesc();
92 
93  private:
94   ReportDesc(const ReportDesc&);
95   void operator = (const ReportDesc&);
96 };
97 
98 // Format and output the report to the console/log. No additional logic.
99 void PrintReport(const ReportDesc *rep);
100 void PrintStack(const ReportStack *stack);
101 
102 }  // namespace __tsan
103 
104 #endif  // TSAN_REPORT_H
105