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

Coverage information generated Thu Mar 26 16:15:41 2015.