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

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%330.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    :  // Utility functions used by the Asan check functions..
  16    :  #ifndef SYZYGY_AGENT_ASAN_RTL_UTILS_H_
  17    :  #define SYZYGY_AGENT_ASAN_RTL_UTILS_H_
  18    :  
  19    :  #include <windows.h>
  20    :  
  21    :  #include "syzygy/agent/asan/error_info.h"
  22    :  
  23    :  namespace agent {
  24    :  namespace asan {
  25    :  
  26    :  // Forward declarations.
  27    :  class AsanRuntime;
  28    :  class Shadow;
  29    :  
  30    :  // Contents of the registers before calling the Asan memory check function.
  31    :  #pragma pack(push, 1)
  32    :  struct AsanContext {
  33    :    DWORD original_edi;
  34    :    DWORD original_esi;
  35    :    DWORD original_ebp;
  36    :    DWORD original_esp;
  37    :    DWORD original_ebx;
  38    :    DWORD original_edx;
  39    :    DWORD original_ecx;
  40    :    DWORD original_eax;
  41    :    DWORD original_eflags;
  42    :    DWORD original_eip;
  43    :  };
  44    :  #pragma pack(pop)
  45    :  
  46    :  // Set the AsanRuntime instance that should be used to report the crash.
  47    :  // @param runtime The runtime instance to use.
  48    :  void SetAsanRuntimeInstance(AsanRuntime* runtime);
  49    :  
  50    :  // Convert a CONTEXT struct to an Asan context.
  51    :  // @param context The context to convert.
  52    :  // @param asan_context Receives the Asan context.
  53    :  void ContextToAsanContext(const CONTEXT& context, AsanContext* asan_context);
  54    :  
  55    :  // Report a bad access to the memory.
  56    :  // @param location The memory address of the access.
  57    :  // @param access_mode The mode of the access.
  58    :  // @param access_size The size of the access.
  59    :  // @param asan_context The context of the access.
  60    :  void ReportBadMemoryAccess(void* location,
  61    :                             AccessMode access_mode,
  62    :                             size_t access_size,
  63    :                             const AsanContext& asan_context);
  64    :  
  65    :  // Report an invalid access to @p location.
  66    :  // @param location The memory address of the access.
  67    :  // @param access_mode The mode of the access.
  68    :  void ReportBadAccess(const uint8* location, AccessMode access_mode);
  69    :  
  70    :  // Test that a memory range is accessible. Report an error if it's not.
  71    :  // @param shadow The shadow memory to use.
  72    :  // @param memory The pointer to the beginning of the memory range that we want
  73    :  //     to check.
  74    :  // @param size The size of the memory range that we want to check.
  75    :  // @param access_mode The access mode.
  76    :  void TestMemoryRange(Shadow* shadow,
  77    :                       const uint8* memory,
  78    :                       size_t size,
  79    :                       AccessMode access_mode);
  80    :  
  81    :  // Helper function to test if the memory range of a given structure is
  82    :  // accessible.
  83    :  // @tparam T the type of the structure to be tested.
  84    :  // @param shadow The shadow memory to use.
  85    :  // @param structure A pointer to this structure.
  86    :  // @param access mode The access mode.
  87    :  template <typename T>
  88  E :  void TestStructure(Shadow* shadow, const T* structure, AccessMode access_mode) {
  89    :    TestMemoryRange(shadow, reinterpret_cast<const uint8*>(structure), sizeof(T),
  90  E :                    access_mode);
  91  E :  }
  92    :  
  93    :  }  // namespace asan
  94    :  }  // namespace agent
  95    :  
  96    :  
  97    :  #endif  // SYZYGY_AGENT_ASAN_RTL_UTILS_H_

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