.NET Framework Bookmark and Share   
 index > Building Development and Diagnostic Tools for .Net > Odd bug with dynamic enable/disable of ENTERLEAVE
 

Odd bug with dynamic enable/disable of ENTERLEAVE

I've been experimenting with toggling COR_PRF_MONITOR_ENTERLEAVE dynamically, and I'm seeing some bugs in the behavior. If I start up the app with the flag defined, everything is fine. If I start up without the flag and then enable it later, the ELT hooks are not actually invoked for any of the functions in the application. They are called for a number of Framework classes -- I've seen System.Windows.ni.dll show up quite a lot and I assume this is an NGEN /Profile image. I am asking the runtime to add hooks to all functions that come through the function mapper, and I am seeing all of the app's functions go through the mapper.

I'm unable to find any bugs in my code that would cause this. The problem is completely and instantly fixed simply by adding MONITOR_ENTERLEAVE in Initialize. Is there something I'm not understanding about how this flag should behave?
Promit

Hi Promit,

COR_PRF_MONITOR_ENTERLEAVE must be enabled when the functions of your interested are being JITed. Otherwise, there's is no way to add ELT hooks to the JITed functions. FunctionIDMapper allow you to specify whethera given function being JITed needsto support ELT hooks. If you want to received ELT callbacks from mscrolib, your profiler has to enableCOR_PRF_MONITOR_ENTERLEAVE in ICorProfilerCallback::Initialize callback, which will load NGEN /Profile version of mscorliborforce CLR to JIT mscorlib if there is no NGEN /Profile version of mscorlib. Disabling COR_PRF_MONITOR_ENTERLEAVE means you don't want to functions to be JITed later on to support ELT hooks, but it doesn't affect theexisting JITedfunctions.



Thanks,
Shane

All Replies

Shane Yuan

Hi Promit,

COR_PRF_MONITOR_ENTERLEAVE must be enabled when the functions of your interested are being JITed. Otherwise, there's is no way to add ELT hooks to the JITed functions. FunctionIDMapper allow you to specify whethera given function being JITed needsto support ELT hooks. If you want to received ELT callbacks from mscrolib, your profiler has to enableCOR_PRF_MONITOR_ENTERLEAVE in ICorProfilerCallback::Initialize callback, which will load NGEN /Profile version of mscorliborforce CLR to JIT mscorlib if there is no NGEN /Profile version of mscorlib. Disabling COR_PRF_MONITOR_ENTERLEAVE means you don't want to functions to be JITed later on to support ELT hooks, but it doesn't affect theexisting JITedfunctions.



Thanks,
Shane
  • Saturday, August 08, 2009 5:07 PMPromitMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I see. That doesn't quite match up with how the documentation and blogs describe it, which I took to mean that that value of pbHookFunction in FunctionIDMapper is the only thing that controls whether the ELT hooks are injected. Thanks.
  • Shane Yuan

    You can use google to search for other answers

    Custom Search

    More Threads

    • IMetaDataEmit.DefineTypeRefByName for generic types?
    • Running Mdbg in my app (was Re: Custom Debugging)
    • Creating Performance Counter Logs using C#
    • Not seeing C# code when debugging remotely
    • Help!My program sometimes can't exit normally
    • Check the assembly files in dos command
    • Calling Win32 API from Assembly Language
    • How to monitor the performance of the applications I developed??
    • Custom Debugging
    • Query on using enterprise library For logging