.NET Framework Bookmark and Share   
 index > Building Development and Diagnostic Tools for .Net > How to determine generic specialization of a function in the function mapper?
 

How to determine generic specialization of a function in the function mapper?

(David: I already emailed you this question before remembering this forum existed.)

I'm using the FunctionIDMapper to get the complete signature of functions that the profiler sees. I'm able to use the ICorProfilerInfo(2) and IMetaDataImport(2) interfaces, along with parsing the COR_SIGNATURE blob, with great success overall. However, the problem is that with generics, I end up with a signature like:
System.Threading.Interlocked.CompareExchange<T>(ref T, T, T)
What I really want is the generic type instantiation that is being invoked, eg:
System.Threading.Interlocked.CompareExchange<int>(ref int, int, int)

It's not clear to me how to get this info. I tried GetFunctionInfo2, but the tokens it returns are always for the same type, System.__Canon. How can I find out what specific instantiation a FunctionID corresponds to? Even the COR_SIGNATURE I get is for a MethodDef rather than a MethodSpec.
  •  

Answers

  • Tuesday, July 28, 2009 11:21 PMShane YuanMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Promit,

    Your observation is correct, Internally, CLR uses System.__Canon as parameters for different reference types to share code and reduce the working set. Since a function is shared among different instantiated reference types, it is not possible to get specific instantiation informationbased ona FunctionID. However, ELT (enter, leave, and tailcall) callbacks pass you the COR_PRF_FRAME_INFO parameter. Passing the COR_PRF_FRAME_INFOdata you get from ELT to GetFunctionInfo2 will give you the more useful results.


    Shane
    • Marked As Answer byPromitMVPWednesday, July 29, 2009 12:34 AM
    •  

All Replies

  • Monday, July 27, 2009 7:28 PMPromitMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    So I found out that the FunctionID will only change for different value types, and all reference types will basically get the same FunctionID. Even so, is there any way to distinguish at least a little bit?
Promit
Hi Promit,

Your observation is correct, Internally, CLR uses System.__Canon as parameters for different reference types to share code and reduce the working set. Since a function is shared among different instantiated reference types, it is not possible to get specific instantiation informationbased ona FunctionID. However, ELT (enter, leave, and tailcall) callbacks pass you the COR_PRF_FRAME_INFO parameter. Passing the COR_PRF_FRAME_INFOdata you get from ELT to GetFunctionInfo2 will give you the more useful results.


Shane
  • Marked As Answer byPromitMVPWednesday, July 29, 2009 12:34 AM
  •  
  • Wednesday, July 29, 2009 12:34 AMPromitMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks for the explanation Shane.
  • Shane Yuan

    You can use google to search for other answers

    Custom Search

    More Threads

    • CodePlex.Diagnostics 2.0.0.4 Released
    • setting epilog in JitCompilationStarted
    • AddVectoredExceptionHandler
    • Performance Monitor Command Line Question
    • How to filter Calltree in CLR profiler to show calls from only my DLLs and Exe?
    • C# tuple 2.0 - Logic to be rewritten in 1.1 framework
    • Can I know how to get some sample class diagram for c# projects?
    • How to Pack my windows application developed in .net 2.0 using C#
    • Mdbg 2.0 extended for distributed user (client/server)
    • Profiling API and security