[PATCH] D35654: [compiler-rt] Include thread ID into sanitizers logs
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 20 10:32:43 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL308637: [compiler-rt] Include thread ID into sanitizers logs (authored by vitalybuka).
Repository:
rL LLVM
https://reviews.llvm.org/D35654
Files:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc
compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/vreport.cc
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc
@@ -260,16 +260,15 @@
"Buffer in Report is too short!\n"); \
}
if (append_pid) {
- int pid = internal_getpid();
const char *exe_name = GetProcessName();
if (common_flags()->log_exe_name && exe_name) {
needed_length += internal_snprintf(buffer, buffer_size,
"==%s", exe_name);
CHECK_NEEDED_LENGTH
}
- needed_length += internal_snprintf(buffer + needed_length,
- buffer_size - needed_length,
- "==%d==", pid);
+ needed_length +=
+ internal_snprintf(buffer + needed_length, buffer_size - needed_length,
+ "==%d:%d==", internal_getpid(), GetTid());
CHECK_NEEDED_LENGTH
}
needed_length += VSNPrintf(buffer + needed_length,
@@ -300,7 +299,7 @@
va_end(args);
}
-// Like Printf, but prints the current PID before the output string.
+// Like Printf, but prints the current PID:TID before the output string.
FORMAT(1, 2)
void Report(const char *format, ...) {
va_list args;
Index: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/vreport.cc
===================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/vreport.cc
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/vreport.cc
@@ -0,0 +1,23 @@
+// RUN: %clangxx -O0 %s -o %t && %env_tool_opts=verbosity=10 %run %t 2>&1 | FileCheck %s
+
+#include <pthread.h>
+#include <stdio.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+void *thread(void *unused) {
+ printf("PID: %d\n", getpid());
+ printf("TID: %ld\n", syscall(SYS_gettid));
+ fflush(stdout);
+ return 0;
+}
+
+int main() {
+ pthread_t t;
+ pthread_create(&t, 0, thread, 0);
+ pthread_join(t, 0);
+ return 0;
+}
+// CHECK: PID: [[PID:[0-9]+]]
+// CHECK: TID: [[TID:[0-9]+]]
+// CHECK: ==[[PID]]:[[TID]]==
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35654.107547.patch
Type: text/x-patch
Size: 2231 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170720/b7e4cb9d/attachment.bin>
More information about the llvm-commits
mailing list