summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_common.h1
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_posix.cc5
-rw-r--r--compiler-rt/lib/tsan/go/tsan_go.cc2
-rw-r--r--compiler-rt/lib/tsan/lit_tests/race_on_heap.cc2
-rw-r--r--compiler-rt/lib/tsan/lit_tests/race_with_finished_thread.cc2
-rw-r--r--compiler-rt/lib/tsan/lit_tests/simple_stack.c2
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_interceptors.cc2
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_report.cc2
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_report.h1
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl.cc3
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl.h3
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc1
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc3
13 files changed, 20 insertions, 9 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index c4d236447a7..04b08b74b23 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -34,6 +34,7 @@ const uptr kMmapGranularity = 1UL << 16;
// Threads
int GetPid();
+int GetTid();
uptr GetThreadSelf();
void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top,
uptr *stack_bottom);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
index e3f851611ec..7d21b5f6c2c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
@@ -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 @@ int GetPid() {
return getpid();
}
+int GetTid() {
+ return syscall(__NR_gettid);
+}
+
uptr GetThreadSelf() {
return (uptr)pthread_self();
}
diff --git a/compiler-rt/lib/tsan/go/tsan_go.cc b/compiler-rt/lib/tsan/go/tsan_go.cc
index 2aa9f178e5a..77da9fe70dd 100644
--- a/compiler-rt/lib/tsan/go/tsan_go.cc
+++ b/compiler-rt/lib/tsan/go/tsan_go.cc
@@ -149,7 +149,7 @@ void __tsan_go_start(int pgoid, int chgoid, void *pc) {
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--;
}
diff --git a/compiler-rt/lib/tsan/lit_tests/race_on_heap.cc b/compiler-rt/lib/tsan/lit_tests/race_on_heap.cc
index 1fdf54d84c6..855c309a955 100644
--- a/compiler-rt/lib/tsan/lit_tests/race_on_heap.cc
+++ b/compiler-rt/lib/tsan/lit_tests/race_on_heap.cc
@@ -42,6 +42,6 @@ int main() {
// 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
diff --git a/compiler-rt/lib/tsan/lit_tests/race_with_finished_thread.cc b/compiler-rt/lib/tsan/lit_tests/race_with_finished_thread.cc
index e50c22bf011..4008ecd66c0 100644
--- a/compiler-rt/lib/tsan/lit_tests/race_with_finished_thread.cc
+++ b/compiler-rt/lib/tsan/lit_tests/race_with_finished_thread.cc
@@ -38,6 +38,6 @@ int main() {
// 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
diff --git a/compiler-rt/lib/tsan/lit_tests/simple_stack.c b/compiler-rt/lib/tsan/lit_tests/simple_stack.c
index 08f5f6534a3..b1309573537 100644
--- a/compiler-rt/lib/tsan/lit_tests/simple_stack.c
+++ b/compiler-rt/lib/tsan/lit_tests/simple_stack.c
@@ -56,7 +56,7 @@ int main() {
// 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)?}} ({{.*}})
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
index 03272993e0f..387cfba06e5 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
@@ -629,7 +629,7 @@ extern "C" void *__tsan_thread_start_func(void *arg) {
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);
diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.cc b/compiler-rt/lib/tsan/rtl/tsan_report.cc
index a284a964034..ded8070dede 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_report.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_report.cc
@@ -104,7 +104,7 @@ static void PrintThread(const ReportThread *rt) {
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");
diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.h b/compiler-rt/lib/tsan/rtl/tsan_report.h
index 20223daddc8..696e4180350 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_report.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_report.h
@@ -67,6 +67,7 @@ struct ReportLocation {
struct ReportThread {
int id;
+ int pid;
bool running;
char *name;
ReportStack *stack;
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
index 33afe3c9ebb..90e2584cb03 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
@@ -74,6 +74,7 @@ ThreadState::ThreadState(Context *ctx, int tid, int unique_id, u64 epoch,
ThreadContext::ThreadContext(int tid)
: tid(tid)
, unique_id()
+ , os_id()
, user_id()
, thr()
, status(ThreadStatusInvalid)
@@ -201,7 +202,7 @@ void Initialize(ThreadState *thr) {
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;
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
index a56025ef48b..f2b18e9fe33 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
@@ -327,6 +327,7 @@ struct ThreadDeadInfo {
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 FuncEntry(ThreadState *thr, uptr pc);
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);
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc
index ac3194b2ebe..d1794105c58 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc
@@ -156,6 +156,7 @@ void ScopedReport::AddThread(const ThreadContext *tctx) {
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);
}
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
index 8b27522c683..47884b4eac5 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
@@ -137,7 +137,7 @@ int ThreadCreate(ThreadState *thr, uptr pc, uptr uid, bool detached) {
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 @@ void ThreadStart(ThreadState *thr, int tid) {
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,
OpenPOWER on IntegriCloud