tsan_report.h revision 7ac41484ea322e0ea5774df681660269f5dc321e
17ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany//===-- tsan_report.h -------------------------------------------*- C++ -*-===//
27ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany//
37ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany//                     The LLVM Compiler Infrastructure
47ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany//
57ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany// This file is distributed under the University of Illinois Open Source
67ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany// License. See LICENSE.TXT for details.
77ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany//
87ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany//===----------------------------------------------------------------------===//
97ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany//
107ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany// This file is a part of ThreadSanitizer (TSan), a race detector.
117ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany//
127ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany//===----------------------------------------------------------------------===//
137ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany#ifndef TSAN_REPORT_H
147ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany#define TSAN_REPORT_H
157ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany
167ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany#include "tsan_defs.h"
177ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany#include "tsan_vector.h"
187ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany
197ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanynamespace __tsan {
207ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany
217ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanyenum ReportType {
227ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ReportTypeRace,
237ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ReportTypeThreadLeak,
247ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ReportTypeMutexDestroyLocked,
257ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ReportTypeSignalUnsafe,
267ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany};
277ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany
287ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanystruct ReportStack {
297ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ReportStack *next;
307ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  char *module;
317ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  uptr offset;
327ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  uptr pc;
337ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  char *func;
347ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  char *file;
357ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  int line;
367ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  int col;
377ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany};
387ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany
397ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanystruct ReportMop {
407ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  int tid;
417ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  uptr addr;
427ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  int size;
437ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  bool write;
447ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  int nmutex;
457ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  int *mutex;
467ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ReportStack *stack;
477ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany};
487ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany
497ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanyenum ReportLocationType {
507ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ReportLocationGlobal,
517ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ReportLocationHeap,
527ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ReportLocationStack,
537ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany};
547ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany
557ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanystruct ReportLocation {
567ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ReportLocationType type;
577ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  uptr addr;
587ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  uptr size;
597ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  int tid;
607ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  char *name;
617ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  char *file;
627ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  int line;
637ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ReportStack *stack;
647ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany};
657ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany
667ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanystruct ReportThread {
677ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  int id;
687ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  bool running;
697ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  char *name;
707ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ReportStack *stack;
717ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany};
727ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany
737ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanystruct ReportMutex {
747ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  int id;
757ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ReportStack *stack;
767ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany};
777ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany
787ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanyclass ReportDesc {
797ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany public:
807ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ReportType typ;
817ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  Vector<ReportStack*> stacks;
827ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  Vector<ReportMop*> mops;
837ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  Vector<ReportLocation*> locs;
847ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  Vector<ReportMutex*> mutexes;
857ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  Vector<ReportThread*> threads;
867ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany
877ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ReportDesc();
887ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ~ReportDesc();
897ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany
907ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany private:
917ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  ReportDesc(const ReportDesc&);
927ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany  void operator = (const ReportDesc&);
937ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany};
947ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany
957ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany// Format and output the report to the console/log. No additional logic.
967ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanyvoid PrintReport(const ReportDesc *rep);
977ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany
987ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany}  // namespace __tsan
997ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany
1007ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany#endif  // TSAN_REPORT_H
101