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

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%990.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    :  // Implementation of the SyzyAsan instrumentation transform.
  16    :  
  17    :  #ifndef SYZYGY_INSTRUMENT_TRANSFORMS_ASAN_TRANSFORM_H_
  18    :  #define SYZYGY_INSTRUMENT_TRANSFORMS_ASAN_TRANSFORM_H_
  19    :  
  20    :  #include <set>
  21    :  #include <string>
  22    :  #include <utility>
  23    :  
  24    :  #include "base/string_piece.h"
  25    :  #include "syzygy/block_graph/iterate.h"
  26    :  #include "syzygy/block_graph/transforms/iterative_transform.h"
  27    :  #include "syzygy/block_graph/transforms/named_transform.h"
  28    :  
  29    :  namespace instrument {
  30    :  namespace transforms {
  31    :  
  32    :  // This class implements the transformation applied to each basic block.
  33    :  class AsanBasicBlockTransform
  34    :      : public block_graph::transforms::NamedBasicBlockSubGraphTransformImpl<
  35    :            AsanBasicBlockTransform> {
  36    :   public:
  37    :    typedef block_graph::BlockGraph BlockGraph;
  38    :    typedef block_graph::BasicBlockSubGraph BasicBlockSubGraph;
  39    :  
  40    :    // Constructor.
  41    :    // @param hook_access a reference to the access check import entry.
  42    :    explicit AsanBasicBlockTransform(BlockGraph::Reference* hook_access) :
  43  E :        hook_access_(hook_access) {
  44  E :      DCHECK(hook_access != NULL);
  45  E :    }
  46    :  
  47    :    // The transform name.
  48    :    static const char kTransformName[];
  49    :  
  50    :   protected:
  51    :    // @name BasicBlockSubGraphTransformInterface method.
  52    :    virtual bool TransformBasicBlockSubGraph(BlockGraph* block_graph,
  53    :        BasicBlockSubGraph* basic_block_subgraph) OVERRIDE;
  54    :  
  55    :    // Instruments the memory accesses in a basic block.
  56    :    // @param basic_block The basic block to be instrumented.
  57    :    // @returns true on success, false otherwise.
  58    :    bool InstrumentBasicBlock(block_graph::BasicBlock* basic_block);
  59    :  
  60    :   private:
  61    :    // The references to the Asan access check import entry.
  62    :    BlockGraph::Reference* hook_access_;
  63    :  
  64    :    DISALLOW_COPY_AND_ASSIGN(AsanBasicBlockTransform);
  65    :  };
  66    :  
  67    :  class AsanTransform
  68    :      : public block_graph::transforms::IterativeTransformImpl<AsanTransform> {
  69    :   public:
  70    :    typedef block_graph::BlockGraph BlockGraph;
  71    :  
  72    :    // Initialize a new AsanTransform instance.
  73    :    AsanTransform();
  74    :  
  75    :    // @name IterativeTransformImpl implementation.
  76    :    // @{
  77    :    bool PreBlockGraphIteration(BlockGraph* block_graph,
  78    :                                BlockGraph::Block* header_block);
  79    :    bool OnBlock(BlockGraph* block_graph, BlockGraph::Block* block);
  80    :    bool PostBlockGraphIteration(BlockGraph* block_graph,
  81    :                                 BlockGraph::Block* header_block);
  82    :    // @}
  83    :  
  84    :    // @name Accessors.
  85    :    // @{
  86  E :    void set_instrument_dll_name(const base::StringPiece& instrument_dll_name) {
  87  E :      instrument_dll_name.CopyToString(&asan_dll_name_);
  88  E :    }
  89  E :    const char* instrument_dll_name() const {
  90  E :      return asan_dll_name_.c_str();
  91  E :    }
  92    :    // @}
  93    :  
  94    :    // The names of the imports for the Asan hooks.
  95    :    static const char kCheckAccessName[];
  96    :  
  97    :    // The name of the DLL that is imported by default.
  98    :    static const char kSyzyAsanDll[];
  99    :  
 100    :    // The transform name.
 101    :    static const char kTransformName[];
 102    :  
 103    :   protected:
 104    :    // Name of the asan_rtl DLL we import. Defaults to "asan_rtl.dll".
 105    :    std::string asan_dll_name_;
 106    :  
 107    :    // References to "asan_check_access" import entry. Valid after successful
 108    :    // PreBlockGraphIteration.
 109    :    BlockGraph::Reference hook_asan_check_access_;
 110    :  
 111    :    DISALLOW_COPY_AND_ASSIGN(AsanTransform);
 112    :  };
 113    :  
 114    :  }  // namespace transforms
 115    :  }  // namespace instrument
 116    :  
 117    :  #endif  // SYZYGY_INSTRUMENT_TRANSFORMS_ASAN_TRANSFORM_H_

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