2018-09-05 08:57:23 +02:00
|
|
|
//===- RecordPrinter.cpp - FDR Record Printer -----------------------------===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-09-05 08:57:23 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#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) {
|
2018-09-11 08:36:51 +02:00
|
|
|
OS << formatv("<CPU: id = {0}, tsc = {1}>", R.cpuid(), R.tsc()) << Delim;
|
2018-09-05 08:57:23 +02:00
|
|
|
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) {
|
2018-11-01 01:18:52 +01:00
|
|
|
OS << formatv(
|
|
|
|
"<Custom Event: tsc = {0}, cpu = {1}, size = {2}, data = '{3}'>",
|
|
|
|
R.tsc(), R.cpu(), R.size(), R.data())
|
2018-09-05 08:57:23 +02:00
|
|
|
<< Delim;
|
|
|
|
return Error::success();
|
|
|
|
}
|
|
|
|
|
2018-11-07 05:37:42 +01:00
|
|
|
Error RecordPrinter::visit(CustomEventRecordV5 &R) {
|
|
|
|
OS << formatv("<Custom Event: delta = +{0}, size = {1}, data = '{2}'>",
|
|
|
|
R.delta(), R.size(), R.data())
|
|
|
|
<< Delim;
|
|
|
|
return Error::success();
|
|
|
|
}
|
|
|
|
|
|
|
|
Error RecordPrinter::visit(TypedEventRecord &R) {
|
|
|
|
OS << formatv(
|
|
|
|
"<Typed Event: delta = +{0}, type = {1}, size = {2}, data = '{3}'",
|
|
|
|
R.delta(), R.eventType(), R.size(), R.data())
|
|
|
|
<< Delim;
|
|
|
|
return Error::success();
|
|
|
|
}
|
|
|
|
|
2018-09-05 08:57:23 +02:00
|
|
|
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:
|
2018-11-02 09:07:38 +01:00
|
|
|
OS << formatv("<Function Enter: #{0} delta = +{1}>", R.functionId(),
|
2018-09-05 08:57:23 +02:00
|
|
|
R.delta());
|
|
|
|
break;
|
|
|
|
case RecordTypes::ENTER_ARG:
|
2018-11-02 09:07:38 +01:00
|
|
|
OS << formatv("<Function Enter With Arg: #{0} delta = +{1}>",
|
2018-09-05 08:57:23 +02:00
|
|
|
R.functionId(), R.delta());
|
|
|
|
break;
|
|
|
|
case RecordTypes::EXIT:
|
2018-11-02 09:07:38 +01:00
|
|
|
OS << formatv("<Function Exit: #{0} delta = +{1}>", R.functionId(),
|
2018-09-05 08:57:23 +02:00
|
|
|
R.delta());
|
|
|
|
break;
|
|
|
|
case RecordTypes::TAIL_EXIT:
|
2018-11-02 09:07:38 +01:00
|
|
|
OS << formatv("<Function Tail Exit: #{0} delta = +{1}>", R.functionId(),
|
2018-09-05 08:57:23 +02:00
|
|
|
R.delta());
|
|
|
|
break;
|
2018-11-06 09:51:37 +01:00
|
|
|
case RecordTypes::CUSTOM_EVENT:
|
|
|
|
case RecordTypes::TYPED_EVENT:
|
|
|
|
// TODO: Flag as a bug?
|
|
|
|
break;
|
2018-09-05 08:57:23 +02:00
|
|
|
}
|
|
|
|
OS << Delim;
|
|
|
|
return Error::success();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace xray
|
|
|
|
} // namespace llvm
|