[compiler-rt] r294166 - [XRay][compiler-rt] Use gettid instead of getpid in FDR mode.
Dean Michael Berris via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 5 17:48:21 PST 2017
Author: dberris
Date: Sun Feb 5 19:48:21 2017
New Revision: 294166
URL: http://llvm.org/viewvc/llvm-project?rev=294166&view=rev
Log:
[XRay][compiler-rt] Use gettid instead of getpid in FDR mode.
Summary:
This was pointed out that FDR mode didn't quite put the thread ID in the
buffers, but instead would write down the parent process ID.
Reviewers: pelikan, rSerge
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D29484
Modified:
compiler-rt/trunk/lib/xray/xray_fdr_logging.cc
Modified: compiler-rt/trunk/lib/xray/xray_fdr_logging.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_fdr_logging.cc?rev=294166&r1=294165&r2=294166&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_fdr_logging.cc (original)
+++ compiler-rt/trunk/lib/xray/xray_fdr_logging.cc Sun Feb 5 19:48:21 2017
@@ -20,6 +20,7 @@
#include <cassert>
#include <cstring>
#include <memory>
+#include <sys/syscall.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
@@ -200,8 +201,8 @@ void setupNewBuffer(const BufferQueue::B
auto &NewBuffer = *reinterpret_cast<MetadataRecord *>(&Records[0]);
NewBuffer.Type = RecordType::Metadata;
NewBuffer.RecordKind = MetadataRecord::RecordKinds::NewBuffer;
- pid_t Pid = getpid();
- std::memcpy(&NewBuffer.Data, &Pid, sizeof(pid_t));
+ pid_t Tid = syscall(SYS_gettid);
+ std::memcpy(&NewBuffer.Data, &Tid, sizeof(pid_t));
}
// Also write the WalltimeMarker record.
More information about the llvm-commits
mailing list