Coverage for /Syzygy/pe/pe_transform_policy.h

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

Line-by-line coverage:

   1    :  // Copyright 2013 Google Inc. All Rights Reserved.
   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 the PE-specific transform policy object. This guides decisions made
  16    :  // during image decomposition, basic-block decomposition, transforms and block
  17    :  // building.
  18    :  
  19    :  #ifndef SYZYGY_PE_PE_TRANSFORM_POLICY_H_
  20    :  #define SYZYGY_PE_PE_TRANSFORM_POLICY_H_
  21    :  
  22    :  #include "syzygy/block_graph/transform_policy.h"
  23    :  
  24    :  namespace pe {
  25    :  
  26    :  // The interface that guides image and basic-block transform decisions for PE
  27    :  // files.
  28    :  class PETransformPolicy : public block_graph::TransformPolicyInterface {
  29    :   public:
  30    :    PETransformPolicy();
  31  E :    virtual ~PETransformPolicy() { }
  32    :  
  33    :    // @name TransformPolicyInterface implementation
  34    :    // @{
  35    :    virtual bool BlockIsSafeToBasicBlockDecompose(
  36    :        const BlockGraph::Block* block) const override;
  37    :    virtual bool ReferenceIsSafeToRedirect(
  38    :        const BlockGraph::Block* referrer,
  39    :        const BlockGraph::Reference& reference) const override;
  40    :    // @}
  41    :  
  42  E :    bool allow_inline_assembly() const { return allow_inline_assembly_; }
  43  E :    void set_allow_inline_assembly(bool value) {
  44  E :      allow_inline_assembly_ = value;
  45  E :    }
  46    :  
  47    :    // TODO(chrisha): When Decomposer disappears (the last place doing disassembly
  48    :    //     that is *not* the basic-block decomposer), make these protected member
  49    :    //     functions.
  50    :  
  51    :    // Internal implementation details. Exposed for unittesting.
  52    :    bool CodeBlockIsSafeToBasicBlockDecompose(
  53    :        const BlockGraph::Block* code_block) const;
  54    :    // Checks that the attributes (derived from symbol data) are consistent.
  55    :    static bool CodeBlockAttributesAreBasicBlockSafe(
  56    :        const BlockGraph::Block* code_block,
  57    :        bool allow_inline_assembly);
  58    :    // Checks that a block contains private symbols. These are required for
  59    :    // basic block disassembly.
  60    :    static bool CodeBlockHasPrivateSymbols(const BlockGraph::Block* code_block);
  61    :    // Checks that the code-data layout of the block is consistent. Assumes that
  62    :    // the block attributes have already been checked and are valid.
  63    :    static bool CodeBlockLayoutIsClConsistent(
  64    :        const BlockGraph::Block* code_block);
  65    :    // Checks that all outgoing references are consistent. Assumes that the block
  66    :    // attributes have already been checked and are valid.
  67    :    static bool CodeBlockReferencesAreClConsistent(
  68    :        const BlockGraph::Block* code_block);
  69    :    // Checks that all referrers are consistent. Assumes that the block layout has
  70    :    // already been checked and is valid.
  71    :    static bool CodeBlockReferrersAreClConsistent(
  72    :        const BlockGraph::Block* code_block);
  73    :  
  74    :   protected:
  75    :    // Block IDs are stable, unique and can't be reused. That makes them perfect
  76    :    // for a cache ID.
  77    :    typedef std::map<const BlockGraph::BlockId, bool> BlockResultCache;
  78    :    scoped_ptr<BlockResultCache> block_result_cache_;
  79    :  
  80    :    // Determines whether or not we will allow decomposition of blocks with
  81    :    // inline assembly.
  82    :    bool allow_inline_assembly_;
  83    :  
  84    :    DISALLOW_COPY_AND_ASSIGN(PETransformPolicy);
  85    :  };
  86    :  
  87    :  }  // namespace pe
  88    :  
  89    :  #endif  // SYZYGY_PE_PE_TRANSFORM_POLICY_H_

Coverage information generated Thu Jan 14 17:40:38 2016.