(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.AnswersHi 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 RepliesSo 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
-
Thanks for the explanation Shane. | | Shane Yuan |
|