[llvm-commits] [compiler-rt] r164998 - in /compiler-rt/trunk/lib: sanitizer_common/sanitizer_common.h sanitizer_common/sanitizer_posix.cc tsan/go/tsan_go.cc tsan/lit_tests/race_on_heap.cc tsan/lit_tests/race_with_finished_thread.cc tsan/lit_tests/simple_stack.c tsan/rtl/tsan_interceptors.cc tsan/rtl/tsan_report.cc tsan/rtl/tsan_report.h tsan/rtl/tsan_rtl.cc tsan/rtl/tsan_rtl.h tsan/rtl/tsan_rtl_report.cc tsan/rtl/tsan_rtl_thread.cc
Dmitry Vyukov
dvyukov at google.com
Tue Oct 2 04:52:05 PDT 2012
Author: dvyukov
Date: Tue Oct 2 06:52:05 2012
New Revision: 164998
URL: http://llvm.org/viewvc/llvm-project?rev=164998&view=rev
Log:
tsan: output tid's in reports
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
compiler-rt/trunk/lib/tsan/go/tsan_go.cc
compiler-rt/trunk/lib/tsan/lit_tests/race_on_heap.cc
compiler-rt/trunk/lib/tsan/lit_tests/race_with_finished_thread.cc
compiler-rt/trunk/lib/tsan/lit_tests/simple_stack.c
compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_report.h
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=164998&r1=164997&r2=164998&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Tue Oct 2 06:52:05 2012
@@ -34,6 +34,7 @@
// Threads
int GetPid();
+int GetTid();
uptr GetThreadSelf();
void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top,
uptr *stack_bottom);
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc?rev=164998&r1=164997&r2=164998&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc Tue Oct 2 06:52:05 2012
@@ -27,6 +27,7 @@
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/types.h>
+#include <syscall.h>
#include <unistd.h>
namespace __sanitizer {
@@ -37,6 +38,10 @@
return getpid();
}
+int GetTid() {
+ return syscall(__NR_gettid);
+}
+
uptr GetThreadSelf() {
return (uptr)pthread_self();
}
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=164998&r1=164997&r2=164998&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/tsan_go.cc (original)
+++ compiler-rt/trunk/lib/tsan/go/tsan_go.cc Tue Oct 2 06:52:05 2012
@@ -149,7 +149,7 @@
thr->in_rtl++;
parent->in_rtl++;
int goid2 = ThreadCreate(parent, (uptr)pc, 0, true);
- ThreadStart(thr, goid2);
+ ThreadStart(thr, goid2, 0);
parent->in_rtl--;
thr->in_rtl--;
}
Modified: compiler-rt/trunk/lib/tsan/lit_tests/race_on_heap.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/lit_tests/race_on_heap.cc?rev=164998&r1=164997&r2=164998&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/lit_tests/race_on_heap.cc (original)
+++ compiler-rt/trunk/lib/tsan/lit_tests/race_on_heap.cc Tue Oct 2 06:52:05 2012
@@ -42,6 +42,6 @@
// CHECK: #1 alloc
// CHECK: #2 AllocThread
// ...
-// CHECK: Thread 1 (finished) created at:
+// CHECK: Thread 1 (tid={{.*}}, finished) created at:
// CHECK: #0 pthread_create
// CHECK: #1 main
Modified: compiler-rt/trunk/lib/tsan/lit_tests/race_with_finished_thread.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/lit_tests/race_with_finished_thread.cc?rev=164998&r1=164997&r2=164998&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/lit_tests/race_with_finished_thread.cc (original)
+++ compiler-rt/trunk/lib/tsan/lit_tests/race_with_finished_thread.cc Tue Oct 2 06:52:05 2012
@@ -38,6 +38,6 @@
// CHECK: Previous write of size 4 at {{.*}} by thread 1:
// CHECK: #0 foobar
// CHECK: #1 Thread1
-// CHECK: Thread 1 (finished) created at:
+// CHECK: Thread 1 (tid={{.*}}, finished) created at:
// CHECK: #0 pthread_create
// CHECK: #1 main
Modified: compiler-rt/trunk/lib/tsan/lit_tests/simple_stack.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/lit_tests/simple_stack.c?rev=164998&r1=164997&r2=164998&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/lit_tests/simple_stack.c (original)
+++ compiler-rt/trunk/lib/tsan/lit_tests/simple_stack.c Tue Oct 2 06:52:05 2012
@@ -56,7 +56,7 @@
// CHECK-NEXT: #0 foo2{{.*}} {{.*}}simple_stack.c:18{{(:26)?}} ({{.*}})
// CHECK-NEXT: #1 bar2{{.*}} {{.*}}simple_stack.c:23{{(:3)?}} ({{.*}})
// CHECK-NEXT: #2 Thread2{{.*}} {{.*}}simple_stack.c:33{{(:3)?}} ({{.*}})
-// CHECK: Thread 1 (running) created at:
+// CHECK: Thread 1 (tid={{.*}}, running) created at:
// CHECK-NEXT: #0 pthread_create {{.*}} ({{.*}})
// CHECK-NEXT: #1 StartThread{{.*}} {{.*}}simple_stack.c:38{{(:3)?}} ({{.*}})
// CHECK-NEXT: #2 main{{.*}} {{.*}}simple_stack.c:43{{(:3)?}} ({{.*}})
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=164998&r1=164997&r2=164998&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Tue Oct 2 06:52:05 2012
@@ -629,7 +629,7 @@
while ((tid = atomic_load(&p->tid, memory_order_acquire)) == 0)
pthread_yield();
atomic_store(&p->tid, 0, memory_order_release);
- ThreadStart(thr, tid);
+ ThreadStart(thr, tid, GetTid());
CHECK_EQ(thr->in_rtl, 1);
}
void *res = callback(param);
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=164998&r1=164997&r2=164998&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_report.cc Tue Oct 2 06:52:05 2012
@@ -104,7 +104,7 @@
TsanPrintf(" Thread %d", rt->id);
if (rt->name)
TsanPrintf(" '%s'", rt->name);
- TsanPrintf(" (%s)", rt->running ? "running" : "finished");
+ TsanPrintf(" (tid=%d, %s)", rt->pid, rt->running ? "running" : "finished");
if (rt->stack)
TsanPrintf(" created at:");
TsanPrintf("\n");
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_report.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_report.h?rev=164998&r1=164997&r2=164998&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_report.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_report.h Tue Oct 2 06:52:05 2012
@@ -67,6 +67,7 @@
struct ReportThread {
int id;
+ int pid;
bool running;
char *name;
ReportStack *stack;
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc?rev=164998&r1=164997&r2=164998&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc Tue Oct 2 06:52:05 2012
@@ -74,6 +74,7 @@
ThreadContext::ThreadContext(int tid)
: tid(tid)
, unique_id()
+ , os_id()
, user_id()
, thr()
, status(ThreadStatusInvalid)
@@ -201,7 +202,7 @@
ctx->thread_seq = 0;
int tid = ThreadCreate(thr, 0, 0, true);
CHECK_EQ(tid, 0);
- ThreadStart(thr, tid);
+ ThreadStart(thr, tid, GetPid());
CHECK_EQ(thr->in_rtl, 1);
ctx->initialized = true;
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h?rev=164998&r1=164997&r2=164998&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h Tue Oct 2 06:52:05 2012
@@ -327,6 +327,7 @@
struct ThreadContext {
const int tid;
int unique_id; // Non-rolling thread id.
+ int os_id; // pid
uptr user_id; // Some opaque user thread id (e.g. pthread_t).
ThreadState *thr;
ThreadStatus status;
@@ -480,7 +481,7 @@
void FuncExit(ThreadState *thr);
int ThreadCreate(ThreadState *thr, uptr pc, uptr uid, bool detached);
-void ThreadStart(ThreadState *thr, int tid);
+void ThreadStart(ThreadState *thr, int tid, int os_id);
void ThreadFinish(ThreadState *thr);
int ThreadTid(ThreadState *thr, uptr pc, uptr uid);
void ThreadJoin(ThreadState *thr, uptr pc, int tid);
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=164998&r1=164997&r2=164998&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc Tue Oct 2 06:52:05 2012
@@ -156,6 +156,7 @@
ReportThread *rt = new(mem) ReportThread();
rep_->threads.PushBack(rt);
rt->id = tctx->tid;
+ rt->pid = tctx->os_id;
rt->running = (tctx->status == ThreadStatusRunning);
rt->stack = SymbolizeStack(tctx->creation_stack);
}
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc?rev=164998&r1=164997&r2=164998&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc Tue Oct 2 06:52:05 2012
@@ -137,7 +137,7 @@
return tid;
}
-void ThreadStart(ThreadState *thr, int tid) {
+void ThreadStart(ThreadState *thr, int tid, int os_id) {
CHECK_GT(thr->in_rtl, 0);
uptr stk_addr = 0;
uptr stk_size = 0;
@@ -169,6 +169,7 @@
CHECK_NE(tctx, 0);
CHECK_EQ(tctx->status, ThreadStatusCreated);
tctx->status = ThreadStatusRunning;
+ tctx->os_id = os_id;
tctx->epoch0 = tctx->epoch1 + 1;
tctx->epoch1 = (u64)-1;
new(thr) ThreadState(CTX(), tid, tctx->unique_id,
More information about the llvm-commits
mailing list