Merge "Add tid to trace info if available" into main am: d3026c61f9
Original change: https://android-review.googlesource.com/c/platform/bionic/+/3053343
Change-Id: I2d8b266cb969fd5b492a8745e0c165beaf616f92
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/libc/bionic/pthread_mutex.cpp b/libc/bionic/pthread_mutex.cpp
index 9b37225..0a452e9 100644
--- a/libc/bionic/pthread_mutex.cpp
+++ b/libc/bionic/pthread_mutex.cpp
@@ -182,7 +182,12 @@
return 0;
}
if (ret == EBUSY) {
- ScopedTrace trace("Contending for pthread mutex");
+ char trace_msg[64];
+ const pid_t owner = atomic_load_explicit(&mutex.owner_tid, memory_order_relaxed)
+ & FUTEX_TID_MASK;
+ snprintf(trace_msg, sizeof(trace_msg),
+ "Contending for pthread mutex owned by tid: %d", owner);
+ ScopedTrace trace(trace_msg);
ret = -__futex_pi_lock_ex(&mutex.owner_tid, mutex.shared, use_realtime_clock, abs_timeout);
}
return ret;