LCOV - code coverage report
Current view: top level - include/llvm/XRay - YAMLXRayRecord.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 29 29 100.0 %
Date: 2018-06-17 00:07:59 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- YAMLXRayRecord.h - XRay Record YAML Support Definitions ------------===//
       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             : //
      10             : // Types and traits specialisations for YAML I/O of XRay log entries.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : #ifndef LLVM_XRAY_YAML_XRAY_RECORD_H
      14             : #define LLVM_XRAY_YAML_XRAY_RECORD_H
      15             : 
      16             : #include <type_traits>
      17             : 
      18             : #include "llvm/Support/YAMLTraits.h"
      19             : #include "llvm/XRay/XRayRecord.h"
      20             : 
      21             : namespace llvm {
      22             : namespace xray {
      23             : 
      24             : struct YAMLXRayFileHeader {
      25             :   uint16_t Version;
      26             :   uint16_t Type;
      27             :   bool ConstantTSC;
      28             :   bool NonstopTSC;
      29             :   uint64_t CycleFrequency;
      30             : };
      31             : 
      32        5791 : struct YAMLXRayRecord {
      33             :   uint16_t RecordType;
      34             :   uint16_t CPU;
      35             :   RecordTypes Type;
      36             :   int32_t FuncId;
      37             :   std::string Function;
      38             :   uint64_t TSC;
      39             :   uint32_t TId;
      40             :   std::vector<uint64_t> CallArgs;
      41             : };
      42             : 
      43          65 : struct YAMLXRayTrace {
      44             :   YAMLXRayFileHeader Header;
      45             :   std::vector<YAMLXRayRecord> Records;
      46             : };
      47             : 
      48             : } // namespace xray
      49             : 
      50             : namespace yaml {
      51             : 
      52             : // YAML Traits
      53             : // -----------
      54             : template <> struct ScalarEnumerationTraits<xray::RecordTypes> {
      55         633 :   static void enumeration(IO &IO, xray::RecordTypes &Type) {
      56         633 :     IO.enumCase(Type, "function-enter", xray::RecordTypes::ENTER);
      57         633 :     IO.enumCase(Type, "function-exit", xray::RecordTypes::EXIT);
      58         633 :     IO.enumCase(Type, "function-tail-exit", xray::RecordTypes::TAIL_EXIT);
      59         633 :     IO.enumCase(Type, "function-enter-arg", xray::RecordTypes::ENTER_ARG);
      60         633 :   }
      61             : };
      62             : 
      63             : template <> struct MappingTraits<xray::YAMLXRayFileHeader> {
      64          65 :   static void mapping(IO &IO, xray::YAMLXRayFileHeader &Header) {
      65          65 :     IO.mapRequired("version", Header.Version);
      66          65 :     IO.mapRequired("type", Header.Type);
      67          65 :     IO.mapRequired("constant-tsc", Header.ConstantTSC);
      68          65 :     IO.mapRequired("nonstop-tsc", Header.NonstopTSC);
      69          65 :     IO.mapRequired("cycle-frequency", Header.CycleFrequency);
      70          65 :   }
      71             : };
      72             : 
      73             : template <> struct MappingTraits<xray::YAMLXRayRecord> {
      74         633 :   static void mapping(IO &IO, xray::YAMLXRayRecord &Record) {
      75             :     // FIXME: Make this type actually be descriptive
      76         633 :     IO.mapRequired("type", Record.RecordType);
      77         633 :     IO.mapRequired("func-id", Record.FuncId);
      78         633 :     IO.mapOptional("function", Record.Function);
      79         633 :     IO.mapOptional("args", Record.CallArgs);
      80         633 :     IO.mapRequired("cpu", Record.CPU);
      81         633 :     IO.mapRequired("thread", Record.TId);
      82         633 :     IO.mapRequired("kind", Record.Type);
      83         633 :     IO.mapRequired("tsc", Record.TSC);
      84         633 :   }
      85             : 
      86             :   static constexpr bool flow = true;
      87             : };
      88             : 
      89             : template <> struct MappingTraits<xray::YAMLXRayTrace> {
      90          65 :   static void mapping(IO &IO, xray::YAMLXRayTrace &Trace) {
      91             :     // A trace file contains two parts, the header and the list of all the
      92             :     // trace records.
      93          65 :     IO.mapRequired("header", Trace.Header);
      94          65 :     IO.mapRequired("records", Trace.Records);
      95          65 :   }
      96             : };
      97             : 
      98             : } // namespace yaml
      99             : } // namespace llvm
     100             : 
     101             : LLVM_YAML_IS_SEQUENCE_VECTOR(xray::YAMLXRayRecord)
     102             : 
     103             : #endif // LLVM_XRAY_YAML_XRAY_RECORD_H

Generated by: LCOV version 1.13