diff options
Diffstat (limited to 'lib/tsan/go/tsan_go.cc')
-rw-r--r-- | lib/tsan/go/tsan_go.cc | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/lib/tsan/go/tsan_go.cc b/lib/tsan/go/tsan_go.cc index ea0beb742..862f5cad4 100644 --- a/lib/tsan/go/tsan_go.cc +++ b/lib/tsan/go/tsan_go.cc @@ -81,11 +81,14 @@ static ThreadState *AllocGoroutine() { return thr; } -void __tsan_init(ThreadState **thrp, void (*cb)(SymbolizeContext *cb)) { +void __tsan_init(ThreadState **thrp, + Processor **procp, + void (*cb)(SymbolizeContext *cb)) { symbolize_cb = cb; ThreadState *thr = AllocGoroutine(); main_thr = *thrp = thr; Initialize(thr); + *procp = thr->proc; inited = true; } @@ -140,24 +143,52 @@ void __tsan_func_exit(ThreadState *thr) { FuncExit(thr); } -void __tsan_malloc(void *p, uptr sz) { - if (!inited) - return; - MemoryResetRange(0, 0, (uptr)p, sz); +void __tsan_malloc(ThreadState *thr, uptr pc, uptr p, uptr sz) { + CHECK(inited); + if (thr && thr->proc) + ctx->metamap.AllocBlock(thr, pc, p, sz); + MemoryResetRange(thr, 0, p, sz); +} + +void __tsan_free(Processor *proc, uptr p, uptr sz) { + ctx->metamap.FreeRange(proc, p, sz); } void __tsan_go_start(ThreadState *parent, ThreadState **pthr, void *pc) { ThreadState *thr = AllocGoroutine(); *pthr = thr; int goid = ThreadCreate(parent, (uptr)pc, 0, true); + Processor *proc = parent->proc; + ProcUnwire(proc, parent); + ProcWire(proc, thr); ThreadStart(thr, goid, 0); + ProcUnwire(proc, thr); + ProcWire(proc, parent); } void __tsan_go_end(ThreadState *thr) { + Processor *proc = thr->proc; ThreadFinish(thr); + ProcUnwire(proc, thr); internal_free(thr); } +void __tsan_proc_create(Processor **pproc) { + *pproc = ProcCreate(); +} + +void __tsan_proc_destroy(Processor *proc) { + ProcDestroy(proc); +} + +void __tsan_proc_wire(Processor *proc, ThreadState *thr) { + ProcWire(proc, thr); +} + +void __tsan_proc_unwire(Processor *proc, ThreadState *thr) { + ProcUnwire(proc, thr); +} + void __tsan_acquire(ThreadState *thr, void *addr) { Acquire(thr, 0, (uptr)addr); } |