diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2012-07-06 20:23:59 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2012-07-06 20:23:59 +0000 |
commit | cb3a6b82ae406613f8870519d2acda1ee1c8f2b5 (patch) | |
tree | 75a7445877da846c4faa21092b23607581114af3 /lib/tsan/go | |
parent | c510a2f264a22ff60333fc48e5fa12d41cefba3c (diff) | |
download | compiler-rt-cb3a6b82ae406613f8870519d2acda1ee1c8f2b5.tar.gz compiler-rt-cb3a6b82ae406613f8870519d2acda1ee1c8f2b5.tar.bz2 compiler-rt-cb3a6b82ae406613f8870519d2acda1ee1c8f2b5.tar.xz |
tsan: Go language support fixes
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@159856 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/go')
-rwxr-xr-x | lib/tsan/go/buildgo.sh | 4 | ||||
-rw-r--r-- | lib/tsan/go/tsan_go.cc | 31 |
2 files changed, 18 insertions, 17 deletions
diff --git a/lib/tsan/go/buildgo.sh b/lib/tsan/go/buildgo.sh index c4cff836..36813ae3 100755 --- a/lib/tsan/go/buildgo.sh +++ b/lib/tsan/go/buildgo.sh @@ -33,9 +33,9 @@ for F in $SRCS; do cat $F >> gotsan.cc done -CFLAGS=" -I../rtl -I../.. -I../../sanitizer_common -fPIC -g -Wall -Werror -ffreestanding -fno-exceptions -DTSAN_GO -DSANITIZER_GO" +CFLAGS=" -I../rtl -I../.. -I../../sanitizer_common -fPIC -g -Wall -Werror -ffreestanding -fno-exceptions -DTSAN_GO -DSANITIZER_GO -DTSAN_SHADOW_COUNT=4" if [ "$DEBUG" == "" ]; then - CFLAGS+=" -DTSAN_DEBUG=0 -O3 -fno-omit-frame-pointer" + CFLAGS+=" -DTSAN_DEBUG=0 -O3 -fomit-frame-pointer" else CFLAGS+=" -DTSAN_DEBUG=1 -g" fi diff --git a/lib/tsan/go/tsan_go.cc b/lib/tsan/go/tsan_go.cc index 9f4df9ed..11f14dac 100644 --- a/lib/tsan/go/tsan_go.cc +++ b/lib/tsan/go/tsan_go.cc @@ -22,7 +22,7 @@ struct ThreadStatePlaceholder { uptr opaque[sizeof(ThreadState) / sizeof(uptr) + kCacheLineSize]; }; -static ThreadStatePlaceholder *threads; +static ThreadState *goroutines[kMaxTid]; void InitializeInterceptors() { } @@ -139,11 +139,15 @@ enum Tsan1EventType { LAST_EVENT // Should not appear. }; +static void AllocGoroutine(int tid) { + goroutines[tid] = (ThreadState*)internal_alloc(MBlockThreadContex, + sizeof(ThreadState)); + internal_memset(goroutines[tid], 0, sizeof(ThreadState)); +} + void __tsan_init() { - threads = (ThreadStatePlaceholder*)internal_alloc(MBlockThreadContex, - kMaxTid * sizeof(ThreadStatePlaceholder)); - //!!! internal_memset(threads, 0, kMaxTid * sizeof(ThreadStatePlaceholder)); - ThreadState *thr = (ThreadState*)&threads[0]; + AllocGoroutine(0); + ThreadState *thr = goroutines[0]; thr->in_rtl++; Initialize(thr); thr->in_rtl--; @@ -151,7 +155,7 @@ void __tsan_init() { void __tsan_fini() { // FIXME: Not necessary thread 0. - ThreadState *thr = (ThreadState*)&threads[0]; + ThreadState *thr = goroutines[0]; thr->in_rtl++; int res = Finalize(thr); thr->in_rtl--; @@ -159,9 +163,7 @@ void __tsan_fini() { } void __tsan_event(int typ, int tid, void *pc, void *addr, int info) { - //if (typ != READ && typ != WRITE && typ != SBLOCK_ENTER) - // Printf("typ=%d tid=%d pc=%p addr=%p info=%d\n", typ, tid, pc, addr, info); - ThreadState *thr = (ThreadState*)&threads[tid]; + ThreadState *thr = goroutines[tid]; switch (typ) { case READ: MemoryAccess(thr, (uptr)pc, (uptr)addr, 0, false); @@ -195,23 +197,22 @@ void __tsan_event(int typ, int tid, void *pc, void *addr, int info) { case FREE: break; case THR_START: { - //Printf("typ=%d tid=%d pc=%p addr=%p info=%d\n", typ, tid, pc, addr, info); if (tid == 0) return; - ThreadState *parent = (ThreadState*)&threads[info]; + ThreadState *parent = goroutines[info]; + AllocGoroutine(tid); + thr = goroutines[tid]; thr->in_rtl++; parent->in_rtl++; int tid2 = ThreadCreate(parent, (uptr)pc, 0, true); - CHECK_EQ(tid2, tid); ThreadStart(thr, tid2); parent->in_rtl--; thr->in_rtl--; break; } default: - thr->in_rtl++; - Printf("Event: typ=%d thr=%d\n", typ, tid); - thr->in_rtl--; + Printf("Unknown event type %d\n", typ); + Die(); } } |