tsan: fix Go build

llvm-svn: 177260
This commit is contained in:
Dmitry Vyukov 2013-03-18 08:52:46 +00:00
parent f74654d274
commit 50160030e1
5 changed files with 22 additions and 17 deletions

View File

@ -34,7 +34,7 @@ enum ThreadStatus {
class ThreadContextBase {
public:
explicit ThreadContextBase(u32 tid);
virtual ~ThreadContextBase();
~ThreadContextBase();
const u32 tid; // Thread ID. Main thread should have tid = 0.
u64 unique_id; // Unique thread ID.

View File

@ -20,6 +20,7 @@ SRCS="
../../sanitizer_common/sanitizer_flags.cc
../../sanitizer_common/sanitizer_libc.cc
../../sanitizer_common/sanitizer_printf.cc
../../sanitizer_common/sanitizer_thread_registry.cc
"
if [ "`uname -a | grep Linux`" != "" ]; then
@ -60,7 +61,7 @@ for F in $SRCS; do
cat $F >> gotsan.cc
done
FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -I../../../include -m64 -Wall -Werror -fno-exceptions -DTSAN_GO -DSANITIZER_GO -DTSAN_SHADOW_COUNT=4 $OSCFLAGS"
FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -I../../../include -m64 -Wall -Werror -fno-exceptions -fno-rtti -DTSAN_GO -DSANITIZER_GO -DTSAN_SHADOW_COUNT=4 $OSCFLAGS"
if [ "$DEBUG" == "" ]; then
FLAGS+=" -DTSAN_DEBUG=0 -O3 -fomit-frame-pointer"
else

View File

@ -50,7 +50,6 @@ Context *CTX() {
static char thread_registry_placeholder[sizeof(ThreadRegistry)];
static ThreadContextBase *CreateThreadContext(u32 tid) {
StatInc(cur_thread(), StatThreadMaxTid);
// Map thread trace when context is created.
MapThreadTrace(GetThreadTrace(tid), TraceSize() * sizeof(Event));
void *mem = MmapOrDie(sizeof(ThreadContext), "ThreadContext");

View File

@ -241,6 +241,8 @@ void ScopedReport::AddMutex(const SyncVar *s) {
rep_->mutexes.PushBack(rm);
rm->id = s->uid;
rm->destroyed = false;
rm->stack = 0;
#ifndef TSAN_GO
uptr ssz = 0;
const uptr *stack = StackDepotGet(s->creation_stack_id, &ssz);
if (stack) {
@ -248,6 +250,7 @@ void ScopedReport::AddMutex(const SyncVar *s) {
trace.Init(stack, ssz);
rm->stack = SymbolizeStack(trace);
}
#endif
}
void ScopedReport::AddMutex(u64 id) {

View File

@ -48,17 +48,19 @@ struct OnCreatedArgs {
void ThreadContext::OnCreated(void *arg) {
thr = 0;
if (tid != 0) {
OnCreatedArgs *args = static_cast<OnCreatedArgs *>(arg);
args->thr->fast_state.IncrementEpoch();
// Can't increment epoch w/o writing to the trace as well.
TraceAddEvent(args->thr, args->thr->fast_state, EventTypeMop, 0);
args->thr->clock.set(args->thr->tid, args->thr->fast_state.epoch());
args->thr->fast_synch_epoch = args->thr->fast_state.epoch();
args->thr->clock.release(&sync);
StatInc(args->thr, StatSyncRelease);
creation_stack.ObtainCurrent(args->thr, args->pc);
}
if (tid == 0)
return;
OnCreatedArgs *args = static_cast<OnCreatedArgs *>(arg);
args->thr->fast_state.IncrementEpoch();
// Can't increment epoch w/o writing to the trace as well.
TraceAddEvent(args->thr, args->thr->fast_state, EventTypeMop, 0);
args->thr->clock.set(args->thr->tid, args->thr->fast_state.epoch());
args->thr->fast_synch_epoch = args->thr->fast_state.epoch();
args->thr->clock.release(&sync);
StatInc(args->thr, StatSyncRelease);
creation_stack.ObtainCurrent(args->thr, args->pc);
if (reuse_count == 0)
StatInc(args->thr, StatThreadMaxTid);
}
void ThreadContext::OnReset(void *arg) {
@ -77,11 +79,12 @@ struct OnStartedArgs {
void ThreadContext::OnStarted(void *arg) {
OnStartedArgs *args = static_cast<OnStartedArgs*>(arg);
thr = args->thr;
// RoundUp so that one trace part does not contain events
// from different threads.
epoch0 = RoundUp(epoch1 + 1, kTracePartSize);
epoch1 = (u64)-1;
new(args->thr) ThreadState(CTX(), tid, unique_id,
new(thr) ThreadState(CTX(), tid, unique_id,
epoch0, args->stk_addr, args->stk_size, args->tls_addr, args->tls_size);
#ifdef TSAN_GO
// Setup dynamic shadow stack.
@ -104,8 +107,7 @@ void ThreadContext::OnStarted(void *arg) {
StatInc(thr, StatSyncAcquire);
DPrintf("#%d: ThreadStart epoch=%zu stk_addr=%zx stk_size=%zx "
"tls_addr=%zx tls_size=%zx\n",
tid, (uptr)epoch0, args->stk_addr, args->stk_size,
args->tls_addr, args->tls_size);
tid, (uptr)epoch0, stk_addr, stk_size, tls_addr, tls_size);
thr->is_alive = true;
}