[llvm-commits] [compiler-rt] r159827 - in /compiler-rt/trunk/lib/tsan: go/buildgo.sh go/tsan_go.cc rtl/tsan_report.cc rtl/tsan_rtl_report.cc
Dmitry Vyukov
dvyukov at google.com
Fri Jul 6 07:54:26 PDT 2012
Author: dvyukov
Date: Fri Jul 6 09:54:25 2012
New Revision: 159827
URL: http://llvm.org/viewvc/llvm-project?rev=159827&view=rev
Log:
tsan: Go lang: symbolize stack traces
Modified:
compiler-rt/trunk/lib/tsan/go/buildgo.sh
compiler-rt/trunk/lib/tsan/go/tsan_go.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
Modified: compiler-rt/trunk/lib/tsan/go/buildgo.sh
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/go/buildgo.sh?rev=159827&r1=159826&r2=159827&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/buildgo.sh (original)
+++ compiler-rt/trunk/lib/tsan/go/buildgo.sh Fri Jul 6 09:54:25 2012
@@ -16,7 +16,6 @@
../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 @@
echo as gotsan.s -o gotsan.syso
as gotsan.s -o gotsan.syso
+gcc test.c gotsan.syso -lpthread -o test
+./test
+
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=159827&r1=159826&r2=159827&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/tsan_go.cc (original)
+++ compiler-rt/trunk/lib/tsan/go/tsan_go.cc Fri Jul 6 09:54:25 2012
@@ -37,14 +37,40 @@
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);
}
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc?rev=159827&r1=159826&r2=159827&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc Fri Jul 6 09:54:25 2012
@@ -27,6 +27,8 @@
ReportDesc::~ReportDesc() {
}
+#ifndef TSAN_GO
+
static void PrintHeader(ReportType typ) {
TsanPrintf("WARNING: ThreadSanitizer: ");
@@ -125,4 +127,31 @@
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
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc?rev=159827&r1=159826&r2=159827&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc Fri Jul 6 09:54:25 2012
@@ -43,6 +43,7 @@
}
static void StackStripMain(ReportStack *stack) {
+#ifndef TSAN_GO
ReportStack *last_frame = 0;
ReportStack *last_frame2 = 0;
const char *prefix = "__interceptor_";
@@ -82,6 +83,7 @@
// due to our fault.
TsanPrintf("Bottom stack frame of stack %zx is missed\n", stack->pc);
}
+#endif
}
static ReportStack *SymbolizeStack(const StackTrace& trace) {
More information about the llvm-commits
mailing list