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 std::copy(R.data().begin(), R.data().end(), 49 std::back_inserter(CurrentRecord.Data)); 50 BuildingRecord = true; 51 } 52 return Error::success(); 53 } 54 55 Error TraceExpander::visit(CallArgRecord &R) { 56 CurrentRecord.CallArgs.push_back(R.arg()); 57 CurrentRecord.Type = RecordTypes::ENTER_ARG; 58 return Error::success(); 59 } 60 61 Error TraceExpander::visit(PIDRecord &R) { 62 PID = R.pid(); 63 return Error::success(); 64 } 65 66 Error TraceExpander::visit(NewBufferRecord &R) { 67 if (IgnoringRecords) 68 IgnoringRecords = false; 69 TID = R.tid(); 70 if (LogVersion == 2) 71 PID = R.tid(); 72 return Error::success(); 73 } 74 75 Error TraceExpander::visit(EndBufferRecord &) { 76 IgnoringRecords = true; 77 resetCurrentRecord(); 78 return Error::success(); 79 } 80 81 Error TraceExpander::visit(FunctionRecord &R) { 82 resetCurrentRecord(); 83 if (!IgnoringRecords) { 84 BaseTSC += R.delta(); 85 CurrentRecord.Type = R.recordType(); 86 CurrentRecord.FuncId = R.functionId(); 87 CurrentRecord.TSC = BaseTSC; 88 CurrentRecord.PId = PID; 89 CurrentRecord.TId = TID; 90 CurrentRecord.CPU = CPUId; 91 BuildingRecord = true; 92 } 93 return Error::success(); 94 } 95 96 Error TraceExpander::flush() { 97 resetCurrentRecord(); 98 return Error::success(); 99 } 100 101 } // namespace xray 102 } // namespace llvm 103