LLVM  8.0.1
FDRTraceExpander.cpp
Go to the documentation of this file.
1 //===- FDRTraceExpander.cpp -----------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
10 
11 namespace llvm {
12 namespace xray {
13 
14 void TraceExpander::resetCurrentRecord() {
15  if (BuildingRecord)
16  C(CurrentRecord);
17  BuildingRecord = false;
18  CurrentRecord.CallArgs.clear();
19  CurrentRecord.Data.clear();
20 }
21 
23  resetCurrentRecord();
24  return Error::success();
25 }
26 
28 
30  CPUId = R.cpuid();
31  BaseTSC = R.tsc();
32  return Error::success();
33 }
34 
36  BaseTSC = R.tsc();
37  return Error::success();
38 }
39 
41  resetCurrentRecord();
42  if (!IgnoringRecords) {
43  CurrentRecord.TSC = R.tsc();
44  CurrentRecord.CPU = R.cpu();
45  CurrentRecord.PId = PID;
46  CurrentRecord.TId = TID;
47  CurrentRecord.Type = RecordTypes::CUSTOM_EVENT;
48  CurrentRecord.Data = R.data();
49  BuildingRecord = true;
50  }
51  return Error::success();
52 }
53 
55  resetCurrentRecord();
56  if (!IgnoringRecords) {
57  BaseTSC += R.delta();
58  CurrentRecord.TSC = BaseTSC;
59  CurrentRecord.CPU = CPUId;
60  CurrentRecord.PId = PID;
61  CurrentRecord.TId = TID;
62  CurrentRecord.Type = RecordTypes::CUSTOM_EVENT;
63  CurrentRecord.Data = R.data();
64  BuildingRecord = true;
65  }
66  return Error::success();
67 }
68 
70  resetCurrentRecord();
71  if (!IgnoringRecords) {
72  BaseTSC += R.delta();
73  CurrentRecord.TSC = BaseTSC;
74  CurrentRecord.CPU = CPUId;
75  CurrentRecord.PId = PID;
76  CurrentRecord.TId = TID;
77  CurrentRecord.RecordType = R.eventType();
78  CurrentRecord.Type = RecordTypes::TYPED_EVENT;
79  CurrentRecord.Data = R.data();
80  BuildingRecord = true;
81  }
82  return Error::success();
83 }
84 
86  CurrentRecord.CallArgs.push_back(R.arg());
87  CurrentRecord.Type = RecordTypes::ENTER_ARG;
88  return Error::success();
89 }
90 
92  PID = R.pid();
93  return Error::success();
94 }
95 
97  if (IgnoringRecords)
98  IgnoringRecords = false;
99  TID = R.tid();
100  if (LogVersion == 2)
101  PID = R.tid();
102  return Error::success();
103 }
104 
106  IgnoringRecords = true;
107  resetCurrentRecord();
108  return Error::success();
109 }
110 
112  resetCurrentRecord();
113  if (!IgnoringRecords) {
114  BaseTSC += R.delta();
115  CurrentRecord.Type = R.recordType();
116  CurrentRecord.FuncId = R.functionId();
117  CurrentRecord.TSC = BaseTSC;
118  CurrentRecord.PId = PID;
119  CurrentRecord.TId = TID;
120  CurrentRecord.CPU = CPUId;
121  BuildingRecord = true;
122  }
123  return Error::success();
124 }
125 
127  resetCurrentRecord();
128  return Error::success();
129 }
130 
131 } // namespace xray
132 } // namespace llvm
int32_t functionId() const
Definition: FDRRecords.h:390
uint16_t RecordType
RecordType values are used as "sub-types" which have meaning in the context of the Type below...
Definition: XRayRecord.h:75
This class represents lattice values for constants.
Definition: AllocatorList.h:24
uint16_t cpuid() const
Definition: FDRRecords.h:174
RecordTypes recordType() const
Definition: FDRRecords.h:389
uint64_t arg() const
Definition: FDRRecords.h:305
std::string Data
For custom and typed events, we provide the raw data from the trace.
Definition: XRayRecord.h:99
RecordTypes Type
Identifies the type of record.
Definition: XRayRecord.h:81
int32_t pid() const
Definition: FDRRecords.h:328
Error visit(BufferExtents &) override
int32_t FuncId
The function ID for the record, if this is a function call record.
Definition: XRayRecord.h:84
uint64_t tsc() const
Definition: FDRRecords.h:176
uint16_t eventType() const
Definition: FDRRecords.h:282
uint32_t TId
The thread ID for the currently running thread.
Definition: XRayRecord.h:90
uint64_t tsc() const
Definition: FDRRecords.h:198
static ErrorSuccess success()
Create a success value.
Definition: Error.h:327
uint32_t PId
The process ID for the currently running process.
Definition: XRayRecord.h:93
uint64_t TSC
Get the full 8 bytes of the TSC when we get the log record.
Definition: XRayRecord.h:87
StringRef data() const
Definition: FDRRecords.h:283
std::vector< uint64_t > CallArgs
The function call arguments.
Definition: XRayRecord.h:96
StringRef data() const
Definition: FDRRecords.h:227
uint32_t delta() const
Definition: FDRRecords.h:391
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158
uint16_t CPU
The CPU where the thread is running. We assume number of CPUs <= 65536.
Definition: XRayRecord.h:78