LLVM  14.0.0git
FDRTraceExpander.cpp
Go to the documentation of this file.
1 //===- FDRTraceExpander.cpp -----------------------------------------------===//
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 
10 namespace llvm {
11 namespace xray {
12 
13 void TraceExpander::resetCurrentRecord() {
14  if (BuildingRecord)
15  C(CurrentRecord);
16  BuildingRecord = false;
17  CurrentRecord.CallArgs.clear();
18  CurrentRecord.Data.clear();
19 }
20 
22  resetCurrentRecord();
23  return Error::success();
24 }
25 
27 
29  CPUId = R.cpuid();
30  BaseTSC = R.tsc();
31  return Error::success();
32 }
33 
35  BaseTSC = R.tsc();
36  return Error::success();
37 }
38 
40  resetCurrentRecord();
41  if (!IgnoringRecords) {
42  CurrentRecord.TSC = R.tsc();
43  CurrentRecord.CPU = R.cpu();
44  CurrentRecord.PId = PID;
45  CurrentRecord.TId = TID;
46  CurrentRecord.Type = RecordTypes::CUSTOM_EVENT;
47  CurrentRecord.Data = std::string(R.data());
48  BuildingRecord = true;
49  }
50  return Error::success();
51 }
52 
54  resetCurrentRecord();
55  if (!IgnoringRecords) {
56  BaseTSC += R.delta();
57  CurrentRecord.TSC = BaseTSC;
58  CurrentRecord.CPU = CPUId;
59  CurrentRecord.PId = PID;
60  CurrentRecord.TId = TID;
61  CurrentRecord.Type = RecordTypes::CUSTOM_EVENT;
62  CurrentRecord.Data = std::string(R.data());
63  BuildingRecord = true;
64  }
65  return Error::success();
66 }
67 
69  resetCurrentRecord();
70  if (!IgnoringRecords) {
71  BaseTSC += R.delta();
72  CurrentRecord.TSC = BaseTSC;
73  CurrentRecord.CPU = CPUId;
74  CurrentRecord.PId = PID;
75  CurrentRecord.TId = TID;
76  CurrentRecord.RecordType = R.eventType();
77  CurrentRecord.Type = RecordTypes::TYPED_EVENT;
78  CurrentRecord.Data = std::string(R.data());
79  BuildingRecord = true;
80  }
81  return Error::success();
82 }
83 
85  CurrentRecord.CallArgs.push_back(R.arg());
86  CurrentRecord.Type = RecordTypes::ENTER_ARG;
87  return Error::success();
88 }
89 
91  PID = R.pid();
92  return Error::success();
93 }
94 
96  if (IgnoringRecords)
97  IgnoringRecords = false;
98  TID = R.tid();
99  if (LogVersion == 2)
100  PID = R.tid();
101  return Error::success();
102 }
103 
105  IgnoringRecords = true;
106  resetCurrentRecord();
107  return Error::success();
108 }
109 
111  resetCurrentRecord();
112  if (!IgnoringRecords) {
113  BaseTSC += R.delta();
114  CurrentRecord.Type = R.recordType();
115  CurrentRecord.FuncId = R.functionId();
116  CurrentRecord.TSC = BaseTSC;
117  CurrentRecord.PId = PID;
118  CurrentRecord.TId = TID;
119  CurrentRecord.CPU = CPUId;
120  BuildingRecord = true;
121  }
122  return Error::success();
123 }
124 
126  resetCurrentRecord();
127  return Error::success();
128 }
129 
130 } // namespace xray
131 } // namespace llvm
llvm::xray::XRayRecord::TId
uint32_t TId
The thread ID for the currently running thread.
Definition: XRayRecord.h:89
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::xray::FunctionRecord
Definition: FDRRecords.h:372
llvm::xray::PIDRecord
Definition: FDRRecords.h:313
llvm::xray::XRayRecord::RecordType
uint16_t RecordType
RecordType values are used as "sub-types" which have meaning in the context of the Type below.
Definition: XRayRecord.h:74
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
llvm::xray::XRayRecord::CPU
uint16_t CPU
The CPU where the thread is running. We assume number of CPUs <= 65536.
Definition: XRayRecord.h:77
llvm::xray::RecordTypes::TYPED_EVENT
@ TYPED_EVENT
llvm::xray::BufferExtents
Definition: FDRRecords.h:110
llvm::xray::NewCPUIDRecord
Definition: FDRRecords.h:158
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::xray::NewBufferRecord
Definition: FDRRecords.h:336
llvm::xray::XRayRecord::TSC
uint64_t TSC
Get the full 8 bytes of the TSC when we get the log record.
Definition: XRayRecord.h:86
llvm::xray::RecordTypes::CUSTOM_EVENT
@ CUSTOM_EVENT
llvm::xray::TraceExpander::flush
Error flush()
Definition: FDRTraceExpander.cpp:125
llvm::xray::XRayRecord::PId
uint32_t PId
The process ID for the currently running process.
Definition: XRayRecord.h:92
llvm::xray::TraceExpander::visit
Error visit(BufferExtents &) override
Definition: FDRTraceExpander.cpp:21
llvm::xray::EndBufferRecord
Definition: FDRRecords.h:359
llvm::xray::WallclockRecord
Definition: FDRRecords.h:133
llvm::xray::CallArgRecord
Definition: FDRRecords.h:291
llvm::xray::TypedEventRecord
Definition: FDRRecords.h:262
llvm::xray::TSCWrapRecord
Definition: FDRRecords.h:184
llvm::xray::XRayRecord::Type
RecordTypes Type
Identifies the type of record.
Definition: XRayRecord.h:80
llvm::xray::XRayRecord::FuncId
int32_t FuncId
The function ID for the record, if this is a function call record.
Definition: XRayRecord.h:83
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::xray::XRayRecord::Data
std::string Data
For custom and typed events, we provide the raw data from the trace.
Definition: XRayRecord.h:98
llvm::xray::CustomEventRecord
Definition: FDRRecords.h:206
llvm::xray::CustomEventRecordV5
Definition: FDRRecords.h:235
llvm::xray::XRayRecord::CallArgs
std::vector< uint64_t > CallArgs
The function call arguments.
Definition: XRayRecord.h:95
FDRTraceExpander.h
llvm::xray::RecordTypes::ENTER_ARG
@ ENTER_ARG