Coverage for /Syzygy/agent/asan/asan_shadow.h

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
0.0%0029.C++source

Line-by-line coverage:

   1    :  // Copyright 2012 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    :  // Implements an all-static class that manages shadow memory for ASAN.
  16    :  #ifndef SYZYGY_AGENT_ASAN_ASAN_SHADOW_H_
  17    :  #define SYZYGY_AGENT_ASAN_ASAN_SHADOW_H_
  18    :  
  19    :  #include <string>
  20    :  
  21    :  #include "base/basictypes.h"
  22    :  
  23  m :  namespace agent {
  24  m :  namespace asan {
  25    :  
  26    :  // An all-static class that manages the ASAN shadow memory.
  27  m :  class Shadow {
  28  m :   public:
  29    :    // The different markers we use to mark the shadow memory.
  30  m :    enum ShadowMarker {
  31  m :      kHeapAddressableByte = 0x00,
  32  m :      kHeapNonAccessibleByteMask = 0xf0,
  33  m :      kHeapLeftRedzone = 0xfa,
  34  m :      kHeapRightRedzone = 0xfb,
  35  m :      kHeapFreedByte = 0xfd,
  36  m :    };
  37    :  
  38    :    // Poisons @p size bytes starting at @p addr with @p shadow_val value.
  39    :    // @pre addr + size mod 8 == 0.
  40  m :    static void Poison(const void* addr, size_t size, ShadowMarker shadow_val);
  41    :  
  42    :    // Un-poisons @p size bytes starting at @p addr.
  43    :    // @pre addr mod 8 == 0 && size mod 8 == 0.
  44  m :    static void Unpoison(const void* addr, size_t size);
  45    :  
  46    :    // Mark @p size bytes starting at @p addr as freed.
  47  m :    static void MarkAsFreed(const void* addr, size_t size);
  48    :  
  49    :    // Returns true iff the byte at @p addr is not poisoned.
  50  m :    static bool __stdcall IsAccessible(const void* addr);
  51    :  
  52    :    // Print the contents of the shadow memory for @p addr.
  53  m :    static void PrintShadowMemoryForAddress(const void* addr);
  54    :  
  55    :    // Appends a textual description of the shadow memory for @p addr to
  56    :    // @p output.
  57  m :    static void AppendShadowMemoryText(const void* addr, std::string* output);
  58    :  
  59  m :   protected:
  60    :    // Reset the shadow memory.
  61  m :    static void Reset();
  62    :  
  63  m :   private:
  64    :    // Appends a line of shadow byte text for the bytes ranging from
  65    :    // shadow_[index] to shadow_[index + 7], prefixed by @p prefix. If the index
  66    :    // @p bug_index is present in this range then its value will be surrounded by
  67    :    // brackets.
  68  m :    static void AppendShadowByteText(const char *prefix,
  69  m :                                     uintptr_t index,
  70  m :                                     std::string* output,
  71  m :                                     size_t bug_index);
  72    :  
  73    :    // One shadow byte for every 8 bytes in a 4G address space.
  74  m :    static const size_t kShadowSize = 1 << (32 - 3);
  75  m :    static uint8 shadow_[kShadowSize];
  76  m :  };
  77    :  
  78  m :  }  // namespace asan
  79  m :  }  // namespace agent
  80    :  
  81    :  #endif  // SYZYGY_AGENT_ASAN_ASAN_SHADOW_H_

Coverage information generated Thu Mar 14 11:53:36 2013.