Coverage for /Syzygy/refinery/testing/self_bit_source.cc

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
77.8%21270.C++test

Line-by-line coverage:

   1    :  // Copyright 2015 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 a bit source that reads its own process' memory.
  16    :  #include "syzygy/refinery/testing/self_bit_source.h"
  17    :  
  18    :  #include <Windows.h>
  19    :  
  20    :  namespace testing {
  21    :  
  22  E :  SelfBitSource::~SelfBitSource() {
  23  E :  }
  24    :  
  25    :  bool SelfBitSource::GetAll(const refinery::AddressRange& range,
  26  E :                             void* data_ptr) {
  27  E :    DCHECK(range.IsValid());
  28  E :    DCHECK(data_ptr);
  29    :  
  30  E :    size_t read_bytes = 0;
  31  E :    if (!GetFrom(range, &read_bytes, data_ptr))
  32  i :      return false;
  33  E :    if (read_bytes != range.size())
  34  i :      return false;
  35    :  
  36  E :    return true;
  37  E :  }
  38    :  
  39    :  bool SelfBitSource::GetFrom(const refinery::AddressRange& range,
  40    :                              size_t* data_cnt,
  41  E :                              void* data_ptr) {
  42  E :    DCHECK(range.IsValid());
  43  E :    DCHECK(data_cnt);
  44  E :    DCHECK(data_ptr);
  45    :  
  46  E :    *data_cnt = 0;
  47    :  
  48  E :    DWORD read_bytes = 0;
  49    :    BOOL succeeded = ::ReadProcessMemory(
  50    :        ::GetCurrentProcess(), reinterpret_cast<const void*>(range.start()),
  51  E :        data_ptr, range.size(), &read_bytes);
  52  E :    if (!succeeded)
  53  i :      return false;
  54  E :    *data_cnt = read_bytes;
  55    :  
  56  E :    return read_bytes != 0;
  57  E :  }
  58    :  
  59  i :  bool SelfBitSource::HasSome(const refinery::AddressRange& range) {
  60    :    // TODO(siggi): Fixme!
  61  i :    return true;
  62  i :  }
  63    :  
  64    :  }  // namespace testing

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