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

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%24240.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    :  // Contains the implementation details of the templated functions of Asan's
  16    :  // shadow memory. See 'shadow.h' for more information. This file is not
  17    :  // meant to be included directly, but is brought in by shadow.h.
  18    :  #ifndef SYZYGY_AGENT_ASAN_SHADOW_IMPL_H_
  19    :  #define SYZYGY_AGENT_ASAN_SHADOW_IMPL_H_
  20    :  
  21    :  template<typename type>
  22    :  bool Shadow::GetNullTerminatedArraySize(const void* addr,
  23    :                                          size_t max_size,
  24  E :                                          size_t* size) const {
  25  E :    DCHECK_NE(reinterpret_cast<const void*>(NULL), addr);
  26  E :    DCHECK_NE(reinterpret_cast<size_t*>(NULL), size);
  27    :  
  28  E :    uintptr_t index = reinterpret_cast<uintptr_t>(addr);
  29  E :    const type* addr_value = reinterpret_cast<const type*>(addr);
  30  E :    index >>= 3;
  31  E :    *size = 0;
  32    :  
  33    :    // Scan the input array 8 bytes at a time until we've found a NULL value or
  34    :    // we've reached the end of an accessible memory block.
  35    :    // TODO(sebmarchand): Look into doing this more efficiently.
  36  E :    while (true) {
  37  E :      uint8 shadow = shadow_[index++];
  38  E :      if (ShadowMarkerHelper::IsRedzone(shadow))
  39  E :        return false;
  40    :  
  41  E :      uint8 max_index = shadow ? shadow : kShadowRatio;
  42  E :      DCHECK_EQ(0U, max_index % sizeof(type));
  43  E :      max_index /= sizeof(type);
  44  E :      while (max_index-- > 0) {
  45  E :        (*size) += sizeof(type);
  46  E :        if (*size == max_size || *addr_value == 0)
  47  E :          return true;
  48  E :        addr_value++;
  49  E :      }
  50    :  
  51  E :      if (shadow != 0)
  52  E :        return false;
  53  E :    }
  54  E :  }
  55    :  
  56    :  #endif  // SYZYGY_AGENT_ASAN_SHADOW_IMPL_H_

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