[PATCH] D51289: [XRay] FDR Record Producer/Consumer Implementation

Dean Michael Berris via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 27 02:06:22 PDT 2018


dberris created this revision.
dberris added reviewers: eizan, kpw.
Herald added subscribers: hiraditya, mgorny.

This patch defines two new base types called `RecordProducer` and
`RecordConsumer` which have default implementations for convenience
(particularly for testing).

A `RecordProducer` implementation has one member function called
`produce()` which serves as a factory constructor for `Record`
instances. This code exercises the `RecordInitializer` code path in the
implementation for `FileBasedRecordProducer`.

A `RecordConsumer` has a single member function called `consume(...)`
which, as the name implies, consumes instances of
`std::unique_ptr<Record>`. We have two implementations, one of which is
used in the test to generate a vector of `std::unique_ptr<Record>`
similar to how the `LogBuilder` implementation works.

We introduce a test in `FDRProducerConsumerTest` which ensures that
records we write through the `FDRTraceWriter` can be loaded by the
`FileBasedRecordProducer`. The record(s) loaded this way are written
again through the `FDRTraceWriter` into a separate string, which we then
compare. This ensures that the read-in bytes to create the `Record`
instances in memory can be replicated when written out through the
`FDRTraceWriter`.

This change depends on https://reviews.llvm.org/D51210 and is part of the refactoring of https://reviews.llvm.org/D50441
into smaller, more focused changes.


https://reviews.llvm.org/D51289

Files:
  llvm/include/llvm/XRay/FDRRecordConsumer.h
  llvm/include/llvm/XRay/FDRRecordProducer.h
  llvm/lib/XRay/CMakeLists.txt
  llvm/lib/XRay/FDRRecordProducer.cpp
  llvm/lib/XRay/FDRTraceWriter.cpp
  llvm/lib/XRay/LogBuilderConsumer.cpp
  llvm/unittests/XRay/CMakeLists.txt
  llvm/unittests/XRay/FDRProducerConsumerTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51289.162639.patch
Type: text/x-patch
Size: 13932 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180827/a19c8c69/attachment-0001.bin>


More information about the llvm-commits mailing list