diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2014-02-04 10:35:23 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2014-02-04 10:35:23 +0000 |
commit | 9244c48b2940eddbd61d10a85ee34d3d1e5ea742 (patch) | |
tree | 64dc8ea00ce9b15dce18214aef41204e6f1e76e9 /compiler-rt | |
parent | 2e7dc60ee349df0fb57fbc586f79986ccf1799e5 (diff) | |
download | bcm5719-llvm-9244c48b2940eddbd61d10a85ee34d3d1e5ea742.tar.gz bcm5719-llvm-9244c48b2940eddbd61d10a85ee34d3d1e5ea742.zip |
tsan: update public Go interface
in preparation for https://codereview.appspot.com/55100044
llvm-svn: 200750
Diffstat (limited to 'compiler-rt')
-rw-r--r-- | compiler-rt/lib/tsan/go/test.c | 2 | ||||
-rw-r--r-- | compiler-rt/lib/tsan/go/tsan_go.cc | 76 |
2 files changed, 55 insertions, 23 deletions
diff --git a/compiler-rt/lib/tsan/go/test.c b/compiler-rt/lib/tsan/go/test.c index 859b35d348e..8bb1d32b1db 100644 --- a/compiler-rt/lib/tsan/go/test.c +++ b/compiler-rt/lib/tsan/go/test.c @@ -23,7 +23,6 @@ void __tsan_write(void *thr, void *addr, void *pc); void __tsan_func_enter(void *thr, void *pc); void __tsan_func_exit(void *thr); void __tsan_malloc(void *thr, void *p, unsigned long sz, void *pc); -void __tsan_free(void *p); void __tsan_acquire(void *thr, void *addr); void __tsan_release(void *thr, void *addr); void __tsan_release_merge(void *thr, void *addr); @@ -60,7 +59,6 @@ int main(void) { __tsan_read(thr2, buf, (char*)&barfoo + 1); __tsan_func_exit(thr2); __tsan_go_end(thr2); - __tsan_free(buf); __tsan_func_exit(thr0); __tsan_fini(); return 0; diff --git a/compiler-rt/lib/tsan/go/tsan_go.cc b/compiler-rt/lib/tsan/go/tsan_go.cc index 20558b8bea1..7c088879e0e 100644 --- a/compiler-rt/lib/tsan/go/tsan_go.cc +++ b/compiler-rt/lib/tsan/go/tsan_go.cc @@ -51,25 +51,33 @@ void internal_free(void *p) { InternalFree(p); } +struct SymbolizeContext { + uptr pc; + char *func; + char *file; + uptr line; + uptr off; + uptr res; +}; + // Callback into Go. -extern "C" int __tsan_symbolize(uptr pc, char **func, char **file, - int *line, int *off); +extern "C" void __tsan_symbolize(SymbolizeContext *ctx); ReportStack *SymbolizeCode(uptr addr) { ReportStack *s = (ReportStack*)internal_alloc(MBlockReportStack, sizeof(ReportStack)); internal_memset(s, 0, sizeof(*s)); s->pc = addr; - char *func = 0, *file = 0; - int line = 0, off = 0; - if (__tsan_symbolize(addr, &func, &file, &line, &off)) { - s->offset = off; - s->func = internal_strdup(func ? func : "??"); - s->file = internal_strdup(file ? file : "-"); - s->line = line; + SymbolizeContext ctx; + internal_memset(&ctx, 0, sizeof(ctx)); + ctx.pc = addr; + __tsan_symbolize(&ctx); + if (ctx.res) { + s->offset = ctx.off; + s->func = internal_strdup(ctx.func ? ctx.func : "??"); + s->file = internal_strdup(ctx.file ? ctx.file : "-"); + s->line = ctx.line; s->col = 0; - free(func); - free(file); } return s; } @@ -106,22 +114,52 @@ void __tsan_read(ThreadState *thr, void *addr, void *pc) { MemoryRead(thr, (uptr)pc, (uptr)addr, kSizeLog1); } +void __tsan_read_pc(ThreadState *thr, void *addr, uptr callpc, uptr pc) { + if (callpc != 0) + FuncEntry(thr, callpc); + MemoryRead(thr, (uptr)pc, (uptr)addr, kSizeLog1); + if (callpc != 0) + FuncExit(thr); +} + void __tsan_write(ThreadState *thr, void *addr, void *pc) { MemoryWrite(thr, (uptr)pc, (uptr)addr, kSizeLog1); } -void __tsan_read_range(ThreadState *thr, void *addr, uptr size, uptr step, - void *pc) { - (void)step; +void __tsan_write_pc(ThreadState *thr, void *addr, uptr callpc, uptr pc) { + if (callpc != 0) + FuncEntry(thr, callpc); + MemoryWrite(thr, (uptr)pc, (uptr)addr, kSizeLog1); + if (callpc != 0) + FuncExit(thr); +} + +void __tsan_read_range(ThreadState *thr, void *addr, uptr size, uptr pc) { MemoryAccessRange(thr, (uptr)pc, (uptr)addr, size, false); } -void __tsan_write_range(ThreadState *thr, void *addr, uptr size, uptr step, - void *pc) { - (void)step; +void __tsan_write_range(ThreadState *thr, void *addr, uptr size, uptr pc) { MemoryAccessRange(thr, (uptr)pc, (uptr)addr, size, true); } +void __tsan_read_range_pc(ThreadState *thr, void *addr, uptr size, uptr callpc, + uptr pc) { + if (callpc != 0) + FuncEntry(thr, callpc); + MemoryAccessRange(thr, (uptr)pc, (uptr)addr, size, false); + if (callpc != 0) + FuncExit(thr); +} + +void __tsan_write_range_pc(ThreadState *thr, void *addr, uptr size, uptr callpc, + uptr pc) { + if (callpc != 0) + FuncEntry(thr, callpc); + MemoryAccessRange(thr, (uptr)pc, (uptr)addr, size, true); + if (callpc != 0) + FuncExit(thr); +} + void __tsan_func_enter(ThreadState *thr, void *pc) { FuncEntry(thr, (uptr)pc); } @@ -136,10 +174,6 @@ void __tsan_malloc(ThreadState *thr, void *p, uptr sz, void *pc) { MemoryResetRange(thr, (uptr)pc, (uptr)p, sz); } -void __tsan_free(void *p) { - (void)p; -} - void __tsan_go_start(ThreadState *parent, ThreadState **pthr, void *pc) { ThreadState *thr = AllocGoroutine(); *pthr = thr; |