Files
llvm/lib/XRay/RecordPrinter.cpp
T
Dean Michael Berris b92b0b860c [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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346214 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-06 08:51:37 +00:00

95 lines
2.7 KiB
C++

//===- RecordPrinter.cpp - FDR Record Printer -----------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/XRay/RecordPrinter.h"
#include "llvm/Support/FormatVariadic.h"
namespace llvm {
namespace xray {
Error RecordPrinter::visit(BufferExtents &R) {
OS << formatv("<Buffer: size = {0} bytes>", R.size()) << Delim;
return Error::success();
}
Error RecordPrinter::visit(WallclockRecord &R) {
OS << formatv("<Wall Time: seconds = {0}.{1,0+6}>", R.seconds(), R.nanos())
<< Delim;
return Error::success();
}
Error RecordPrinter::visit(NewCPUIDRecord &R) {
OS << formatv("<CPU: id = {0}, tsc = {1}>", R.cpuid(), R.tsc()) << Delim;
return Error::success();
}
Error RecordPrinter::visit(TSCWrapRecord &R) {
OS << formatv("<TSC Wrap: base = {0}>", R.tsc()) << Delim;
return Error::success();
}
Error RecordPrinter::visit(CustomEventRecord &R) {
OS << formatv(
"<Custom Event: tsc = {0}, cpu = {1}, size = {2}, data = '{3}'>",
R.tsc(), R.cpu(), R.size(), R.data())
<< Delim;
return Error::success();
}
Error RecordPrinter::visit(CallArgRecord &R) {
OS << formatv("<Call Argument: data = {0} (hex = {0:x})>", R.arg()) << Delim;
return Error::success();
}
Error RecordPrinter::visit(PIDRecord &R) {
OS << formatv("<PID: {0}>", R.pid()) << Delim;
return Error::success();
}
Error RecordPrinter::visit(NewBufferRecord &R) {
OS << formatv("<Thread ID: {0}>", R.tid()) << Delim;
return Error::success();
}
Error RecordPrinter::visit(EndBufferRecord &R) {
OS << "<End of Buffer>" << Delim;
return Error::success();
}
Error RecordPrinter::visit(FunctionRecord &R) {
// FIXME: Support symbolization here?
switch (R.recordType()) {
case RecordTypes::ENTER:
OS << formatv("<Function Enter: #{0} delta = +{1}>", R.functionId(),
R.delta());
break;
case RecordTypes::ENTER_ARG:
OS << formatv("<Function Enter With Arg: #{0} delta = +{1}>",
R.functionId(), R.delta());
break;
case RecordTypes::EXIT:
OS << formatv("<Function Exit: #{0} delta = +{1}>", R.functionId(),
R.delta());
break;
case RecordTypes::TAIL_EXIT:
OS << formatv("<Function Tail Exit: #{0} delta = +{1}>", R.functionId(),
R.delta());
break;
case RecordTypes::CUSTOM_EVENT:
case RecordTypes::TYPED_EVENT:
// TODO: Flag as a bug?
break;
}
OS << Delim;
return Error::success();
}
} // namespace xray
} // namespace llvm