forked from OSchip/llvm-project
[TSan] Provide default values for compile definitions.
Provide defaults for TSAN_COLLECT_STATS and TSAN_NO_HISTORY. Replace #ifdef directives with #if. This fixes a bug introduced in r229112, where building TSan runtime with -DTSAN_COLLECT_STATS=0 would still enable stats collection and reporting. llvm-svn: 229581
This commit is contained in:
parent
8c77768609
commit
e194dfa6be
|
@ -18,6 +18,15 @@
|
|||
#include "sanitizer_common/sanitizer_libc.h"
|
||||
#include "tsan_stat.h"
|
||||
|
||||
// Setup defaults for compile definitions.
|
||||
#ifndef TSAN_NO_HISTORY
|
||||
# define TSAN_NO_HISTORY 0
|
||||
#endif
|
||||
|
||||
#ifndef TSAN_COLLECT_STATS
|
||||
# define TSAN_COLLECT_STATS 0
|
||||
#endif
|
||||
|
||||
namespace __tsan {
|
||||
|
||||
#ifdef SANITIZER_GO
|
||||
|
@ -63,7 +72,7 @@ const uptr kMetaShadowCell = 8;
|
|||
// Size of a single meta shadow value (u32).
|
||||
const uptr kMetaShadowSize = 4;
|
||||
|
||||
#if defined(TSAN_NO_HISTORY) && TSAN_NO_HISTORY
|
||||
#if TSAN_NO_HISTORY
|
||||
const bool kCollectHistory = false;
|
||||
#else
|
||||
const bool kCollectHistory = true;
|
||||
|
|
|
@ -397,7 +397,7 @@ int Finalize(ThreadState *thr) {
|
|||
|
||||
failed = OnFinalize(failed);
|
||||
|
||||
#ifdef TSAN_COLLECT_STATS
|
||||
#if TSAN_COLLECT_STATS
|
||||
StatAggregate(ctx->stat, thr->stat);
|
||||
StatOutput(ctx->stat);
|
||||
#endif
|
||||
|
|
|
@ -351,7 +351,7 @@ struct ThreadState {
|
|||
Vector<JmpBuf> jmp_bufs;
|
||||
int ignore_interceptors;
|
||||
#endif
|
||||
#ifdef TSAN_COLLECT_STATS
|
||||
#if TSAN_COLLECT_STATS
|
||||
u64 stat[StatCnt];
|
||||
#endif
|
||||
const int tid;
|
||||
|
@ -543,18 +543,18 @@ void ObtainCurrentStack(ThreadState *thr, uptr toppc, StackTraceTy *stack) {
|
|||
}
|
||||
|
||||
|
||||
#ifdef TSAN_COLLECT_STATS
|
||||
#if TSAN_COLLECT_STATS
|
||||
void StatAggregate(u64 *dst, u64 *src);
|
||||
void StatOutput(u64 *stat);
|
||||
#endif
|
||||
|
||||
void ALWAYS_INLINE StatInc(ThreadState *thr, StatType typ, u64 n = 1) {
|
||||
#ifdef TSAN_COLLECT_STATS
|
||||
#if TSAN_COLLECT_STATS
|
||||
thr->stat[typ] += n;
|
||||
#endif
|
||||
}
|
||||
void ALWAYS_INLINE StatSet(ThreadState *thr, StatType typ, u64 n) {
|
||||
#ifdef TSAN_COLLECT_STATS
|
||||
#if TSAN_COLLECT_STATS
|
||||
thr->stat[typ] = n;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ void ThreadContext::OnFinished() {
|
|||
AllocatorThreadFinish(thr);
|
||||
#endif
|
||||
thr->~ThreadState();
|
||||
#ifdef TSAN_COLLECT_STATS
|
||||
#if TSAN_COLLECT_STATS
|
||||
StatAggregate(ctx->stat, thr->stat);
|
||||
#endif
|
||||
thr = 0;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
namespace __tsan {
|
||||
|
||||
#ifdef TSAN_COLLECT_STATS
|
||||
#if TSAN_COLLECT_STATS
|
||||
|
||||
void StatAggregate(u64 *dst, u64 *src) {
|
||||
for (int i = 0; i < StatCnt; i++)
|
||||
|
|
Loading…
Reference in New Issue