LCOV - code coverage report
Current view: top level - include/llvm/XRay - BlockIndexer.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 3 3 100.0 %
Date: 2018-10-20 13:21:21 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- BlockIndexer.h - FDR Block Indexing Visitor ------------------------===//
       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             : // An implementation of the RecordVisitor which generates a mapping between a
      11             : // thread and a range of records representing a block.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : #ifndef LLVM_LIB_XRAY_BLOCKINDEXER_H_
      15             : #define LLVM_LIB_XRAY_BLOCKINDEXER_H_
      16             : 
      17             : #include "llvm/ADT/DenseMap.h"
      18             : #include "llvm/XRay/FDRRecords.h"
      19             : #include <cstdint>
      20             : #include <vector>
      21             : 
      22             : namespace llvm {
      23             : namespace xray {
      24             : 
      25             : // The BlockIndexer will gather all related records associated with a
      26             : // process+thread and group them by 'Block'.
      27          11 : class BlockIndexer : public RecordVisitor {
      28             : public:
      29          58 :   struct Block {
      30             :     uint64_t ProcessID;
      31             :     int32_t ThreadID;
      32             :     WallclockRecord *WallclockTime;
      33             :     std::vector<Record *> Records;
      34             :   };
      35             : 
      36             :   // This maps the process + thread combination to a sequence of blocks.
      37             :   using Index = DenseMap<std::pair<uint64_t, int32_t>, std::vector<Block>>;
      38             : 
      39             : private:
      40             :   Index &Indices;
      41             : 
      42             :   Block CurrentBlock{0, 0, nullptr, {}};
      43             : 
      44             : public:
      45          11 :   explicit BlockIndexer(Index &I) : RecordVisitor(), Indices(I) {}
      46             : 
      47             :   Error visit(BufferExtents &) override;
      48             :   Error visit(WallclockRecord &) override;
      49             :   Error visit(NewCPUIDRecord &) override;
      50             :   Error visit(TSCWrapRecord &) override;
      51             :   Error visit(CustomEventRecord &) override;
      52             :   Error visit(CallArgRecord &) override;
      53             :   Error visit(PIDRecord &) override;
      54             :   Error visit(NewBufferRecord &) override;
      55             :   Error visit(EndBufferRecord &) override;
      56             :   Error visit(FunctionRecord &) override;
      57             : 
      58             :   /// The flush() function will clear out the current state of the visitor, to
      59             :   /// allow for explicitly flushing a block's records to the currently
      60             :   /// recognized thread and process combination.
      61             :   Error flush();
      62             : };
      63             : 
      64             : } // namespace xray
      65             : } // namespace llvm
      66             : 
      67             : #endif // LLVM_LIB_XRAY_BLOCKINDEXER_H_

Generated by: LCOV version 1.13