[PATCH] D38493: [XRay] [compiler-rt] make sure single threaded programs get traced too

Martin Pelikán via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 3 17:28:11 PDT 2017


pelikan added inline comments.


================
Comment at: lib/xray/xray_fdr_logging.cc:119-127
+
+  // The buffer for this particular thread would have been finalised after
+  // we've written everything to disk, and we'd lose the thread's trace.
+  auto &TLD = __xray::__xray_fdr_internal::getThreadLocalData();
+  if (TLD.Buffer.Buffer != nullptr) {
+    __xray::__xray_fdr_internal::writeEOBMetadata();
+    auto Start = reinterpret_cast<char *>(TLD.Buffer.Buffer);
----------------
dberris wrote:
> Shouldn't this happen before we write out the data instead, so we don't need to do a special write here?
That write will only be triggered if the second member of the tuple is true, which may or may not be the case.  Hence the explicit write in an "if this thread needs it".

(Your question makes sense and I had it like that at first.  It didn't work, though.)


================
Comment at: test/xray/TestCases/Linux/fdr-single-thread.cc:2
+// RUN: %clangxx_xray -g -std=c++11 %s -o %t
+// RUN: XRAY_OPTIONS=XRAY_OPTIONS="verbosity=1 patch_premain=true xray_naive_log=false xray_fdr_log=true xray_fdr_log_func_duration_threshold_us=0 xray_logfile_base=fdr-logging-1thr-" %run %t 2>&1
+// RUN: %llvm_xray convert --output-format=yaml --symbolize --instr_map=%t "`ls fdr-logging-1thr-* | head -n1`" | FileCheck %s --check-prefix=TRACE
----------------
dberris wrote:
> Consider breaking these up with slashes:
> 
> ```
> // RUN: ... \
> // RUN:     ... \
> // RUN:     ...
> ```
I've also removed the "TRACE" thing when there's a perfectly sensible default.


https://reviews.llvm.org/D38493





More information about the llvm-commits mailing list