[PATCH] D43278: Add Xray instrumentation support to FreeBSD

Kamil Rytarowski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 14:22:13 PST 2018


krytarowski added inline comments.


================
Comment at: lib/xray/xray_fdr_logging_impl.h:240
   TLD.RecordPtr = static_cast<char *>(B.Data);
-  pid_t Tid = syscall(SYS_gettid);
+  pid_t Tid = getTid();
   timespec TS{0, 0};
----------------
krytarowski wrote:
> devnexen wrote:
> > krytarowski wrote:
> > > krytarowski wrote:
> > > > Here `Tid` should be of type `Tid_t`.
> > > There are more `pid_t` out there:
> > > 
> > > ```
> > > static void writeNewBufferPreamble(pid_t Tid, timespec TS);
> > > ```
> > > 
> > > ```
> > > static void writeNewBufferPreamble(pid_t Tid, 
> > >                                    timespec TS) XRAY_NEVER_INSTRUMENT {
> > > ```
> > > 
> > > ```
> > >     // point we only write down the following bytes:
> > >     //   - Thread ID (pid_t, 4 bytes)
> > > ```
> > Careful here writeNewBufferPreamble expects internally a size of pid_t (so 4 bytes)
> Please adjust the code for `Tid_t` of 8bytes.
Alternatively we can squash `Tid_t` to 4 bytes, it will be fine for Linux, FreeBSD and NetBSD. I have no idea about Darwin.


https://reviews.llvm.org/D43278





More information about the llvm-commits mailing list