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 //===----------------------------------------------------------------------===// 9 #include "llvm/XRay/FDRTraceExpander.h" 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 22 Error TraceExpander::visit(BufferExtents &) { 23 resetCurrentRecord(); 24 return Error::success(); 25 } 26 27 Error TraceExpander::visit(WallclockRecord &) { return Error::success(); } 28 29 Error TraceExpander::visit(NewCPUIDRecord &R) { 30 CPUId = R.cpuid(); 31 BaseTSC = R.tsc(); 32 return Error::success(); 33 } 34 35 Error TraceExpander::visit(TSCWrapRecord &R) { 36 BaseTSC = R.tsc(); 37 return Error::success(); 38 } 39 40 Error TraceExpander::visit(CustomEventRecord &R) { 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 54 Error TraceExpander::visit(CustomEventRecordV5 &R) { 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 69 Error TraceExpander::visit(TypedEventRecord &R) { 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 85 Error TraceExpander::visit(CallArgRecord &R) { 86 CurrentRecord.CallArgs.push_back(R.arg()); 87 CurrentRecord.Type = RecordTypes::ENTER_ARG; 88 return Error::success(); 89 } 90 91 Error TraceExpander::visit(PIDRecord &R) { 92 PID = R.pid(); 93 return Error::success(); 94 } 95 96 Error TraceExpander::visit(NewBufferRecord &R) { 97 if (IgnoringRecords) 98 IgnoringRecords = false; 99 TID = R.tid(); 100 if (LogVersion == 2) 101 PID = R.tid(); 102 return Error::success(); 103 } 104 105 Error TraceExpander::visit(EndBufferRecord &) { 106 IgnoringRecords = true; 107 resetCurrentRecord(); 108 return Error::success(); 109 } 110 111 Error TraceExpander::visit(FunctionRecord &R) { 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 126 Error TraceExpander::flush() { 127 resetCurrentRecord(); 128 return Error::success(); 129 } 130 131 } // namespace xray 132 } // namespace llvm 133