LLVM  9.0.0svn
RecordPrinter.cpp
Go to the documentation of this file.
1 //===- RecordPrinter.cpp - FDR Record Printer -----------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 
11 
12 namespace llvm {
13 namespace xray {
14 
16  OS << formatv("<Buffer: size = {0} bytes>", R.size()) << Delim;
17  return Error::success();
18 }
19 
21  OS << formatv("<Wall Time: seconds = {0}.{1,0+6}>", R.seconds(), R.nanos())
22  << Delim;
23  return Error::success();
24 }
25 
27  OS << formatv("<CPU: id = {0}, tsc = {1}>", R.cpuid(), R.tsc()) << Delim;
28  return Error::success();
29 }
30 
32  OS << formatv("<TSC Wrap: base = {0}>", R.tsc()) << Delim;
33  return Error::success();
34 }
35 
37  OS << formatv(
38  "<Custom Event: tsc = {0}, cpu = {1}, size = {2}, data = '{3}'>",
39  R.tsc(), R.cpu(), R.size(), R.data())
40  << Delim;
41  return Error::success();
42 }
43 
45  OS << formatv("<Custom Event: delta = +{0}, size = {1}, data = '{2}'>",
46  R.delta(), R.size(), R.data())
47  << Delim;
48  return Error::success();
49 }
50 
52  OS << formatv(
53  "<Typed Event: delta = +{0}, type = {1}, size = {2}, data = '{3}'",
54  R.delta(), R.eventType(), R.size(), R.data())
55  << Delim;
56  return Error::success();
57 }
58 
60  OS << formatv("<Call Argument: data = {0} (hex = {0:x})>", R.arg()) << Delim;
61  return Error::success();
62 }
63 
65  OS << formatv("<PID: {0}>", R.pid()) << Delim;
66  return Error::success();
67 }
68 
70  OS << formatv("<Thread ID: {0}>", R.tid()) << Delim;
71  return Error::success();
72 }
73 
75  OS << "<End of Buffer>" << Delim;
76  return Error::success();
77 }
78 
80  // FIXME: Support symbolization here?
81  switch (R.recordType()) {
82  case RecordTypes::ENTER:
83  OS << formatv("<Function Enter: #{0} delta = +{1}>", R.functionId(),
84  R.delta());
85  break;
87  OS << formatv("<Function Enter With Arg: #{0} delta = +{1}>",
88  R.functionId(), R.delta());
89  break;
90  case RecordTypes::EXIT:
91  OS << formatv("<Function Exit: #{0} delta = +{1}>", R.functionId(),
92  R.delta());
93  break;
95  OS << formatv("<Function Tail Exit: #{0} delta = +{1}>", R.functionId(),
96  R.delta());
97  break;
100  // TODO: Flag as a bug?
101  break;
102  }
103  OS << Delim;
104  return Error::success();
105 }
106 
107 } // namespace xray
108 } // namespace llvm
int32_t functionId() const
Definition: FDRRecords.h:389
This class represents lattice values for constants.
Definition: AllocatorList.h:23
uint16_t cpuid() const
Definition: FDRRecords.h:173
RecordTypes recordType() const
Definition: FDRRecords.h:388
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
uint64_t arg() const
Definition: FDRRecords.h:304
int32_t pid() const
Definition: FDRRecords.h:327
uint64_t seconds() const
Definition: FDRRecords.h:148
uint64_t tsc() const
Definition: FDRRecords.h:175
uint16_t eventType() const
Definition: FDRRecords.h:281
uint64_t tsc() const
Definition: FDRRecords.h:197
static ErrorSuccess success()
Create a success value.
Definition: Error.h:326
StringRef data() const
Definition: FDRRecords.h:282
uint32_t nanos() const
Definition: FDRRecords.h:149
StringRef data() const
Definition: FDRRecords.h:226
uint32_t delta() const
Definition: FDRRecords.h:390
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
uint64_t size() const
Definition: FDRRecords.h:124
Error visit(BufferExtents &) override