Coverage for /Syzygy/agent/asan/memory_notifiers/shadow_memory_notifier.cc

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

Line-by-line coverage:

   1    :  // Copyright 2014 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    :  #include "syzygy/agent/asan/memory_notifiers/shadow_memory_notifier.h"
  16    :  
  17    :  #include "syzygy/agent/asan/shadow.h"
  18    :  #include "syzygy/common/align.h"
  19    :  
  20    :  namespace agent {
  21    :  namespace asan {
  22    :  namespace memory_notifiers {
  23    :  
  24    :  namespace {
  25    :  
  26  E :  void AlignRange(const void** address, size_t* size) {
  27  E :    DCHECK_NE(reinterpret_cast<void**>(nullptr), address);
  28  E :    DCHECK_NE(reinterpret_cast<size_t*>(nullptr), size);
  29  E :    const uint8* start = reinterpret_cast<const uint8*>(*address);
  30  E :    const uint8* end = start + *size;
  31  E :    start = ::common::AlignDown(start, kShadowRatio);
  32  E :    end = ::common::AlignUp(end, kShadowRatio);
  33  E :    *address = start;
  34  E :    *size = end - start;
  35  E :  }
  36    :  
  37    :  }  // namespace
  38    :  
  39    :  void ShadowMemoryNotifier::NotifyInternalUse(
  40  E :      const void* address, size_t size) {
  41  E :    DCHECK_NE(static_cast<void*>(nullptr), address);
  42  E :    AlignRange(&address, &size);
  43  E :    shadow_->Poison(address, size, kAsanMemoryMarker);
  44  E :  }
  45    :  
  46    :  void ShadowMemoryNotifier::NotifyFutureHeapUse(
  47  E :      const void* address, size_t size) {
  48  E :    DCHECK_NE(static_cast<void*>(nullptr), address);
  49  E :    AlignRange(&address, &size);
  50  E :    shadow_->Poison(address, size, kAsanReservedMarker);
  51  E :  }
  52    :  
  53    :  void ShadowMemoryNotifier::NotifyReturnedToOS(
  54  E :      const void* address, size_t size) {
  55  E :    DCHECK_NE(static_cast<void*>(nullptr), address);
  56  E :    AlignRange(&address, &size);
  57  E :    shadow_->Unpoison(address, size);
  58  E :  }
  59    :  
  60    :  }  // namespace memory_notifiers
  61    :  }  // namespace asan
  62    :  }  // namespace agent

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