[compiler-rt] r200750 - tsan: update public Go interface
Dmitry Vyukov
dvyukov at google.com
Tue Feb 4 02:35:24 PST 2014
Author: dvyukov
Date: Tue Feb 4 04:35:23 2014
New Revision: 200750
URL: http://llvm.org/viewvc/llvm-project?rev=200750&view=rev
Log:
tsan: update public Go interface
in preparation for https://codereview.appspot.com/55100044
Modified:
compiler-rt/trunk/lib/tsan/go/test.c
compiler-rt/trunk/lib/tsan/go/tsan_go.cc
Modified: compiler-rt/trunk/lib/tsan/go/test.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/go/test.c?rev=200750&r1=200749&r2=200750&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/test.c (original)
+++ compiler-rt/trunk/lib/tsan/go/test.c Tue Feb 4 04:35:23 2014
@@ -23,7 +23,6 @@ void __tsan_write(void *thr, void *addr,
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;
Modified: compiler-rt/trunk/lib/tsan/go/tsan_go.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/go/tsan_go.cc?rev=200750&r1=200749&r2=200750&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/tsan_go.cc (original)
+++ compiler-rt/trunk/lib/tsan/go/tsan_go.cc Tue Feb 4 04:35:23 2014
@@ -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
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, voi
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;
More information about the llvm-commits
mailing list