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, 230dc47b652dfbe0d61d153eded02bae9487a7b539Dmitry Vyukov ReportTypeVptrRace, 24069ce828e3057819ee34426496ea7080f7cc52f0Dmitry Vyukov ReportTypeUseAfterFree, 257ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany ReportTypeThreadLeak, 267ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany ReportTypeMutexDestroyLocked, 272d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines ReportTypeMutexDoubleLock, 282d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines ReportTypeMutexBadUnlock, 292d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines ReportTypeMutexBadReadLock, 302d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines ReportTypeMutexBadReadUnlock, 317ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany ReportTypeSignalUnsafe, 322d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines ReportTypeErrnoInSignal, 332d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines ReportTypeDeadlock 347ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany}; 357ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany 367ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanystruct ReportStack { 377ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany ReportStack *next; 387ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany char *module; 397ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany uptr offset; 407ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany uptr pc; 417ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany char *func; 427ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany char *file; 437ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany int line; 447ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany int col; 455d71de26cedae3dafc17449fe0182045c0bd20e8Stephen Hines bool suppressable; 467ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany}; 477ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany 48ad9da372f962495b3487685232d09390be841b1cDmitry Vyukovstruct ReportMopMutex { 49ad9da372f962495b3487685232d09390be841b1cDmitry Vyukov u64 id; 50ad9da372f962495b3487685232d09390be841b1cDmitry Vyukov bool write; 51ad9da372f962495b3487685232d09390be841b1cDmitry Vyukov}; 52ad9da372f962495b3487685232d09390be841b1cDmitry Vyukov 537ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanystruct ReportMop { 547ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany int tid; 557ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany uptr addr; 567ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany int size; 577ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany bool write; 580a07b354fe95d50911c620b42fc031868ef15cc1Dmitry Vyukov bool atomic; 59ad9da372f962495b3487685232d09390be841b1cDmitry Vyukov Vector<ReportMopMutex> mset; 607ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany ReportStack *stack; 61ad9da372f962495b3487685232d09390be841b1cDmitry Vyukov 62ad9da372f962495b3487685232d09390be841b1cDmitry Vyukov ReportMop(); 637ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany}; 647ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany 657ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanyenum ReportLocationType { 667ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany ReportLocationGlobal, 677ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany ReportLocationHeap, 68c2234cd922bbd94e276e0bebb08004d63cbc5cf2Dmitry Vyukov ReportLocationStack, 69fb917e9069ea44f7103f50c658be84a8f66de56cDmitry Vyukov ReportLocationTLS, 70c2234cd922bbd94e276e0bebb08004d63cbc5cf2Dmitry Vyukov ReportLocationFD 717ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany}; 727ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany 737ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanystruct ReportLocation { 747ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany ReportLocationType type; 757ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany uptr addr; 767ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany uptr size; 77433c219f8772c35dc4e6bd32bb4131dbc07fdfd6Dmitry Vyukov char *module; 78433c219f8772c35dc4e6bd32bb4131dbc07fdfd6Dmitry Vyukov uptr offset; 797ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany int tid; 80c2234cd922bbd94e276e0bebb08004d63cbc5cf2Dmitry Vyukov int fd; 817ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany char *name; 827ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany char *file; 837ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany int line; 845d71de26cedae3dafc17449fe0182045c0bd20e8Stephen Hines bool suppressable; 857ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany ReportStack *stack; 867ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany}; 877ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany 887ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanystruct ReportThread { 897ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany int id; 90e0023f74ea88efee329f68391b70f8adc6b21617Dmitry Vyukov uptr pid; 917ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany bool running; 927ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany char *name; 93da3503782901d30bd6e48885055b51b38cf5126cDmitry Vyukov int parent_tid; 947ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany ReportStack *stack; 957ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany}; 967ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany 977ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanystruct ReportMutex { 98ad9da372f962495b3487685232d09390be841b1cDmitry Vyukov u64 id; 992d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines uptr addr; 100ad9da372f962495b3487685232d09390be841b1cDmitry Vyukov bool destroyed; 1017ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany ReportStack *stack; 1027ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany}; 1037ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany 1047ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanyclass ReportDesc { 1057ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany public: 1067ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany ReportType typ; 1077ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany Vector<ReportStack*> stacks; 1087ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany Vector<ReportMop*> mops; 1097ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany Vector<ReportLocation*> locs; 1107ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany Vector<ReportMutex*> mutexes; 1117ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany Vector<ReportThread*> threads; 1122d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines Vector<int> unique_tids; 113848531192777acecf79747dc7c1ffeedf5c1da9fDmitry Vyukov ReportStack *sleep; 1144536cb1fa7734133f404acb413589d7a6d314f4aDmitry Vyukov int count; 1157ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany 1167ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany ReportDesc(); 1177ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany ~ReportDesc(); 1187ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany 1197ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany private: 1207ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany ReportDesc(const ReportDesc&); 1217ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany void operator = (const ReportDesc&); 1227ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany}; 1237ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany 1247ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany// Format and output the report to the console/log. No additional logic. 1257ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryanyvoid PrintReport(const ReportDesc *rep); 1261da1056127d1dbcacdd035eb4149257848f7c4dfDmitry Vyukovvoid PrintStack(const ReportStack *stack); 1277ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany 1287ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany} // namespace __tsan 1297ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany 1307ac41484ea322e0ea5774df681660269f5dc321eKostya Serebryany#endif // TSAN_REPORT_H 131