Retro68/gcc/libsanitizer/tsan/tsan_report.h

134 lines
2.6 KiB
C
Raw Normal View History

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,
2018-12-28 15:30:48 +00:00
ReportTypeExternalRace,
2014-09-21 17:33:12 +00:00
ReportTypeThreadLeak,
ReportTypeMutexDestroyLocked,
2015-08-28 15:33:40 +00:00
ReportTypeMutexDoubleLock,
ReportTypeMutexInvalidAccess,
2015-08-28 15:33:40 +00:00
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;
2018-12-28 15:30:48 +00:00
uptr external_tag;
2014-09-21 17:33:12 +00:00
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;
2018-12-28 15:30:48 +00:00
uptr external_tag;
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;
2018-12-28 15:30:48 +00:00
tid_t os_id;
2014-09-21 17:33:12 +00:00
bool running;
2018-12-28 15:30:48 +00:00
bool workerthread;
2014-09-21 17:33:12 +00:00
char *name;
2018-12-28 15:30:48 +00:00
u32 parent_tid;
2014-09-21 17:33:12 +00:00
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;
2018-12-28 15:30:48 +00:00
uptr tag;
2014-09-21 17:33:12 +00:00
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