forked from OSchip/llvm-project
tsan: update public Go interface
in preparation for https://codereview.appspot.com/55100044 llvm-svn: 200750
This commit is contained in:
parent
2e7dc60ee3
commit
9244c48b29
|
@ -23,7 +23,6 @@ void __tsan_write(void *thr, void *addr, void *pc);
|
||||||
void __tsan_func_enter(void *thr, void *pc);
|
void __tsan_func_enter(void *thr, void *pc);
|
||||||
void __tsan_func_exit(void *thr);
|
void __tsan_func_exit(void *thr);
|
||||||
void __tsan_malloc(void *thr, void *p, unsigned long sz, void *pc);
|
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_acquire(void *thr, void *addr);
|
||||||
void __tsan_release(void *thr, void *addr);
|
void __tsan_release(void *thr, void *addr);
|
||||||
void __tsan_release_merge(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_read(thr2, buf, (char*)&barfoo + 1);
|
||||||
__tsan_func_exit(thr2);
|
__tsan_func_exit(thr2);
|
||||||
__tsan_go_end(thr2);
|
__tsan_go_end(thr2);
|
||||||
__tsan_free(buf);
|
|
||||||
__tsan_func_exit(thr0);
|
__tsan_func_exit(thr0);
|
||||||
__tsan_fini();
|
__tsan_fini();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -51,25 +51,33 @@ void internal_free(void *p) {
|
||||||
InternalFree(p);
|
InternalFree(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct SymbolizeContext {
|
||||||
|
uptr pc;
|
||||||
|
char *func;
|
||||||
|
char *file;
|
||||||
|
uptr line;
|
||||||
|
uptr off;
|
||||||
|
uptr res;
|
||||||
|
};
|
||||||
|
|
||||||
// Callback into Go.
|
// Callback into Go.
|
||||||
extern "C" int __tsan_symbolize(uptr pc, char **func, char **file,
|
extern "C" void __tsan_symbolize(SymbolizeContext *ctx);
|
||||||
int *line, int *off);
|
|
||||||
|
|
||||||
ReportStack *SymbolizeCode(uptr addr) {
|
ReportStack *SymbolizeCode(uptr addr) {
|
||||||
ReportStack *s = (ReportStack*)internal_alloc(MBlockReportStack,
|
ReportStack *s = (ReportStack*)internal_alloc(MBlockReportStack,
|
||||||
sizeof(ReportStack));
|
sizeof(ReportStack));
|
||||||
internal_memset(s, 0, sizeof(*s));
|
internal_memset(s, 0, sizeof(*s));
|
||||||
s->pc = addr;
|
s->pc = addr;
|
||||||
char *func = 0, *file = 0;
|
SymbolizeContext ctx;
|
||||||
int line = 0, off = 0;
|
internal_memset(&ctx, 0, sizeof(ctx));
|
||||||
if (__tsan_symbolize(addr, &func, &file, &line, &off)) {
|
ctx.pc = addr;
|
||||||
s->offset = off;
|
__tsan_symbolize(&ctx);
|
||||||
s->func = internal_strdup(func ? func : "??");
|
if (ctx.res) {
|
||||||
s->file = internal_strdup(file ? file : "-");
|
s->offset = ctx.off;
|
||||||
s->line = line;
|
s->func = internal_strdup(ctx.func ? ctx.func : "??");
|
||||||
|
s->file = internal_strdup(ctx.file ? ctx.file : "-");
|
||||||
|
s->line = ctx.line;
|
||||||
s->col = 0;
|
s->col = 0;
|
||||||
free(func);
|
|
||||||
free(file);
|
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -106,22 +114,52 @@ void __tsan_read(ThreadState *thr, void *addr, void *pc) {
|
||||||
MemoryRead(thr, (uptr)pc, (uptr)addr, kSizeLog1);
|
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) {
|
void __tsan_write(ThreadState *thr, void *addr, void *pc) {
|
||||||
MemoryWrite(thr, (uptr)pc, (uptr)addr, kSizeLog1);
|
MemoryWrite(thr, (uptr)pc, (uptr)addr, kSizeLog1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __tsan_read_range(ThreadState *thr, void *addr, uptr size, uptr step,
|
void __tsan_write_pc(ThreadState *thr, void *addr, uptr callpc, uptr pc) {
|
||||||
void *pc) {
|
if (callpc != 0)
|
||||||
(void)step;
|
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);
|
MemoryAccessRange(thr, (uptr)pc, (uptr)addr, size, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __tsan_write_range(ThreadState *thr, void *addr, uptr size, uptr step,
|
void __tsan_write_range(ThreadState *thr, void *addr, uptr size, uptr pc) {
|
||||||
void *pc) {
|
|
||||||
(void)step;
|
|
||||||
MemoryAccessRange(thr, (uptr)pc, (uptr)addr, size, true);
|
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) {
|
void __tsan_func_enter(ThreadState *thr, void *pc) {
|
||||||
FuncEntry(thr, (uptr)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);
|
MemoryResetRange(thr, (uptr)pc, (uptr)p, sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __tsan_free(void *p) {
|
|
||||||
(void)p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void __tsan_go_start(ThreadState *parent, ThreadState **pthr, void *pc) {
|
void __tsan_go_start(ThreadState *parent, ThreadState **pthr, void *pc) {
|
||||||
ThreadState *thr = AllocGoroutine();
|
ThreadState *thr = AllocGoroutine();
|
||||||
*pthr = thr;
|
*pthr = thr;
|
||||||
|
|
Loading…
Reference in New Issue