[XRay][compiler-rt] FDR Mode: Allow multiple runs
authorDean Michael Berris <dberris@google.com>
Wed, 18 Jul 2018 01:31:30 +0000 (01:31 +0000)
committerDean Michael Berris <dberris@google.com>
Wed, 18 Jul 2018 01:31:30 +0000 (01:31 +0000)
commit1e3feb49e333520f9c16ea586a8edd5931f34063
treefa72f83226725f15b0328ff444f3309d420a29bb
parent2526104ee472d4f5c21e4b519d7a04a19d76821b
[XRay][compiler-rt] FDR Mode: Allow multiple runs

Summary:
Fix a bug in FDR mode which didn't allow for re-initialising the logging
in the same process. This change ensures that:

- When we flush the FDR mode logging, that the state of the logging
  implementation is `XRAY_LOG_UNINITIALIZED`.

- Fix up the thread-local initialisation to use aligned storage and
  `pthread_getspecific` as well as `pthread_setspecific` for the
  thread-specific data.

- Actually use the pointer provided to the thread-exit cleanup handling,
  instead of assuming that the thread has thread-local data associated
  with it, and reaching at thread-exit time.

In this change we also have an explicit test for two consecutive
sessions for FDR mode tracing, and ensuring both sessions succeed.

Reviewers: kpw, eizan

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D49359

llvm-svn: 337341
compiler-rt/lib/xray/xray_fdr_logging.cc
compiler-rt/test/xray/TestCases/Posix/fdr-mode-multiple.cc [new file with mode: 0644]