summaryrefslogtreecommitdiff
path: root/libsanitizer/tsan/tsan_symbolize.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libsanitizer/tsan/tsan_symbolize.cc')
-rw-r--r--libsanitizer/tsan/tsan_symbolize.cc66
1 files changed, 61 insertions, 5 deletions
diff --git a/libsanitizer/tsan/tsan_symbolize.cc b/libsanitizer/tsan/tsan_symbolize.cc
index 65a994670b5..0c7efac7a26 100644
--- a/libsanitizer/tsan/tsan_symbolize.cc
+++ b/libsanitizer/tsan/tsan_symbolize.cc
@@ -67,16 +67,65 @@ static ReportStack *NewReportStackEntry(const AddressInfo &info) {
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) {
- if (!IsSymbolizerAvailable())
+ // 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;
static const uptr kMaxAddrFrames = 16;
InternalScopedBuffer<AddressInfo> addr_frames(kMaxAddrFrames);
for (uptr i = 0; i < kMaxAddrFrames; i++)
new(&addr_frames[i]) AddressInfo();
- uptr addr_frames_num = __sanitizer::SymbolizeCode(addr, addr_frames.data(),
- kMaxAddrFrames);
+ uptr addr_frames_num =
+ getSymbolizer()->SymbolizeCode(addr, addr_frames.data(), kMaxAddrFrames);
if (addr_frames_num == 0)
return NewReportStackEntry(addr);
ReportStack *top = 0;
@@ -95,11 +144,11 @@ ReportStack *SymbolizeCode(uptr addr) {
}
ReportLocation *SymbolizeData(uptr addr) {
- if (!IsSymbolizerAvailable())
+ if (!getSymbolizer()->IsAvailable())
return 0;
ScopedInSymbolizer in_symbolizer;
DataInfo info;
- if (!__sanitizer::SymbolizeData(addr, &info))
+ if (!getSymbolizer()->SymbolizeData(addr, &info))
return 0;
ReportLocation *ent = (ReportLocation*)internal_alloc(MBlockReportStack,
sizeof(ReportLocation));
@@ -114,4 +163,11 @@ ReportLocation *SymbolizeData(uptr addr) {
return ent;
}
+void SymbolizeFlush() {
+ if (!getSymbolizer()->IsAvailable())
+ return;
+ ScopedInSymbolizer in_symbolizer;
+ getSymbolizer()->Flush();
+}
+
} // namespace __tsan