diff options
author | Sung Yoon Whang <suwhang@microsoft.com> | 2018-07-22 20:56:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-22 20:56:42 -0700 |
commit | cc96914f80b6873c555d0ed377042537ef99f1af (patch) | |
tree | 026d241960b09179fd5132861763261e1f43f8d4 /src/vm/profattach.cpp | |
parent | 45f1ec9c4d91733c76868870ff85f2beafabdd39 (diff) | |
download | coreclr-cc96914f80b6873c555d0ed377042537ef99f1af.tar.gz coreclr-cc96914f80b6873c555d0ed377042537ef99f1af.tar.bz2 coreclr-cc96914f80b6873c555d0ed377042537ef99f1af.zip |
Enable profiler attach on Windows (#18762)
* try building clr with prof attach enabled
* define ICLRProfiling interface
* profattach.dll now builds with CreateCLRProfiling export
* remove try catch
* basic attach working now
* build with profiler attach feature only on win
* Fix linux build
* cleanup
* more cleanup
* more cleanup
* remove profattach dll
* remove useless unix exports in mscorwks
* remove profattach from dll cmakelist
* Add back ifdef
* cleanup
* change LINUX to UNIX in clrdefinitions
* Fix broken checked builds
* Remove CLRProfilingClassFactory and metadata.h include from profattach.cpp
* remove useless extern C
* Add this back in
* adding ifndef DACCESS_COMPILE
* Try building with FWD define ICLRProfiling interface
* Test commit - removing additional definition from metahost.h to see if this will pass CI runs
* Address pr comments
Diffstat (limited to 'src/vm/profattach.cpp')
-rw-r--r-- | src/vm/profattach.cpp | 91 |
1 files changed, 20 insertions, 71 deletions
diff --git a/src/vm/profattach.cpp b/src/vm/profattach.cpp index ff56f38405..981e937cdc 100644 --- a/src/vm/profattach.cpp +++ b/src/vm/profattach.cpp @@ -11,6 +11,7 @@ // ====================================================================================== + #include "common.h" #ifdef FEATURE_PROFAPI_ATTACH_DETACH @@ -1192,55 +1193,6 @@ void ProfilingAPIAttachDetach::CreateAttachThread() } // ---------------------------------------------------------------------------- -// CLRProfilingClassFactoryImpl::CreateInstance -// -// Description: -// A standard IClassFactory interface function to allow a profiling trigger -// to query for IID_ICLRProfiling interface -// -HRESULT CLRProfilingClassFactoryImpl::CreateInstance(IUnknown * pUnkOuter, REFIID riid, void ** ppv) -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_PREEMPTIVE; - SO_NOT_MAINLINE; - } - CONTRACTL_END; - - if (ppv == NULL) - return E_POINTER; - - *ppv = NULL; - - NewHolder<CLRProfilingImpl> pProfilingImpl = new (nothrow) CLRProfilingImpl(); - if (pProfilingImpl == NULL) - return E_OUTOFMEMORY; - - HRESULT hr = pProfilingImpl->QueryInterface(riid, ppv); - if (SUCCEEDED(hr)) - { - pProfilingImpl.SuppressRelease(); - } - - return hr; -} - -// ---------------------------------------------------------------------------- -// CLRProfilingClassFactoryImpl::LockServer -// -// Description: -// A standard IClassFactory interface function that doesn't do anything interesting here -// -HRESULT CLRProfilingClassFactoryImpl::LockServer(BOOL fLock) -{ - LIMITED_METHOD_CONTRACT; - - return S_OK; -} - -// ---------------------------------------------------------------------------- // CLRProfilingImpl::AttachProfiler // // Description: @@ -1279,41 +1231,38 @@ HRESULT CLRProfilingImpl::AttachProfiler(DWORD dwProfileeProcessID, wszRuntimeVersion); } -// ---------------------------------------------------------------------------- -// ICLRProfilingGetClassObject -// -// Description: -// A wrapper to create a CLRProfilingImpl object and to QueryInterface on the CLRProfilingImpl object -// -HRESULT ICLRProfilingGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv) + +// Contract for public APIs. These must be NOTHROW. +EXTERN_C const IID IID_ICLRProfiling; + +HRESULT +CreateCLRProfiling( + __out void ** ppCLRProfilingInstance) { CONTRACTL { NOTHROW; - GC_NOTRIGGER; - MODE_PREEMPTIVE; - SO_NOT_MAINLINE; - PRECONDITION(rclsid == CLSID_CLRProfiling); } CONTRACTL_END; - if (ppv == NULL) - return E_POINTER; - - *ppv = NULL; + HRESULT hrIgnore = S_OK; // ignored HResult + HRESULT hr = S_OK; + HMODULE hMod = NULL; + IUnknown * pCordb = NULL; - NewHolder<CLRProfilingClassFactoryImpl> pCLRProfilingClassFactoryImpl = new (nothrow) CLRProfilingClassFactoryImpl(); - if (pCLRProfilingClassFactoryImpl == NULL) + LOG((LF_CORDB, LL_EVERYTHING, "Calling CreateCLRProfiling")); + + NewHolder<CLRProfilingImpl> pProfilingImpl = new (nothrow) CLRProfilingImpl(); + if (pProfilingImpl == NULL) return E_OUTOFMEMORY; - HRESULT hr = pCLRProfilingClassFactoryImpl->QueryInterface(riid, ppv); + hr = pProfilingImpl->QueryInterface(IID_ICLRProfiling, ppCLRProfilingInstance); if (SUCCEEDED(hr)) { - pCLRProfilingClassFactoryImpl.SuppressRelease(); + pProfilingImpl.SuppressRelease(); + return S_OK; } - - return hr; + return E_FAIL; } - #endif // FEATURE_PROFAPI_ATTACH_DETACH |