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

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
0.0%0031.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    :    // Set up the shadow memory.
  30  m :    static void SetUp();
  31    :  
  32    :    // Tear down the shadow memory.
  33  m :    static void TearDown();
  34    :  
  35    :    // The different markers we use to mark the shadow memory.
  36  m :    enum ShadowMarker {
  37  m :      kHeapAddressableByte = 0x00,
  38  m :      kHeapNonAccessibleByteMask = 0xf0,
  39  m :      kAsanMemoryByte = 0xf1,
  40  m :      kHeapLeftRedzone = 0xfa,
  41  m :      kHeapRightRedzone = 0xfb,
  42  m :      kHeapFreedByte = 0xfd,
  43  m :    };
  44    :  
  45    :    // Poisons @p size bytes starting at @p addr with @p shadow_val value.
  46    :    // @pre addr + size mod 8 == 0.
  47  m :    static void Poison(const void* addr, size_t size, ShadowMarker shadow_val);
  48    :  
  49    :    // Un-poisons @p size bytes starting at @p addr.
  50    :    // @pre addr mod 8 == 0 && size mod 8 == 0.
  51  m :    static void Unpoison(const void* addr, size_t size);
  52    :  
  53    :    // Mark @p size bytes starting at @p addr as freed.
  54  m :    static void MarkAsFreed(const void* addr, size_t size);
  55    :  
  56    :    // Returns true iff the byte at @p addr is not poisoned.
  57  m :    static bool IsAccessible(const void* addr);
  58    :  
  59    :    // Returns the ShadowMarker value for the byte at @p addr.
  60  m :    static ShadowMarker GetShadowMarkerForAddress(const void* addr);
  61    :  
  62    :    // Appends a textual description of the shadow memory for @p addr to
  63    :    // @p output.
  64  m :    static void AppendShadowMemoryText(const void* addr, std::string* output);
  65    :  
  66  m :   protected:
  67    :    // Reset the shadow memory.
  68  m :    static void Reset();
  69    :  
  70    :    // Appends a line of shadow byte text for the bytes ranging from
  71    :    // shadow_[index] to shadow_[index + 7], prefixed by @p prefix. If the index
  72    :    // @p bug_index is present in this range then its value will be surrounded by
  73    :    // brackets.
  74  m :    static void AppendShadowByteText(const char *prefix,
  75  m :                                     uintptr_t index,
  76  m :                                     std::string* output,
  77  m :                                     size_t bug_index);
  78    :  
  79    :    // One shadow byte for every 8 bytes in a 2G address space. By default Chrome
  80    :    // is not large address aware, so we shouldn't be using the high memory.
  81  m :    static const size_t kShadowSize = 1 << (31 - 3);
  82  m :    static uint8 shadow_[kShadowSize];
  83  m :  };
  84    :  
  85  m :  }  // namespace asan
  86  m :  }  // namespace agent
  87    :  
  88    :  #endif  // SYZYGY_AGENT_ASAN_ASAN_SHADOW_H_

Coverage information generated Thu Jul 04 09:34:53 2013.