.NET Profiler - Filter out .Net Framework Functions

200 Views Asked by At

I've created a .NET Profiling DLL that implements the ICorProfilerCallback3 interface.

I'm using the profiling to trace the functions called during Runtime, however, I'm looking to trace application specific functions, not the standard .NET framework functions.

I successfully used the SetEnterLeaveFunctionHook method and supply it with callback functions.

Then while I'm in the callback functions, I get the function information and assembly information using the GetFunctionInfo and GetModuleInfo2 functions.

The issue I'm running into is this obviously gets called for EVERY function and I'm looking for a way to distinguish between a .Net framework DLL and not a standard DLL.

For instance the majority of calls when the application starts goes to the mscorlib.dll which I'm not interested in tracing.

Any thoughts or ideas? I've tried call this function but pdwImplFlags doesn't appear to populate with anything useful.

https://learn.microsoft.com/en-us/dotnet/framework/unmanaged-api/metadata/imetadataimport-getmethodprops-method

1

There are 1 best solutions below

4
Brian Reichle On

You can use SetFunctionIDMapper2 to specify a mapper which checks to see if the function is of interest and return false in pbHookFunction if it's not. Then you should only get callbacks for the methods where you returned true in pbHookFunction.