LCOV - code coverage report
Current view: top level - include/llvm/XRay - YAMLXRayRecord.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 26 26 100.0 %
Date: 2017-09-14 15:23:50 Functions: 4 4 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        6026 : 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             : };
      41             : 
      42         189 : struct YAMLXRayTrace {
      43             :   YAMLXRayFileHeader Header;
      44             :   std::vector<YAMLXRayRecord> Records;
      45             : };
      46             : 
      47             : } // namespace xray
      48             : 
      49             : namespace yaml {
      50             : 
      51             : // YAML Traits
      52             : // -----------
      53             : template <> struct ScalarEnumerationTraits<xray::RecordTypes> {
      54         627 :   static void enumeration(IO &IO, xray::RecordTypes &Type) {
      55         627 :     IO.enumCase(Type, "function-enter", xray::RecordTypes::ENTER);
      56         627 :     IO.enumCase(Type, "function-exit", xray::RecordTypes::EXIT);
      57         627 :   }
      58             : };
      59             : 
      60             : template <> struct MappingTraits<xray::YAMLXRayFileHeader> {
      61          63 :   static void mapping(IO &IO, xray::YAMLXRayFileHeader &Header) {
      62         126 :     IO.mapRequired("version", Header.Version);
      63         126 :     IO.mapRequired("type", Header.Type);
      64         126 :     IO.mapRequired("constant-tsc", Header.ConstantTSC);
      65         126 :     IO.mapRequired("nonstop-tsc", Header.NonstopTSC);
      66         126 :     IO.mapRequired("cycle-frequency", Header.CycleFrequency);
      67          63 :   }
      68             : };
      69             : 
      70             : template <> struct MappingTraits<xray::YAMLXRayRecord> {
      71         627 :   static void mapping(IO &IO, xray::YAMLXRayRecord &Record) {
      72             :     // FIXME: Make this type actually be descriptive
      73        1254 :     IO.mapRequired("type", Record.RecordType);
      74        1254 :     IO.mapRequired("func-id", Record.FuncId);
      75        1254 :     IO.mapOptional("function", Record.Function);
      76        1254 :     IO.mapRequired("cpu", Record.CPU);
      77        1254 :     IO.mapRequired("thread", Record.TId);
      78        1254 :     IO.mapRequired("kind", Record.Type);
      79        1254 :     IO.mapRequired("tsc", Record.TSC);
      80         627 :   }
      81             : 
      82             :   static constexpr bool flow = true;
      83             : };
      84             : 
      85             : template <> struct MappingTraits<xray::YAMLXRayTrace> {
      86          63 :   static void mapping(IO &IO, xray::YAMLXRayTrace &Trace) {
      87             :     // A trace file contains two parts, the header and the list of all the
      88             :     // trace records.
      89         126 :     IO.mapRequired("header", Trace.Header);
      90         126 :     IO.mapRequired("records", Trace.Records);
      91          63 :   }
      92             : };
      93             : 
      94             : } // namespace yaml
      95             : } // namespace llvm
      96             : 
      97             : LLVM_YAML_IS_SEQUENCE_VECTOR(xray::YAMLXRayRecord)
      98             : 
      99             : #endif // LLVM_XRAY_YAML_XRAY_RECORD_H

Generated by: LCOV version 1.13