Skip to content
This repository was archived by the owner on Nov 15, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions main/OpenCover.FakesSupport/FakesDomainHelper.cs

This file was deleted.

12 changes: 5 additions & 7 deletions main/OpenCover.Profiler/CodeCoverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "NativeCallback.h"
#include "dllmain.h"



CCodeCoverage* CCodeCoverage::g_pProfiler = NULL;
// CCodeCoverage

Expand Down Expand Up @@ -100,10 +98,10 @@ HRESULT CCodeCoverage::OpenCoverInitialise(IUnknown *pICorProfilerInfoUnk){
return E_FAIL;
}

FakesInitialize(pICorProfilerInfoUnk);
OpenCoverSupportInitialize(pICorProfilerInfoUnk);

if (m_chainedProfiler == NULL){
DWORD dwMask = AppendProfilerEventMask(0);
DWORD dwMask = AppendProfilerEventMask(0);

COM_FAIL_MSG_RETURN_ERROR(m_profilerInfo2->SetEventMask(dwMask),
_T(" ::Initialize(...) => SetEventMask => 0x%X"));
Expand Down Expand Up @@ -206,8 +204,6 @@ HRESULT STDMETHODCALLTYPE CCodeCoverage::ModuleAttachedToAssembly(
if (m_chainedProfiler != NULL)
m_chainedProfiler->ModuleAttachedToAssembly(moduleId, assemblyId);

FakesModulesAttachedToAssembly(moduleId, assemblyId);

std::wstring modulePath = GetModulePath(moduleId);
std::wstring assemblyName = GetAssemblyName(assemblyId);
/*ATLTRACE(_T("::ModuleAttachedToAssembly(...) => (%X => %s, %X => %s)"),
Expand All @@ -232,7 +228,8 @@ HRESULT STDMETHODCALLTYPE CCodeCoverage::JITCompilationStarted(

if (GetTokenAndModule(functionId, functionToken, moduleId, modulePath, &assemblyId))
{
FakesSupportCompilation(functionId, functionToken, moduleId, assemblyId, modulePath);
if (OpenCoverSupportRequired(assemblyId, functionId))
OpenCoverSupportCompilation(functionId, functionToken, moduleId, assemblyId, modulePath);

CuckooSupportCompilation(assemblyId, functionToken, moduleId);

Expand Down Expand Up @@ -270,6 +267,7 @@ HRESULT STDMETHODCALLTYPE CCodeCoverage::JITCompilationStarted(
CComPtr<IMethodMalloc> methodMalloc;
COM_FAIL_MSG_RETURN_ERROR(m_profilerInfo2->GetILFunctionBodyAllocator(moduleId, &methodMalloc),
_T(" ::JITCompilationStarted(...) => GetILFunctionBodyAllocator=> 0x%X"));

IMAGE_COR_ILMETHOD* pNewMethod = (IMAGE_COR_ILMETHOD*)methodMalloc->Alloc(instumentedMethod.GetMethodSize());
instumentedMethod.WriteMethod(pNewMethod);
COM_FAIL_MSG_RETURN_ERROR(m_profilerInfo2->SetILFunctionBody(moduleId, functionToken, (LPCBYTE)pNewMethod),
Expand Down
27 changes: 16 additions & 11 deletions main/OpenCover.Profiler/CodeCoverage.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,25 @@ END_COM_MAP()
ModuleID moduleId);

private:
HRESULT FakesInitialize(IUnknown *pICorProfilerInfoUnk);
CComPtr<ICorProfilerCallback4> m_chainedProfiler;
CComObject<CProfilerInfo> *m_infoHook;
HRESULT FakesModulesAttachedToAssembly(ModuleID moduleId, AssemblyID assemblyId);
mdMemberRef m_targetLoadOpenCoverProfilerInsteadRef;
mdMemberRef m_targetPretendWeLoadedFakesProfilerRef;
HRESULT GetFakesSupportRef(ModuleID moduleId, mdModuleRef &fakesSupportRef);
mdTypeRef m_objectTypeRef;
mdMethodDef m_pinvokeAttach;
mdMethodDef CreatePInvokeHook(IMetaDataEmit* pMetaDataEmit);
HRESULT FakesSupportCompilation(FunctionID functionId, mdToken functionToken, ModuleID moduleId, AssemblyID assemblyId, std::wstring &modulePath);
CComPtr<ICorProfilerCallback4> m_chainedProfiler;
CComObject<CProfilerInfo> *m_infoHook;

HRESULT OpenCoverSupportInitialize(IUnknown *pICorProfilerInfoUnk);
HRESULT GetOpenCoverSupportRef(ModuleID moduleId, mdModuleRef &supportRef);
mdMethodDef CreatePInvokeHook(ModuleID moduleId);
HRESULT OpenCoverSupportCompilation(FunctionID functionId, mdToken functionToken, ModuleID moduleId, AssemblyID assemblyId, std::wstring &modulePath);
mdMethodDef Get_CurrentDomainMethod(ModuleID moduleID);
HRESULT InstrumentMethodWith(ModuleID moduleId, mdToken functionToken, InstructionList &instructions);

bool OpenCoverSupportRequired(AssemblyID assemblyId, FunctionID functionId);

mdMethodDef GetFakesHelperMethodRef(TCHAR* methodName, ModuleID moduleId);
void InstrumentTestPlatformUtilities(FunctionID functionId, mdToken functionToken, ModuleID moduleId, AssemblyID assemblyId);
void InstrumentTestPlatformTestExecutor(FunctionID functionId, mdToken functionToken, ModuleID moduleId, AssemblyID assemblyId);

mdMethodDef GetUITestingHelperMethodRef(TCHAR* methodName, ModuleID moduleId);
void InstrumentTestToolsUITesting(FunctionID functionId, mdToken functionToken, ModuleID moduleId, AssemblyID assemblyId);

friend class CProfilerInfo;

public:
Expand Down
6 changes: 5 additions & 1 deletion main/OpenCover.Profiler/CodeCoverage_Cuckoo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ HRESULT CCodeCoverage::CuckooSupportCompilation(
mdToken functionToken,
ModuleID moduleId)
{
// add the bodies for our cuckoo methods when required
// early escape if token is not one we want
if ((m_cuckooCriticalToken != functionToken) && (m_cuckooSafeToken != functionToken))
return S_OK;

// check that we have the right module
if (MSCORLIB_NAME == GetAssemblyName(assemblyId))
{
if (m_cuckooCriticalToken == functionToken)
Expand Down
Loading