FunctionIDMapper Function

Notifies the profiler that the given identifier of a function may be remapped to an alternative ID to be used in the enter2/leave2/tailcall2 callbacks for that function. This method also allows the profiler to indicate whether it wants to receive callbacks for the that function.

UINT_PTR __stdcall FunctionIDMapper (
    [in]  FunctionID  funcId, 
    [out] BOOL       *pbHookFunction
);

Parameters

Parameter Description

funcId

[in] The function identifier to be remapped.

pbHookFunction

[out] A pointer to a value that the profiler sets to true if it wants to receive enter(2)/leave(2)/tailcall(2) callbacks; otherwise, it sets this value to false.

Return Value

The profiler returns a value that the execution engine uses as an alternative function identifier. The return value cannot be NULL unless false is returned in *pbHookFunction; otherwise, a NULL return value will effectively produce unpredictable results, including possibly halting the process.

Remarks

The FunctionIDMapper function is a callback — it is implemented by the profiler to remap a function ID to some other identifier that's more useful for the profiler. The FunctionIDMapper returns the alternate ID to be used for any given function. The execution engine then honors the profiler's request by passing this alternate ID, in addition to the traditional function ID, back to the profiler in the clientData parameter of the enter2/leave2/tailcall2 hooks, to identify the function for which the hook is being called.

You can use the ICorProfilerInfo::SetFunctionIDMapper Method method to specify the implementation of the FunctionIDMapper function. The ICorProfilerInfo::SetFunctionIDMapper Method method can be called at most once and it is recommended to do so in the ICorProfilerCallback::Initialize Method callback.

By default, it is assumed that a profiler which sets the COR_PRF_MONITOR_ENTERLEAVE flag via ICorProfilerInfo::SetEventMask Method, and which sets hooks via ICorProfilerInfo::SetEnterLeaveFunctionHooks Method or ICorProfilerInfo2::SetEnterLeaveFunctionHooks2 Method, should receive the enter(2)/leave(2)/tailcall(2) callbacks for every function. However, profilers may implement FunctionIDMapper to selectively avoid receiving these callbacks for certain functions by setting *pbHookFunction to false.

Profilers should be tolerant of cases where multiple threads of a profiled application are calling the same method/function simultaneously. In such cases, the profiler may receive multiple FunctionIDMapper callbacks for the same FunctionID. The profiler should be certain to return the same values from this callback when it is called multiple times with the same FunctionID.

Requirements

Platforms: Windows 2000, Windows XP, Windows Server 2003 family

Header: CorProf.idl

Library: CorGuids.lib

.NET Framework Version: 2.0, 1.1, 1.0

See Also

Reference

ICorProfilerInfo::SetFunctionIDMapper Method
FunctionEnter2 Function
FunctionLeave2 Function
FunctionTailcall2 Function

Other Resources

Profiling Global Static Functions