diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2013-01-14 10:00:03 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2013-01-14 10:00:03 +0000 |
commit | fb917e9069ea44f7103f50c658be84a8f66de56c (patch) | |
tree | fc4a26b3efdd229c89faa8f62bb415d1357a0ebc /lib/tsan/rtl/tsan_rtl_report.cc | |
parent | 1b2f0306ef6cac2a4c42a80b467a92e9e62b3e5a (diff) | |
download | compiler-rt-fb917e9069ea44f7103f50c658be84a8f66de56c.tar.gz compiler-rt-fb917e9069ea44f7103f50c658be84a8f66de56c.tar.bz2 compiler-rt-fb917e9069ea44f7103f50c658be84a8f66de56c.tar.xz |
tsan: describe stack and TLS addresses
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@172393 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/rtl/tsan_rtl_report.cc')
-rw-r--r-- | lib/tsan/rtl/tsan_rtl_report.cc | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/lib/tsan/rtl/tsan_rtl_report.cc b/lib/tsan/rtl/tsan_rtl_report.cc index b7b3b4a5..1a780e4b 100644 --- a/lib/tsan/rtl/tsan_rtl_report.cc +++ b/lib/tsan/rtl/tsan_rtl_report.cc @@ -121,6 +121,7 @@ static ReportStack *SymbolizeStack(const StackTrace& trace) { ScopedReport::ScopedReport(ReportType typ) { ctx_ = CTX(); + ctx_->thread_mtx.CheckLocked(); void *mem = internal_alloc(MBlockReport, sizeof(ReportDesc)); rep_ = new(mem) ReportDesc; rep_->typ = typ; @@ -187,15 +188,37 @@ void ScopedReport::AddThread(const ThreadContext *tctx) { #ifndef TSAN_GO static ThreadContext *FindThread(int unique_id) { - CTX()->thread_mtx.CheckLocked(); + Context *ctx = CTX(); + ctx->thread_mtx.CheckLocked(); for (unsigned i = 0; i < kMaxTid; i++) { - ThreadContext *tctx = CTX()->threads[i]; + ThreadContext *tctx = ctx->threads[i]; if (tctx && tctx->unique_id == unique_id) { return tctx; } } return 0; } + +ThreadContext *IsThreadStackOrTls(uptr addr, bool *is_stack) { + Context *ctx = CTX(); + ctx->thread_mtx.CheckLocked(); + for (unsigned i = 0; i < kMaxTid; i++) { + ThreadContext *tctx = ctx->threads[i]; + if (tctx == 0 || tctx->status != ThreadStatusRunning) + continue; + ThreadState *thr = tctx->thr; + CHECK(thr); + if (addr >= thr->stk_addr && addr < thr->stk_addr + thr->stk_size) { + *is_stack = true; + return tctx; + } + if (addr >= thr->tls_addr && addr < thr->tls_addr + thr->tls_size) { + *is_stack = false; + return tctx; + } + } + return 0; +} #endif void ScopedReport::AddMutex(const SyncVar *s) { @@ -276,12 +299,21 @@ void ScopedReport::AddLocation(uptr addr, uptr size) { AddThread(tctx); return; } -#endif + bool is_stack = false; + if (ThreadContext *tctx = IsThreadStackOrTls(addr, &is_stack)) { + void *mem = internal_alloc(MBlockReportLoc, sizeof(ReportLocation)); + ReportLocation *loc = new(mem) ReportLocation(); + rep_->locs.PushBack(loc); + loc->type = is_stack ? ReportLocationStack : ReportLocationTLS; + loc->tid = tctx->tid; + AddThread(tctx); + } ReportLocation *loc = SymbolizeData(addr); if (loc) { rep_->locs.PushBack(loc); return; } +#endif } #ifndef TSAN_GO |