1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/include/llvm/XRay
Dean Michael Berris 2fe42806e8 [XRay] Improve FDR trace handling and error messaging
Summary:
This change covers a number of things spanning LLVM and compiler-rt,
which are related in a non-trivial way.

In LLVM, we have a library that handles the FDR mode even log loading,
which uses C++'s runtime polymorphism feature to better faithfully
represent the events that are written down by the FDR mode runtime. We
do this by interpreting a trace that's serliased in a common format
agreed upon by both the trace loading library and the FDR mode runtime.
This library is under active development, which consists of features
allowing us to reconstitute a higher-level event log.

This event log is used by the conversion and visualisation tools we have
for interpreting XRay traces.

One of the tools we have is a diagnostic tool in llvm-xray called
`fdr-dump` which we've been using to debug our expectations of what the
FDR runtime should be writing and what the logical FDR event log
structures are. We use this fairly extensively to reason about why some
non-trivial traces we're generating with FDR mode runtimes fail to
convert or fail to parse correctly.

One of these failures we've found in manual debugging of some of the
traces we've seen involve an inconsistency between the buffer extents (a
record indicating how many bytes to follow are part of a logical
thread's event log) and the record of the bytes written into the log --
sometimes it turns out the data could be garbage, due to buffers being
recycled, but sometimes we're seeing the buffer extent indicating a log
is "shorter" than the actual records associated with the buffer. This
case happens particularly with function entry records with a call
argument.

This change for now updates the FDR mode runtime to write the bytes for
the function call and arg record before updating the buffer extents
atomically, allowing multiple threads to see a consistent view of the
data in the buffer using the atomic counter associated with a buffer.
What we're trying to prevent here is partial updates where we see the
intermediary updates to the buffer extents (function record size then
call argument record size) becoming observable from another thread, for
instance, one doing the serialization/flushing.

To do both diagnose this issue properly, we need to be able to honour
the extents being set in the `BufferExtents` records marking the
beginning of the logical buffers when reading an FDR trace. Since LLVM
doesn't use C++'s RTTI mechanism, we instead follow the advice in the
documentation for LLVM Style RTTI
(https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html). We then rely on
this RTTI feature to ensure that our file-based record producer (our
streaming "deserializer") can honour the extents of individual buffers
as we interpret traces.

This also sets us up to be able to eventually do smart
skipping/continuation of FDR logs, seeking instead to find BufferExtents
records in cases where we find potentially recoverable errors. In the
meantime, we make this change to operate in a strict mode when reading
logical buffers with extent records.

Reviewers: mboerger

Subscribers: hiraditya, llvm-commits, jfb

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

llvm-svn: 346473
2018-11-09 06:26:48 +00:00
..
BlockIndexer.h [XRay] Use TSC delta encoding for custom/typed events 2018-11-07 04:37:42 +00:00
BlockPrinter.h [XRay] Use TSC delta encoding for custom/typed events 2018-11-07 04:37:42 +00:00
BlockVerifier.h [XRay] Use TSC delta encoding for custom/typed events 2018-11-07 04:37:42 +00:00
FDRLogBuilder.h [XRay] FDRTraceWriter and FDR Trace Loading 2018-08-30 07:22:21 +00:00
FDRRecordConsumer.h [XRay] FDR Record Producer/Consumer Implementation 2018-08-31 08:04:56 +00:00
FDRRecordProducer.h [XRay] Improve FDR trace handling and error messaging 2018-11-09 06:26:48 +00:00
FDRRecords.h [XRay] Improve FDR trace handling and error messaging 2018-11-09 06:26:48 +00:00
FDRTraceExpander.h [XRay] Use TSC delta encoding for custom/typed events 2018-11-07 04:37:42 +00:00
FDRTraceWriter.h [XRay] Use TSC delta encoding for custom/typed events 2018-11-07 04:37:42 +00:00
FileHeaderReader.h [XRay] Refactor file header reading (NFC) 2018-08-22 07:37:55 +00:00
Graph.h
InstrumentationMap.h
Profile.h [XRay][llvm] Load XRay Profiles 2018-08-30 01:43:22 +00:00
RecordPrinter.h [XRay] Use TSC delta encoding for custom/typed events 2018-11-07 04:37:42 +00:00
Trace.h [XRay][compiler-rt] FDRLogWriter Abstraction 2018-09-20 05:22:37 +00:00
XRayRecord.h [XRay] Update XRayRecord to support Custom/Typed Events 2018-11-06 08:51:37 +00:00
YAMLXRayRecord.h [XRay] Update XRayRecord to support Custom/Typed Events 2018-11-06 08:51:37 +00:00