2014-09-21 17:33:12 +00:00
|
|
|
//===-- tsan_report.h -------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is a part of ThreadSanitizer (TSan), a race detector.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef TSAN_REPORT_H
|
|
|
|
#define TSAN_REPORT_H
|
|
|
|
|
2015-08-28 15:33:40 +00:00
|
|
|
#include "sanitizer_common/sanitizer_symbolizer.h"
|
2014-09-21 17:33:12 +00:00
|
|
|
#include "tsan_defs.h"
|
|
|
|
#include "tsan_vector.h"
|
|
|
|
|
|
|
|
namespace __tsan {
|
|
|
|
|
|
|
|
enum ReportType {
|
|
|
|
ReportTypeRace,
|
|
|
|
ReportTypeVptrRace,
|
|
|
|
ReportTypeUseAfterFree,
|
2015-08-28 15:33:40 +00:00
|
|
|
ReportTypeVptrUseAfterFree,
|
2014-09-21 17:33:12 +00:00
|
|
|
ReportTypeThreadLeak,
|
|
|
|
ReportTypeMutexDestroyLocked,
|
2015-08-28 15:33:40 +00:00
|
|
|
ReportTypeMutexDoubleLock,
|
|
|
|
ReportTypeMutexBadUnlock,
|
|
|
|
ReportTypeMutexBadReadLock,
|
|
|
|
ReportTypeMutexBadReadUnlock,
|
2014-09-21 17:33:12 +00:00
|
|
|
ReportTypeSignalUnsafe,
|
2015-08-28 15:33:40 +00:00
|
|
|
ReportTypeErrnoInSignal,
|
|
|
|
ReportTypeDeadlock
|
2014-09-21 17:33:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ReportStack {
|
2017-04-10 11:32:00 +00:00
|
|
|
SymbolizedStack *frames;
|
2015-08-28 15:33:40 +00:00
|
|
|
bool suppressable;
|
2017-04-10 11:32:00 +00:00
|
|
|
static ReportStack *New();
|
2015-08-28 15:33:40 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
ReportStack();
|
2014-09-21 17:33:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ReportMopMutex {
|
|
|
|
u64 id;
|
|
|
|
bool write;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ReportMop {
|
|
|
|
int tid;
|
|
|
|
uptr addr;
|
|
|
|
int size;
|
|
|
|
bool write;
|
|
|
|
bool atomic;
|
|
|
|
Vector<ReportMopMutex> mset;
|
|
|
|
ReportStack *stack;
|
|
|
|
|
|
|
|
ReportMop();
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ReportLocationType {
|
|
|
|
ReportLocationGlobal,
|
|
|
|
ReportLocationHeap,
|
|
|
|
ReportLocationStack,
|
|
|
|
ReportLocationTLS,
|
|
|
|
ReportLocationFD
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ReportLocation {
|
|
|
|
ReportLocationType type;
|
2015-08-28 15:33:40 +00:00
|
|
|
DataInfo global;
|
|
|
|
uptr heap_chunk_start;
|
|
|
|
uptr heap_chunk_size;
|
2014-09-21 17:33:12 +00:00
|
|
|
int tid;
|
|
|
|
int fd;
|
2015-08-28 15:33:40 +00:00
|
|
|
bool suppressable;
|
2014-09-21 17:33:12 +00:00
|
|
|
ReportStack *stack;
|
2015-08-28 15:33:40 +00:00
|
|
|
|
|
|
|
static ReportLocation *New(ReportLocationType type);
|
|
|
|
private:
|
|
|
|
explicit ReportLocation(ReportLocationType type);
|
2014-09-21 17:33:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ReportThread {
|
|
|
|
int id;
|
|
|
|
uptr pid;
|
|
|
|
bool running;
|
|
|
|
char *name;
|
|
|
|
int parent_tid;
|
|
|
|
ReportStack *stack;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ReportMutex {
|
|
|
|
u64 id;
|
2015-08-28 15:33:40 +00:00
|
|
|
uptr addr;
|
2014-09-21 17:33:12 +00:00
|
|
|
bool destroyed;
|
|
|
|
ReportStack *stack;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ReportDesc {
|
|
|
|
public:
|
|
|
|
ReportType typ;
|
|
|
|
Vector<ReportStack*> stacks;
|
|
|
|
Vector<ReportMop*> mops;
|
|
|
|
Vector<ReportLocation*> locs;
|
|
|
|
Vector<ReportMutex*> mutexes;
|
|
|
|
Vector<ReportThread*> threads;
|
2015-08-28 15:33:40 +00:00
|
|
|
Vector<int> unique_tids;
|
2014-09-21 17:33:12 +00:00
|
|
|
ReportStack *sleep;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
ReportDesc();
|
|
|
|
~ReportDesc();
|
|
|
|
|
|
|
|
private:
|
|
|
|
ReportDesc(const ReportDesc&);
|
|
|
|
void operator = (const ReportDesc&);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Format and output the report to the console/log. No additional logic.
|
|
|
|
void PrintReport(const ReportDesc *rep);
|
|
|
|
void PrintStack(const ReportStack *stack);
|
|
|
|
|
|
|
|
} // namespace __tsan
|
|
|
|
|
|
|
|
#endif // TSAN_REPORT_H
|