summaryrefslogtreecommitdiff
path: root/lib/tsan/rtl/tsan_rtl_report.cc
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-03-15 13:48:44 +0000
committerAlexey Samsonov <samsonov@google.com>2013-03-15 13:48:44 +0000
commit2bbd8bec77c2fdb41c5f5b6cb0d83d22bc576650 (patch)
tree3ed39be4d91c1318cf22e4d06e1b256b5227b08e /lib/tsan/rtl/tsan_rtl_report.cc
parenta82ca9142c30be8255f5a4dfa596df9304b20dbd (diff)
downloadcompiler-rt-2bbd8bec77c2fdb41c5f5b6cb0d83d22bc576650.tar.gz
compiler-rt-2bbd8bec77c2fdb41c5f5b6cb0d83d22bc576650.tar.bz2
compiler-rt-2bbd8bec77c2fdb41c5f5b6cb0d83d22bc576650.tar.xz
[TSan] Switch TSan runtime to use ThreadRegistry class from sanitizer_common
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177154 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/rtl/tsan_rtl_report.cc')
-rw-r--r--lib/tsan/rtl/tsan_rtl_report.cc34
1 files changed, 20 insertions, 14 deletions
diff --git a/lib/tsan/rtl/tsan_rtl_report.cc b/lib/tsan/rtl/tsan_rtl_report.cc
index de9a0e94..69fd16bb 100644
--- a/lib/tsan/rtl/tsan_rtl_report.cc
+++ b/lib/tsan/rtl/tsan_rtl_report.cc
@@ -125,7 +125,7 @@ static ReportStack *SymbolizeStack(const StackTrace& trace) {
ScopedReport::ScopedReport(ReportType typ) {
ctx_ = CTX();
- ctx_->thread_mtx.CheckLocked();
+ ctx_->thread_registry->CheckLocked();
void *mem = internal_alloc(MBlockReport, sizeof(ReportDesc));
rep_ = new(mem) ReportDesc;
rep_->typ = typ;
@@ -177,7 +177,7 @@ void ScopedReport::AddMemoryAccess(uptr addr, Shadow s,
void ScopedReport::AddThread(const ThreadContext *tctx) {
for (uptr i = 0; i < rep_->threads.Size(); i++) {
- if (rep_->threads[i]->id == tctx->tid)
+ if ((u32)rep_->threads[i]->id == tctx->tid)
return;
}
void *mem = internal_alloc(MBlockReportThread, sizeof(ReportThread));
@@ -187,17 +187,18 @@ void ScopedReport::AddThread(const ThreadContext *tctx) {
rt->pid = tctx->os_id;
rt->running = (tctx->status == ThreadStatusRunning);
rt->name = tctx->name ? internal_strdup(tctx->name) : 0;
- rt->parent_tid = tctx->creation_tid;
+ rt->parent_tid = tctx->parent_tid;
rt->stack = SymbolizeStack(tctx->creation_stack);
}
#ifndef TSAN_GO
-static ThreadContext *FindThread(int unique_id) {
+static ThreadContext *FindThreadLocked(int unique_id) {
Context *ctx = CTX();
- ctx->thread_mtx.CheckLocked();
+ ctx->thread_registry->CheckLocked();
for (unsigned i = 0; i < kMaxTid; i++) {
- ThreadContext *tctx = ctx->threads[i];
- if (tctx && tctx->unique_id == unique_id) {
+ ThreadContext *tctx = static_cast<ThreadContext*>(
+ ctx->thread_registry->GetThreadLocked(i));
+ if (tctx && tctx->unique_id == (u32)unique_id) {
return tctx;
}
}
@@ -206,9 +207,10 @@ static ThreadContext *FindThread(int unique_id) {
ThreadContext *IsThreadStackOrTls(uptr addr, bool *is_stack) {
Context *ctx = CTX();
- ctx->thread_mtx.CheckLocked();
+ ctx->thread_registry->CheckLocked();
for (unsigned i = 0; i < kMaxTid; i++) {
- ThreadContext *tctx = ctx->threads[i];
+ ThreadContext *tctx = static_cast<ThreadContext*>(
+ ctx->thread_registry->GetThreadLocked(i));
if (tctx == 0 || tctx->status != ThreadStatusRunning)
continue;
ThreadState *thr = tctx->thr;
@@ -274,14 +276,14 @@ void ScopedReport::AddLocation(uptr addr, uptr size) {
trace.Init(stack, ssz);
loc->stack = SymbolizeStack(trace);
}
- ThreadContext *tctx = FindThread(creat_tid);
+ ThreadContext *tctx = FindThreadLocked(creat_tid);
if (tctx)
AddThread(tctx);
return;
}
if (allocator()->PointerIsMine((void*)addr)) {
MBlock *b = user_mblock(0, (void*)addr);
- ThreadContext *tctx = FindThread(b->alloc_tid);
+ ThreadContext *tctx = FindThreadLocked(b->alloc_tid);
void *mem = internal_alloc(MBlockReportLoc, sizeof(ReportLocation));
ReportLocation *loc = new(mem) ReportLocation();
rep_->locs.PushBack(loc);
@@ -341,7 +343,10 @@ void RestoreStack(int tid, const u64 epoch, StackTrace *stk, MutexSet *mset) {
// This function restores stack trace and mutex set for the thread/epoch.
// It does so by getting stack trace and mutex set at the beginning of
// trace part, and then replaying the trace till the given epoch.
- ThreadContext *tctx = CTX()->threads[tid];
+ Context *ctx = CTX();
+ ctx->thread_registry->CheckLocked();
+ ThreadContext *tctx = static_cast<ThreadContext*>(
+ ctx->thread_registry->GetThreadLocked(tid));
if (tctx == 0)
return;
Trace* trace = 0;
@@ -585,7 +590,7 @@ void ReportRace(ThreadState *thr) {
}
Context *ctx = CTX();
- Lock l0(&ctx->thread_mtx);
+ ThreadRegistryLock l0(ctx->thread_registry);
ScopedReport rep(freed ? ReportTypeUseAfterFree : ReportTypeRace);
const uptr kMop = 2;
@@ -613,7 +618,8 @@ void ReportRace(ThreadState *thr) {
for (uptr i = 0; i < kMop; i++) {
FastState s(thr->racy_state[i]);
- ThreadContext *tctx = ctx->threads[s.tid()];
+ ThreadContext *tctx = static_cast<ThreadContext*>(
+ ctx->thread_registry->GetThreadLocked(s.tid()));
if (s.epoch() < tctx->epoch0 || s.epoch() > tctx->epoch1)
continue;
rep.AddThread(tctx);