diff options
| author | Dean Michael Berris <dberris@google.com> | 2018-11-06 08:51:37 +0000 |
|---|---|---|
| committer | Dean Michael Berris <dberris@google.com> | 2018-11-06 08:51:37 +0000 |
| commit | 25f8d204b828c534dabd90700e4efa6764508094 (patch) | |
| tree | aa8c192fbad0f862530482b829ec5caf51f0d47a /llvm/tools/llvm-xray/xray-converter.cpp | |
| parent | c1e530ee92ce8e0e6aa67677c4d0843f94b3ee05 (diff) | |
| download | bcm5719-llvm-25f8d204b828c534dabd90700e4efa6764508094.tar.gz bcm5719-llvm-25f8d204b828c534dabd90700e4efa6764508094.zip | |
[XRay] Update XRayRecord to support Custom/Typed Events
Summary:
This change cuts across LLVM and compiler-rt to add support for
rendering custom events in the XRayRecord type, to allow for including
user-provided annotations in the output YAML (as raw bytes).
This work enables us to add custom event and typed event records into
the `llvm::xray::Trace` type for user-provided events. This can then be
programmatically handled through the C++ API and can be included in some
of the tooling as well. For now we support printing the raw data we
encounter in the custom events in the converted output.
Future work will allow us to start interpreting these custom and typed
events through a yet-to-be-defined API for extending the trace analysis
library.
Reviewers: mboerger
Subscribers: hiraditya, llvm-commits
Differential Revision: https://reviews.llvm.org/D54139
llvm-svn: 346214
Diffstat (limited to 'llvm/tools/llvm-xray/xray-converter.cpp')
| -rw-r--r-- | llvm/tools/llvm-xray/xray-converter.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/llvm/tools/llvm-xray/xray-converter.cpp b/llvm/tools/llvm-xray/xray-converter.cpp index 1faa49cf431..3f153b99bc9 100644 --- a/llvm/tools/llvm-xray/xray-converter.cpp +++ b/llvm/tools/llvm-xray/xray-converter.cpp @@ -92,9 +92,10 @@ void TraceConverter::exportAsYAML(const Trace &Records, raw_ostream &OS) { Trace.Records.push_back({R.RecordType, R.CPU, R.Type, R.FuncId, Symbolize ? FuncIdHelper.SymbolOrNumber(R.FuncId) : llvm::to_string(R.FuncId), - R.TSC, R.TId, R.PId, R.CallArgs}); + R.TSC, R.TId, R.PId, R.CallArgs, R.Data}); } Output Out(OS, nullptr, 0); + Out.setWriteDefaultValues(false); Out << Trace; } @@ -123,21 +124,27 @@ void TraceConverter::exportAsRAWv1(const Trace &Records, raw_ostream &OS) { // Then write out the rest of the records, still in an endian-appropriate // format. for (const auto &R : Records) { - Writer.write(R.RecordType); - // The on disk naive raw format uses 8 bit CPUs, but the record has 16. - // There's no choice but truncation. - Writer.write(static_cast<uint8_t>(R.CPU)); switch (R.Type) { case RecordTypes::ENTER: case RecordTypes::ENTER_ARG: + Writer.write(R.RecordType); + Writer.write(static_cast<uint8_t>(R.CPU)); Writer.write(uint8_t{0}); break; case RecordTypes::EXIT: + Writer.write(R.RecordType); + Writer.write(static_cast<uint8_t>(R.CPU)); Writer.write(uint8_t{1}); break; case RecordTypes::TAIL_EXIT: + Writer.write(R.RecordType); + Writer.write(static_cast<uint8_t>(R.CPU)); Writer.write(uint8_t{2}); break; + case RecordTypes::CUSTOM_EVENT: + case RecordTypes::TYPED_EVENT: + // Skip custom and typed event records for v1 logs. + continue; } Writer.write(R.FuncId); Writer.write(R.TSC); @@ -264,6 +271,10 @@ void TraceConverter::exportAsChromeTraceEventFormat(const Trace &Records, double EventTimestampUs = double(1000000) / CycleFreq * double(R.TSC); StackTrieNode *&StackCursor = StackCursorByThreadId[R.TId]; switch (R.Type) { + case RecordTypes::CUSTOM_EVENT: + case RecordTypes::TYPED_EVENT: + // TODO: Support typed and custom event rendering on Chrome Trace Viewer. + break; case RecordTypes::ENTER: case RecordTypes::ENTER_ARG: StackCursor = findOrCreateStackNode(StackCursor, R.FuncId, R.TId, |

