Reputation:
I gather the main benefit of using the CLR Profiler ICLRProfiling::AttachProfiler method is that you now can attach your CLR profiler long after the target process has started and that you also don't have to pass the COR_ENABLE_PROFILING
and COR_PROFILER
environment variables to the process at launch? Are both of these correct assumptions?
Also, I've read in a CLR Profiling team blog post from 2011 that ICLRProfiling::AttachProfiler did not support the following but would in the future:
GetILFunctionBody
GetILFunctionBodyAllocator
SetILFunctionBody
SetILInstrumentedCodeMap
SetEnterLeaveFunctionHooks*
SetFunctionIDMapper*
GetNotifiedExceptionClauseInfo
All methods related to Enter/Leave/Tailcall
Are these supported now? I'm asking since I have'nt found anything more on the subject online and many of the Microsoft links from 2011-2012 are dead now. If not, then is it even possible to IL rewrite a function body when using ICLRProfiling::AttachProfiler to attach my CLR Profiler?
Upvotes: 0
Views: 660
Reputation:
The answer was sadly "No", you can't do IL Rewriting when in CLR attach profiler mode; it is still only supported in process launch mode.
The call to the ICorProfilerInfo::GetILFunctionBody()
method in my CLR Profiler implementation returns CORPROF_E_UNSUPPORTED_FOR_ATTACHING_PROFILER
:
GetILFunctionBody() failed with error 0x8013136f
the ICorProfilerInfo::GetILFunctionBody()
source is here for those interested in digging into why this happens.
Upvotes: 1