summaryrefslogtreecommitdiff
path: root/lib/tsan/go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2014-02-04 14:45:54 +0000
committerDmitry Vyukov <dvyukov@google.com>2014-02-04 14:45:54 +0000
commitc7ccdac3ef74a5e460c953aaffa780cd74552eca (patch)
tree24bf70df1a0976ab98c11771ae6e5d1e9aecec53 /lib/tsan/go
parente7cc26b7c5590645a485cef850f3d6d3cb47e7ba (diff)
tsan: update Go public interface
in preparation for https://codereview.appspot.com/55100044 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200766 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/go')
-rw-r--r--lib/tsan/go/test.c8
-rw-r--r--lib/tsan/go/tsan_go.cc7
2 files changed, 7 insertions, 8 deletions
diff --git a/lib/tsan/go/test.c b/lib/tsan/go/test.c
index 8bb1d32b1..45c3af797 100644
--- a/lib/tsan/go/test.c
+++ b/lib/tsan/go/test.c
@@ -13,7 +13,7 @@
#include <stdio.h>
-void __tsan_init(void **thr);
+void __tsan_init(void **thr, void (*cb)(void*));
void __tsan_fini();
void __tsan_map_shadow(void *addr, unsigned long size);
void __tsan_go_start(void *thr, void **chthr, void *pc);
@@ -27,9 +27,7 @@ void __tsan_acquire(void *thr, void *addr);
void __tsan_release(void *thr, void *addr);
void __tsan_release_merge(void *thr, void *addr);
-int __tsan_symbolize(void *pc, char **img, char **rtn, char **file, int *l) {
- return 0;
-}
+void symbolize_cb(void *ctx) {}
char buf[10];
@@ -38,7 +36,7 @@ void barfoo() {}
int main(void) {
void *thr0 = 0;
- __tsan_init(&thr0);
+ __tsan_init(&thr0, symbolize_cb);
__tsan_map_shadow(buf, sizeof(buf) + 4096);
__tsan_func_enter(thr0, (char*)&main + 1);
__tsan_malloc(thr0, buf, 10, 0);
diff --git a/lib/tsan/go/tsan_go.cc b/lib/tsan/go/tsan_go.cc
index 7c088879e..b622bbf3d 100644
--- a/lib/tsan/go/tsan_go.cc
+++ b/lib/tsan/go/tsan_go.cc
@@ -61,7 +61,7 @@ struct SymbolizeContext {
};
// Callback into Go.
-extern "C" void __tsan_symbolize(SymbolizeContext *ctx);
+static void (*symbolize_cb)(SymbolizeContext *ctx);
ReportStack *SymbolizeCode(uptr addr) {
ReportStack *s = (ReportStack*)internal_alloc(MBlockReportStack,
@@ -71,7 +71,7 @@ ReportStack *SymbolizeCode(uptr addr) {
SymbolizeContext ctx;
internal_memset(&ctx, 0, sizeof(ctx));
ctx.pc = addr;
- __tsan_symbolize(&ctx);
+ symbolize_cb(&ctx);
if (ctx.res) {
s->offset = ctx.off;
s->func = internal_strdup(ctx.func ? ctx.func : "??");
@@ -93,7 +93,8 @@ static ThreadState *AllocGoroutine() {
return thr;
}
-void __tsan_init(ThreadState **thrp) {
+void __tsan_init(ThreadState **thrp, void (*cb)(SymbolizeContext *cb)) {
+ symbolize_cb = cb;
ThreadState *thr = AllocGoroutine();
main_thr = *thrp = thr;
Initialize(thr);