2012-05-10 21:48:04 +08:00
|
|
|
//===-- tsan_report.h -------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// 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-05 04:52:37 +08:00
|
|
|
#include "sanitizer_common/sanitizer_symbolizer.h"
|
2017-12-04 20:30:09 +08:00
|
|
|
#include "sanitizer_common/sanitizer_vector.h"
|
2012-05-10 21:48:04 +08:00
|
|
|
#include "tsan_defs.h"
|
|
|
|
|
|
|
|
namespace __tsan {
|
|
|
|
|
|
|
|
enum ReportType {
|
|
|
|
ReportTypeRace,
|
2013-03-21 23:37:39 +08:00
|
|
|
ReportTypeVptrRace,
|
2012-05-17 22:17:51 +08:00
|
|
|
ReportTypeUseAfterFree,
|
2014-10-13 16:46:25 +08:00
|
|
|
ReportTypeVptrUseAfterFree,
|
2017-02-02 21:17:05 +08:00
|
|
|
ReportTypeExternalRace,
|
2012-05-10 21:48:04 +08:00
|
|
|
ReportTypeThreadLeak,
|
|
|
|
ReportTypeMutexDestroyLocked,
|
2014-04-25 15:42:55 +08:00
|
|
|
ReportTypeMutexDoubleLock,
|
2016-03-16 23:39:20 +08:00
|
|
|
ReportTypeMutexInvalidAccess,
|
2014-04-25 15:55:11 +08:00
|
|
|
ReportTypeMutexBadUnlock,
|
2014-04-25 16:58:23 +08:00
|
|
|
ReportTypeMutexBadReadLock,
|
2014-04-25 16:21:30 +08:00
|
|
|
ReportTypeMutexBadReadUnlock,
|
2012-05-10 21:48:04 +08:00
|
|
|
ReportTypeSignalUnsafe,
|
2014-02-19 22:17:25 +08:00
|
|
|
ReportTypeErrnoInSignal,
|
|
|
|
ReportTypeDeadlock
|
2012-05-10 21:48:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ReportStack {
|
2014-12-03 03:48:40 +08:00
|
|
|
SymbolizedStack *frames;
|
2014-05-29 02:03:32 +08:00
|
|
|
bool suppressable;
|
2014-12-03 03:48:40 +08:00
|
|
|
static ReportStack *New();
|
2014-11-05 04:52:37 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
ReportStack();
|
2012-05-10 21:48:04 +08:00
|
|
|
};
|
|
|
|
|
2012-12-06 20:16:15 +08:00
|
|
|
struct ReportMopMutex {
|
|
|
|
u64 id;
|
|
|
|
bool write;
|
|
|
|
};
|
|
|
|
|
2012-05-10 21:48:04 +08:00
|
|
|
struct ReportMop {
|
|
|
|
int tid;
|
|
|
|
uptr addr;
|
|
|
|
int size;
|
|
|
|
bool write;
|
2013-02-01 19:10:53 +08:00
|
|
|
bool atomic;
|
2017-02-02 21:17:05 +08:00
|
|
|
uptr external_tag;
|
2012-12-06 20:16:15 +08:00
|
|
|
Vector<ReportMopMutex> mset;
|
2012-05-10 21:48:04 +08:00
|
|
|
ReportStack *stack;
|
2012-12-06 20:16:15 +08:00
|
|
|
|
|
|
|
ReportMop();
|
2012-05-10 21:48:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum ReportLocationType {
|
|
|
|
ReportLocationGlobal,
|
|
|
|
ReportLocationHeap,
|
2012-12-18 14:57:34 +08:00
|
|
|
ReportLocationStack,
|
2013-01-14 18:00:03 +08:00
|
|
|
ReportLocationTLS,
|
2012-12-18 14:57:34 +08:00
|
|
|
ReportLocationFD
|
2012-05-10 21:48:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ReportLocation {
|
|
|
|
ReportLocationType type;
|
2014-11-05 06:07:57 +08:00
|
|
|
DataInfo global;
|
|
|
|
uptr heap_chunk_start;
|
|
|
|
uptr heap_chunk_size;
|
2017-02-02 21:17:05 +08:00
|
|
|
uptr external_tag;
|
2012-05-10 21:48:04 +08:00
|
|
|
int tid;
|
2012-12-18 14:57:34 +08:00
|
|
|
int fd;
|
2014-05-29 02:03:32 +08:00
|
|
|
bool suppressable;
|
2012-05-10 21:48:04 +08:00
|
|
|
ReportStack *stack;
|
2014-11-05 06:07:57 +08:00
|
|
|
|
|
|
|
static ReportLocation *New(ReportLocationType type);
|
|
|
|
private:
|
|
|
|
explicit ReportLocation(ReportLocationType type);
|
2012-05-10 21:48:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ReportThread {
|
|
|
|
int id;
|
2017-04-18 02:17:38 +08:00
|
|
|
tid_t os_id;
|
2012-05-10 21:48:04 +08:00
|
|
|
bool running;
|
2017-02-02 20:54:21 +08:00
|
|
|
bool workerthread;
|
2012-05-10 21:48:04 +08:00
|
|
|
char *name;
|
2017-02-02 20:54:21 +08:00
|
|
|
u32 parent_tid;
|
2012-05-10 21:48:04 +08:00
|
|
|
ReportStack *stack;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ReportMutex {
|
2012-12-06 20:16:15 +08:00
|
|
|
u64 id;
|
2014-02-19 22:17:25 +08:00
|
|
|
uptr addr;
|
2012-12-06 20:16:15 +08:00
|
|
|
bool destroyed;
|
2012-05-10 21:48:04 +08:00
|
|
|
ReportStack *stack;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ReportDesc {
|
|
|
|
public:
|
|
|
|
ReportType typ;
|
2017-05-04 00:51:01 +08:00
|
|
|
uptr tag;
|
2012-05-10 21:48:04 +08:00
|
|
|
Vector<ReportStack*> stacks;
|
|
|
|
Vector<ReportMop*> mops;
|
|
|
|
Vector<ReportLocation*> locs;
|
|
|
|
Vector<ReportMutex*> mutexes;
|
|
|
|
Vector<ReportThread*> threads;
|
2014-03-21 21:00:18 +08:00
|
|
|
Vector<int> unique_tids;
|
2012-09-01 01:27:49 +08:00
|
|
|
ReportStack *sleep;
|
2013-03-22 00:55:17 +08:00
|
|
|
int count;
|
2012-05-10 21:48:04 +08: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);
|
2012-09-01 20:13:18 +08:00
|
|
|
void PrintStack(const ReportStack *stack);
|
2012-05-10 21:48:04 +08:00
|
|
|
|
|
|
|
} // namespace __tsan
|
|
|
|
|
|
|
|
#endif // TSAN_REPORT_H
|