[PATCH] D43278: Add Xray instrumentation support to FreeBSD

Kamil Rytarowski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 09:26:23 PST 2018


krytarowski added inline comments.


================
Comment at: lib/xray/xray_utils.cc:100
+  tid = syscall(SYS_gettid);
+#else
+  tid = reinterpret_cast<uint64_t>(pthread_self());
----------------
I propose to use
`#elif SANITIZER_FREEBSD`
and followed by `#error`
`#else`
`#error not implemented`
`#endif`

It will be clear that this code is for FreeBSD.


================
Comment at: lib/xray/xray_x86_64.cc:79
 }
+#else
+uint64_t getTSCFrequency() XRAY_NEVER_INSTRUMENT {
----------------
`#elif SANITIZER_FREEBSD` followed by `#else` with `#error`.


================
Comment at: lib/xray/xray_x86_64.cc:84
 
+    if (sysctlbyname("machdep.tsc_freq", &TSCFrequency, &tscfreqsz,
+        NULL, 0) != -1) {
----------------
I think you should use `sysctl()`, as `sysctlbyname()` allocates memory internally.


================
Comment at: test/xray/lit.cfg:23
 # Setup substitutions.
+xraylib_flags = '-lm -lpthread -lrt'
+if config.host_os == 'Linux':
----------------
`-pthread`


https://reviews.llvm.org/D43278





More information about the llvm-commits mailing list