2012-11-22 23:03:11 +01: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
|
|
|
|
|
2014-11-13 21:41:38 +01:00
|
|
|
#include "sanitizer_common/sanitizer_symbolizer.h"
|
2012-11-22 23:03:11 +01:00
|
|
|
#include "tsan_defs.h"
|
|
|
|
#include "tsan_vector.h"
|
|
|
|
|
|
|
|
namespace __tsan {
|
|
|
|
|
|
|
|
enum ReportType {
|
|
|
|
ReportTypeRace,
|
2013-11-04 22:33:31 +01:00
|
|
|
ReportTypeVptrRace,
|
2012-11-22 23:03:11 +01:00
|
|
|
ReportTypeUseAfterFree,
|
2014-11-13 21:41:38 +01:00
|
|
|
ReportTypeVptrUseAfterFree,
|
2012-11-22 23:03:11 +01:00
|
|
|
ReportTypeThreadLeak,
|
|
|
|
ReportTypeMutexDestroyLocked,
|
2014-05-22 09:09:21 +02:00
|
|
|
ReportTypeMutexDoubleLock,
|
2016-11-08 23:04:09 +01:00
|
|
|
ReportTypeMutexInvalidAccess,
|
2014-05-22 09:09:21 +02:00
|
|
|
ReportTypeMutexBadUnlock,
|
|
|
|
ReportTypeMutexBadReadLock,
|
|
|
|
ReportTypeMutexBadReadUnlock,
|
2012-11-22 23:03:11 +01:00
|
|
|
ReportTypeSignalUnsafe,
|
2014-05-22 09:09:21 +02:00
|
|
|
ReportTypeErrnoInSignal,
|
|
|
|
ReportTypeDeadlock
|
2012-11-22 23:03:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ReportStack {
|
2015-10-21 09:32:45 +02:00
|
|
|
SymbolizedStack *frames;
|
2014-09-23 19:59:53 +02:00
|
|
|
bool suppressable;
|
2015-10-21 09:32:45 +02:00
|
|
|
static ReportStack *New();
|
2014-11-13 21:41:38 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
ReportStack();
|
2012-11-22 23:03:11 +01:00
|
|
|
};
|
|
|
|
|
2013-01-10 13:44:08 +01:00
|
|
|
struct ReportMopMutex {
|
|
|
|
u64 id;
|
|
|
|
bool write;
|
|
|
|
};
|
|
|
|
|
2012-11-22 23:03:11 +01:00
|
|
|
struct ReportMop {
|
|
|
|
int tid;
|
|
|
|
uptr addr;
|
|
|
|
int size;
|
|
|
|
bool write;
|
2013-02-13 11:46:01 +01:00
|
|
|
bool atomic;
|
2013-01-10 13:44:08 +01:00
|
|
|
Vector<ReportMopMutex> mset;
|
2012-11-22 23:03:11 +01:00
|
|
|
ReportStack *stack;
|
2013-01-10 13:44:08 +01:00
|
|
|
|
|
|
|
ReportMop();
|
2012-11-22 23:03:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum ReportLocationType {
|
|
|
|
ReportLocationGlobal,
|
|
|
|
ReportLocationHeap,
|
2013-01-10 13:44:08 +01:00
|
|
|
ReportLocationStack,
|
2013-01-23 12:41:33 +01:00
|
|
|
ReportLocationTLS,
|
2013-01-10 13:44:08 +01:00
|
|
|
ReportLocationFD
|
2012-11-22 23:03:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ReportLocation {
|
|
|
|
ReportLocationType type;
|
2014-11-13 21:41:38 +01:00
|
|
|
DataInfo global;
|
|
|
|
uptr heap_chunk_start;
|
|
|
|
uptr heap_chunk_size;
|
2012-11-22 23:03:11 +01:00
|
|
|
int tid;
|
2013-01-10 13:44:08 +01:00
|
|
|
int fd;
|
2014-09-23 19:59:53 +02:00
|
|
|
bool suppressable;
|
2012-11-22 23:03:11 +01:00
|
|
|
ReportStack *stack;
|
2014-11-13 21:41:38 +01:00
|
|
|
|
|
|
|
static ReportLocation *New(ReportLocationType type);
|
|
|
|
private:
|
|
|
|
explicit ReportLocation(ReportLocationType type);
|
2012-11-22 23:03:11 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ReportThread {
|
|
|
|
int id;
|
2016-11-08 23:04:09 +01:00
|
|
|
uptr os_id;
|
2012-11-22 23:03:11 +01:00
|
|
|
bool running;
|
|
|
|
char *name;
|
2013-01-10 13:44:08 +01:00
|
|
|
int parent_tid;
|
2012-11-22 23:03:11 +01:00
|
|
|
ReportStack *stack;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ReportMutex {
|
2013-01-10 13:44:08 +01:00
|
|
|
u64 id;
|
2014-05-22 09:09:21 +02:00
|
|
|
uptr addr;
|
2013-01-10 13:44:08 +01:00
|
|
|
bool destroyed;
|
2012-11-22 23:03:11 +01:00
|
|
|
ReportStack *stack;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ReportDesc {
|
|
|
|
public:
|
|
|
|
ReportType typ;
|
|
|
|
Vector<ReportStack*> stacks;
|
|
|
|
Vector<ReportMop*> mops;
|
|
|
|
Vector<ReportLocation*> locs;
|
|
|
|
Vector<ReportMutex*> mutexes;
|
|
|
|
Vector<ReportThread*> threads;
|
2014-05-22 09:09:21 +02:00
|
|
|
Vector<int> unique_tids;
|
2012-11-22 23:03:11 +01:00
|
|
|
ReportStack *sleep;
|
2013-11-04 22:33:31 +01:00
|
|
|
int count;
|
2012-11-22 23:03:11 +01:00
|
|
|
|
|
|
|
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
|