Path: blob/main/contrib/llvm-project/compiler-rt/lib/tsan/rtl/tsan_report.h
35269 views
//===-- tsan_report.h -------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file is a part of ThreadSanitizer (TSan), a race detector.9//10//===----------------------------------------------------------------------===//11#ifndef TSAN_REPORT_H12#define TSAN_REPORT_H1314#include "sanitizer_common/sanitizer_symbolizer.h"15#include "sanitizer_common/sanitizer_thread_registry.h"16#include "sanitizer_common/sanitizer_vector.h"17#include "tsan_defs.h"1819namespace __tsan {2021enum ReportType {22ReportTypeRace,23ReportTypeVptrRace,24ReportTypeUseAfterFree,25ReportTypeVptrUseAfterFree,26ReportTypeExternalRace,27ReportTypeThreadLeak,28ReportTypeMutexDestroyLocked,29ReportTypeMutexDoubleLock,30ReportTypeMutexInvalidAccess,31ReportTypeMutexBadUnlock,32ReportTypeMutexBadReadLock,33ReportTypeMutexBadReadUnlock,34ReportTypeSignalUnsafe,35ReportTypeErrnoInSignal,36ReportTypeDeadlock,37ReportTypeMutexHeldWrongContext38};3940struct ReportStack {41SymbolizedStack *frames = nullptr;42bool suppressable = false;43};4445struct ReportMopMutex {46int id;47bool write;48};4950struct ReportMop {51int tid;52uptr addr;53int size;54bool write;55bool atomic;56uptr external_tag;57Vector<ReportMopMutex> mset;58ReportStack *stack;5960ReportMop();61};6263enum ReportLocationType {64ReportLocationGlobal,65ReportLocationHeap,66ReportLocationStack,67ReportLocationTLS,68ReportLocationFD69};7071struct ReportLocation {72ReportLocationType type = ReportLocationGlobal;73DataInfo global = {};74uptr heap_chunk_start = 0;75uptr heap_chunk_size = 0;76uptr external_tag = 0;77Tid tid = kInvalidTid;78int fd = 0;79bool fd_closed = false;80bool suppressable = false;81ReportStack *stack = nullptr;82};8384struct ReportThread {85Tid id;86tid_t os_id;87bool running;88ThreadType thread_type;89char *name;90Tid parent_tid;91ReportStack *stack;92};9394struct ReportMutex {95int id;96uptr addr;97ReportStack *stack;98};99100class ReportDesc {101public:102ReportType typ;103uptr tag;104Vector<ReportStack*> stacks;105Vector<ReportMop*> mops;106Vector<ReportLocation*> locs;107Vector<ReportMutex*> mutexes;108Vector<ReportThread*> threads;109Vector<Tid> unique_tids;110ReportStack *sleep;111int count;112int signum = 0;113114ReportDesc();115~ReportDesc();116117private:118ReportDesc(const ReportDesc&);119void operator = (const ReportDesc&);120};121122// Format and output the report to the console/log. No additional logic.123void PrintReport(const ReportDesc *rep);124void PrintStack(const ReportStack *stack);125126} // namespace __tsan127128#endif // TSAN_REPORT_H129130131