Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:46

0001 //===- FDRTraceExpander.h - XRay FDR Mode Log Expander --------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // We define an FDR record visitor which can re-constitute XRayRecord instances
0010 // from a sequence of FDR mode records in arrival order into a collection.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 #ifndef LLVM_XRAY_FDRTRACEEXPANDER_H
0014 #define LLVM_XRAY_FDRTRACEEXPANDER_H
0015 
0016 #include "llvm/ADT/STLExtras.h"
0017 #include "llvm/XRay/FDRRecords.h"
0018 #include "llvm/XRay/XRayRecord.h"
0019 
0020 namespace llvm {
0021 namespace xray {
0022 
0023 class TraceExpander : public RecordVisitor {
0024   // Type-erased callback for handling individual XRayRecord instances.
0025   function_ref<void(const XRayRecord &)> C;
0026   int32_t PID = 0;
0027   int32_t TID = 0;
0028   uint64_t BaseTSC = 0;
0029   XRayRecord CurrentRecord{0, 0, RecordTypes::ENTER, 0, 0, 0, 0, {}, {}};
0030   uint16_t CPUId = 0;
0031   uint16_t LogVersion = 0;
0032   bool BuildingRecord = false;
0033   bool IgnoringRecords = false;
0034 
0035   void resetCurrentRecord();
0036 
0037 public:
0038   explicit TraceExpander(function_ref<void(const XRayRecord &)> F, uint16_t L)
0039       : C(std::move(F)), LogVersion(L) {}
0040 
0041   Error visit(BufferExtents &) override;
0042   Error visit(WallclockRecord &) override;
0043   Error visit(NewCPUIDRecord &) override;
0044   Error visit(TSCWrapRecord &) override;
0045   Error visit(CustomEventRecord &) override;
0046   Error visit(CallArgRecord &) override;
0047   Error visit(PIDRecord &) override;
0048   Error visit(NewBufferRecord &) override;
0049   Error visit(EndBufferRecord &) override;
0050   Error visit(FunctionRecord &) override;
0051   Error visit(CustomEventRecordV5 &) override;
0052   Error visit(TypedEventRecord &) override;
0053 
0054   // Must be called after all the records have been processed, to handle the
0055   // most recent record generated.
0056   Error flush();
0057 };
0058 
0059 } // namespace xray
0060 } // namespace llvm
0061 
0062 #endif // LLVM_XRAY_FDRTRACEEXPANDER_H