forked from OSchip/llvm-project
parent
c65aa3f6ae
commit
e0d31e9170
|
@ -16,7 +16,6 @@ SRCS="
|
|||
../rtl/tsan_rtl_thread.cc
|
||||
../rtl/tsan_stat.cc
|
||||
../rtl/tsan_suppressions.cc
|
||||
../rtl/tsan_symbolize.cc
|
||||
../rtl/tsan_sync.cc
|
||||
../../sanitizer_common/sanitizer_allocator.cc
|
||||
../../sanitizer_common/sanitizer_common.cc
|
||||
|
@ -47,3 +46,6 @@ cat tmp.s $ASMS > gotsan.s
|
|||
echo as gotsan.s -o gotsan.syso
|
||||
as gotsan.s -o gotsan.syso
|
||||
|
||||
gcc test.c gotsan.syso -lpthread -o test
|
||||
./test
|
||||
|
||||
|
|
|
@ -37,14 +37,40 @@ bool IsExpectedReport(uptr addr, uptr size) {
|
|||
void internal_start_thread(void(*func)(void*), void *arg) {
|
||||
}
|
||||
|
||||
ReportStack *SymbolizeCodeAddr2Line(uptr addr) {
|
||||
return NewReportStackEntry(addr);
|
||||
extern "C" int goCallbackCommentPc(uptr pc, char **img, char **rtn,
|
||||
char **filename, int *lineno);
|
||||
extern "C" void __libc_free(void *p);
|
||||
|
||||
ReportStack *SymbolizeCode(uptr addr) {
|
||||
ReportStack *s = NewReportStackEntry(addr);
|
||||
char *img, *rtn, *filename;
|
||||
int lineno;
|
||||
if (goCallbackCommentPc(addr, &img, &rtn, &filename, &lineno)) {
|
||||
s->module = internal_strdup(img);
|
||||
s->offset = addr;
|
||||
s->func = internal_strdup(rtn);
|
||||
s->file = internal_strdup(filename);
|
||||
s->line = lineno;
|
||||
s->col = 0;
|
||||
__libc_free(img);
|
||||
__libc_free(rtn);
|
||||
__libc_free(filename);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
ReportStack *SymbolizeDataAddr2Line(uptr addr) {
|
||||
ReportStack *SymbolizeData(uptr addr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ReportStack *NewReportStackEntry(uptr addr) {
|
||||
ReportStack *ent = (ReportStack*)internal_alloc(MBlockReportStack,
|
||||
sizeof(ReportStack));
|
||||
internal_memset(ent, 0, sizeof(*ent));
|
||||
ent->pc = addr;
|
||||
return ent;
|
||||
}
|
||||
|
||||
void *internal_alloc(MBlockType typ, uptr sz) {
|
||||
return InternalAlloc(sz);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ ReportDesc::ReportDesc()
|
|||
ReportDesc::~ReportDesc() {
|
||||
}
|
||||
|
||||
#ifndef TSAN_GO
|
||||
|
||||
static void PrintHeader(ReportType typ) {
|
||||
TsanPrintf("WARNING: ThreadSanitizer: ");
|
||||
|
||||
|
@ -125,4 +127,31 @@ void PrintReport(const ReportDesc *rep) {
|
|||
TsanPrintf("==================\n");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void PrintStack(const ReportStack *ent) {
|
||||
for (int i = 0; ent; ent = ent->next, i++) {
|
||||
TsanPrintf(" %s()\n %s:%d +%p\n",
|
||||
ent->func, ent->file, ent->line, (void*)ent->pc);
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintMop(const ReportMop *mop, bool first) {
|
||||
TsanPrintf("%s by goroutine %d:\n",
|
||||
(first ? (mop->write ? "Write" : "Read")
|
||||
: (mop->write ? "Previous write" : "Previous read")),
|
||||
mop->tid);
|
||||
PrintStack(mop->stack);
|
||||
}
|
||||
|
||||
void PrintReport(const ReportDesc *rep) {
|
||||
TsanPrintf("==================\n");
|
||||
TsanPrintf("WARNING: DATA RACE at %p\n", (void*)rep->mops[0]->addr);
|
||||
for (uptr i = 0; i < rep->mops.Size(); i++)
|
||||
PrintMop(rep->mops[i], i == 0);
|
||||
TsanPrintf("==================\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace __tsan
|
||||
|
|
|
@ -43,6 +43,7 @@ bool WEAK OnReport(const ReportDesc *rep, bool suppressed) {
|
|||
}
|
||||
|
||||
static void StackStripMain(ReportStack *stack) {
|
||||
#ifndef TSAN_GO
|
||||
ReportStack *last_frame = 0;
|
||||
ReportStack *last_frame2 = 0;
|
||||
const char *prefix = "__interceptor_";
|
||||
|
@ -82,6 +83,7 @@ static void StackStripMain(ReportStack *stack) {
|
|||
// due to our fault.
|
||||
TsanPrintf("Bottom stack frame of stack %zx is missed\n", stack->pc);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static ReportStack *SymbolizeStack(const StackTrace& trace) {
|
||||
|
|
Loading…
Reference in New Issue