[compiler-rt] r191157 - tsan: allow symbolization of non-native PCs, e.g. coming from JIT/JAVA/etc
Dmitry Vyukov
dvyukov at google.com
Sat Sep 21 17:14:58 PDT 2013
Author: dvyukov
Date: Sat Sep 21 19:14:57 2013
New Revision: 191157
URL: http://llvm.org/viewvc/llvm-project?rev=191157&view=rev
Log:
tsan: allow symbolization of non-native PCs, e.g. coming from JIT/JAVA/etc
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc?rev=191157&r1=191156&r2=191157&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize.cc Sat Sep 21 19:14:57 2013
@@ -69,7 +69,56 @@ static ReportStack *NewReportStackEntry(
return ent;
}
+
+ ReportStack *next;
+ char *module;
+ uptr offset;
+ uptr pc;
+ char *func;
+ char *file;
+ int line;
+ int col;
+
+
+// Denotes fake PC values that come from JIT/JAVA/etc.
+// For such PC values __tsan_symbolize_external() will be called.
+const uptr kExternalPCBit = 1ULL << 60;
+
+// May be overriden by JIT/JAVA/etc,
+// whatever produces PCs marked with kExternalPCBit.
+extern "C" bool __tsan_symbolize_external(uptr pc,
+ char *func_buf, uptr func_siz,
+ char *file_buf, uptr file_siz,
+ int *line, int *col)
+ SANITIZER_WEAK_ATTRIBUTE;
+
+bool __tsan_symbolize_external(uptr pc,
+ char *func_buf, uptr func_siz,
+ char *file_buf, uptr file_siz,
+ int *line, int *col) {
+ return false;
+}
+
ReportStack *SymbolizeCode(uptr addr) {
+ // Check if PC comes from non-native land.
+ if (addr & kExternalPCBit) {
+ // Declare static to not consume too much stack space.
+ // We symbolize reports in a single thread, so this is fine.
+ static char func_buf[1024];
+ static char file_buf[1024];
+ int line, col;
+ if (!__tsan_symbolize_external(addr, func_buf, sizeof(func_buf),
+ file_buf, sizeof(file_buf), &line, &col))
+ return NewReportStackEntry(addr);
+ ReportStack *ent = NewReportStackEntry(addr);
+ ent->module = 0;
+ ent->offset = 0;
+ ent->func = internal_strdup(func_buf);
+ ent->file = internal_strdup(file_buf);
+ ent->line = line;
+ ent->col = col;
+ return ent;
+ }
if (!getSymbolizer()->IsAvailable())
return SymbolizeCodeAddr2Line(addr);
ScopedInSymbolizer in_symbolizer;
More information about the llvm-commits
mailing list