Coverage for /Syzygy/instrument/transforms/coverage_transform.h

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%110.C++source

Line-by-line coverage:

   1    :  // Copyright 2012 Google Inc.
   2    :  //
   3    :  // Licensed under the Apache License, Version 2.0 (the "License");
   4    :  // you may not use this file except in compliance with the License.
   5    :  // You may obtain a copy of the License at
   6    :  //
   7    :  //     http://www.apache.org/licenses/LICENSE-2.0
   8    :  //
   9    :  // Unless required by applicable law or agreed to in writing, software
  10    :  // distributed under the License is distributed on an "AS IS" BASIS,
  11    :  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12    :  // See the License for the specific language governing permissions and
  13    :  // limitations under the License.
  14    :  //
  15    :  // Declares a block-graph transform to be used by the code coverage
  16    :  // instrumenter. This transform does 4 things:
  17    :  //
  18    :  // (1) Injects an import for the run-time code coverage library.
  19    :  // (2) Grabs an entry hook and wires it up the run-time library.
  20    :  // (3) Adds a read/write data section containing code coverage information.
  21    :  // (4) Instruments each basic block to gather basic block visit information.
  22    :  
  23    :  #ifndef SYZYGY_INSTRUMENT_TRANSFORMS_COVERAGE_TRANSFORM_H_
  24    :  #define SYZYGY_INSTRUMENT_TRANSFORMS_COVERAGE_TRANSFORM_H_
  25    :  
  26    :  #include <vector>
  27    :  
  28    :  #include "syzygy/block_graph/transforms/iterative_transform.h"
  29    :  #include "syzygy/core/address_space.h"
  30    :  
  31    :  namespace instrument {
  32    :  namespace transforms {
  33    :  
  34    :  class CoverageInstrumentationTransform
  35    :      : public block_graph::transforms::IterativeTransformImpl<
  36    :            CoverageInstrumentationTransform>,
  37    :        public block_graph::transforms::NamedBasicBlockSubGraphTransformImpl<
  38    :            CoverageInstrumentationTransform> {
  39    :   public:
  40    :    typedef block_graph::BlockGraph BlockGraph;
  41    :    typedef block_graph::BasicBlockSubGraph BasicBlockSubGraph;
  42    :    typedef core::RelativeAddress RelativeAddress;
  43    :    typedef core::AddressRange<RelativeAddress, size_t> RelativeAddressRange;
  44    :    typedef std::vector<RelativeAddressRange> RelativeAddressRangeVector;
  45    :  
  46    :    // Constructor.
  47    :    CoverageInstrumentationTransform();
  48    :  
  49    :    // The name of this transform.
  50    :    static const char kTransformName[];
  51    :  
  52    :    // BasicBlockSubGraphTransform implementation.
  53    :    virtual bool TransformBasicBlockSubGraph(
  54    :        BlockGraph* block_graph,
  55    :        BasicBlockSubGraph* basic_block_subgraph) OVERRIDE;
  56    :  
  57    :    // @returns the RVAs and sizes in the original image of the instrumented basic
  58    :    //    blocks. They are in the order in which they were encountered during
  59    :    //    instrumentation, such that the index of the BB in the vector serves
  60    :    //    as its unique ID.
  61  E :    const RelativeAddressRangeVector& bb_ranges() const { return bb_ranges_; }
  62    :  
  63    :   protected:
  64    :    friend block_graph::transforms::IterativeTransformImpl<
  65    :        CoverageInstrumentationTransform>;
  66    :  
  67    :    // @name IterativeTransformImpl implementation.
  68    :    // @{
  69    :    // Called prior to iterating over the blocks. This creates the coverage
  70    :    // data block, populating coverage_data_block_ and
  71    :    // basic_block_seen_array_ref_.
  72    :    bool PreBlockGraphIteration(BlockGraph* block_graph,
  73    :                                BlockGraph::Block* header_block);
  74    :    // Called after iterating over the blocks. Increments basic_block_count_ as
  75    :    // code blocks are processed.
  76    :    bool OnBlock(BlockGraph* block_graph,
  77    :                 BlockGraph::Block* block);
  78    :    // Called after iterating over the blocks. Sets the basic-block count member
  79    :    // of coverage_data_block_.
  80    :    bool PostBlockGraphIteration(BlockGraph* block_graph,
  81    :                                 BlockGraph::Block* header_block);
  82    :    // @}
  83    :  
  84    :    // Points to the block containing coverage data.
  85    :    BlockGraph::Block* coverage_data_block_;
  86    :    // Stores the RVAs in the original image for each instrumented basic block.
  87    :    RelativeAddressRangeVector bb_ranges_;
  88    :  
  89    :    DISALLOW_COPY_AND_ASSIGN(CoverageInstrumentationTransform);
  90    :  };
  91    :  
  92    :  }  // namespace transforms
  93    :  }  // namespace instrument
  94    :  
  95    :  #endif  // SYZYGY_INSTRUMENT_TRANSFORMS_COVERAGE_TRANSFORM_H_

Coverage information generated Thu Sep 06 11:30:46 2012.