home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / dotNETSDK / SETUP.EXE / netfxsd1.cab / FL_ProfilerCallback_cpp________.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Encoding:
Text File  |  2002-05-06  |  57.2 KB  |  2,749 lines

  1. /****************************************************************************************
  2.  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
  3.  *
  4.  * File:
  5.  *  ProfilerCallBack.cpp
  6.  *
  7.  * Description:
  8.  *  
  9.  *
  10.  *
  11.  ***************************************************************************************/ 
  12. #include "ProfilerCallback.h"
  13.  
  14.           
  15. /***************************************************************************************
  16.  ********************                                               ********************
  17.  ********************     ProfilerCallBack Implementation           ********************
  18.  ********************                                               ********************
  19.  ***************************************************************************************/
  20. ProfilerCallback *g_pCallbackObject;
  21.  
  22.  
  23. /***************************************************************************************
  24.  ********************                                               ********************
  25.  ********************   Global Functions Used by Function Hooks     ********************
  26.  ********************                                               ********************
  27.  ***************************************************************************************/
  28.  
  29. //
  30. // The functions EnterStub, LeaveStub and TailcallStub are basically wrappers 
  31. // because the __declspec(naked) definition does not allow for example
  32. // the use of ProfilerCallback::Enter(functionID);
  33. //
  34. // The hooks implementation has to be __declspec(naked) please read the 
  35. // corprof.idl for more details. The FunctionIDMapper() does not have to be
  36. //  __declspec(naked)
  37. //
  38. void __stdcall EnterStub( FunctionID functionID )
  39. {
  40.     ProfilerCallback::Enter( functionID );
  41. }
  42.  
  43.  
  44. void __stdcall LeaveStub( FunctionID functionID )
  45. {
  46.     ProfilerCallback::Leave( functionID );
  47. }
  48.  
  49.  
  50. void __stdcall TailcallStub( FunctionID functionID )
  51. {
  52.     ProfilerCallback::Tailcall( functionID );
  53. }
  54.  
  55.  
  56. void __declspec( naked ) EnterNaked()
  57. {
  58.     __asm
  59.     {
  60.         push eax
  61.         push ecx
  62.         push edx
  63.         push [esp+16]
  64.         call EnterStub
  65.         pop edx
  66.         pop ecx
  67.         pop eax
  68.         ret 4
  69.     }
  70. }
  71.  
  72.  
  73. void __declspec( naked ) LeaveNaked()
  74. {
  75.     __asm
  76.     {
  77.         push eax
  78.         push ecx
  79.         push edx
  80.         push [esp+16]
  81.         call LeaveStub
  82.         pop edx
  83.         pop ecx
  84.         pop eax
  85.         ret 4
  86.     }
  87. }
  88.  
  89.  
  90. void __declspec(naked) TailcallNaked()
  91. {
  92.     __asm
  93.     {
  94.         push eax
  95.         push ecx
  96.         push edx
  97.         push [esp+16]
  98.         call TailcallStub
  99.         pop edx
  100.         pop ecx
  101.         pop eax
  102.         ret 4
  103.     }
  104. }
  105.  
  106.  
  107. /***************************************************************************************
  108.  *  Method:
  109.  *
  110.  *
  111.  *  Purpose:
  112.  *                  
  113.  *
  114.  *  Parameters: 
  115.  *
  116.  *
  117.  *  Return value:
  118.  *
  119.  *
  120.  *  Notes:
  121.  *
  122.  ***************************************************************************************/
  123. /* public */
  124. ProfilerCallback::ProfilerCallback() :
  125.     m_refCount( 0 ),
  126.     m_dwShutdown( 0 )
  127. {
  128.     //
  129.     // Hold a pointer to the callback interface. It will be used
  130.     // if abnormal shutdown occurs for releasign the profiler ressources
  131.     //
  132.     // We are monitoring only the events that we are interested in. 
  133.     // This maximizes the performance. We still need to implement all
  134.     // the callbacks of the callback interface but the code will never be hit.
  135.     //  
  136.     // Notice that we disabled globally the inlining. This makes the profiler more
  137.     // accurate in monitoring functions but also affects the execution time and 
  138.     // performance
  139.     //
  140.     g_pCallbackObject = this;
  141.     m_dwEventMask = (DWORD) (   COR_PRF_MONITOR_CLASS_LOADS
  142.                               | COR_PRF_MONITOR_MODULE_LOADS
  143.                               | COR_PRF_MONITOR_ASSEMBLY_LOADS
  144.                               | COR_PRF_MONITOR_APPDOMAIN_LOADS
  145.                               | COR_PRF_MONITOR_JIT_COMPILATION
  146.                               | COR_PRF_MONITOR_EXCEPTIONS
  147.                               | COR_PRF_MONITOR_THREADS
  148.                               | COR_PRF_MONITOR_CODE_TRANSITIONS
  149.                               | COR_PRF_MONITOR_ENTERLEAVE
  150.                               | COR_PRF_MONITOR_CACHE_SEARCHES
  151.                               | COR_PRF_DISABLE_INLINING );
  152.  
  153. } // ctor
  154.  
  155.  
  156. /***************************************************************************************
  157.  *  Method:
  158.  *
  159.  *
  160.  *  Purpose:
  161.  *
  162.  *
  163.  *  Parameters: 
  164.  *
  165.  *
  166.  *  Return value:
  167.  *
  168.  *
  169.  *  Notes:
  170.  *
  171.  ***************************************************************************************/
  172. /* public */
  173. ProfilerCallback::~ProfilerCallback()
  174. {
  175.        g_pCallbackObject = NULL;
  176.         
  177. } // dtor
  178.  
  179.         
  180. /***************************************************************************************
  181.  *  Method:
  182.  *
  183.  *
  184.  *  Purpose:
  185.  *
  186.  *
  187.  *  Parameters: 
  188.  *
  189.  *
  190.  *  Return value:
  191.  *
  192.  *
  193.  *  Notes:
  194.  *
  195.  ***************************************************************************************/
  196. /* public */
  197. ULONG ProfilerCallback::AddRef() 
  198. {
  199.     return InterlockedIncrement( &m_refCount );
  200.  
  201. } // ProfilerCallback::AddRef
  202.  
  203.  
  204. /***************************************************************************************
  205.  *  Method:
  206.  *
  207.  *
  208.  *  Purpose:
  209.  *
  210.  *
  211.  *  Parameters: 
  212.  *
  213.  *
  214.  *  Return value:
  215.  *
  216.  *
  217.  *  Notes:
  218.  *
  219.  ***************************************************************************************/
  220. /* public */
  221. ULONG ProfilerCallback::Release() 
  222. {
  223.     long refCount;
  224.  
  225.  
  226.     refCount = InterlockedDecrement( &m_refCount );
  227.     if ( refCount == 0 )
  228.         delete this;
  229.      
  230.  
  231.     return refCount;
  232.  
  233. } // ProfilerCallback::Release
  234.  
  235.  
  236. /***************************************************************************************
  237.  *  Method:
  238.  *
  239.  *
  240.  *  Purpose:
  241.  *
  242.  *
  243.  *  Parameters: 
  244.  *
  245.  *
  246.  *  Return value:
  247.  *
  248.  *
  249.  *  Notes:
  250.  *
  251.  ***************************************************************************************/
  252. /* public */
  253. HRESULT ProfilerCallback::QueryInterface( REFIID riid, void **ppInterface )
  254. {
  255.     if ( riid == IID_IUnknown )
  256.         *ppInterface = static_cast<IUnknown *>( this ); 
  257.  
  258.     else if ( riid == IID_ICorProfilerCallback )
  259.         *ppInterface = static_cast<ICorProfilerCallback *>( this );
  260.  
  261.     else
  262.     {
  263.         *ppInterface = NULL;
  264.  
  265.  
  266.         return E_NOINTERFACE;
  267.     }
  268.     
  269.     reinterpret_cast<IUnknown *>( *ppInterface )->AddRef();
  270.  
  271.     return S_OK;
  272.  
  273. } // ProfilerCallback::QueryInterface 
  274.  
  275.  
  276. /***************************************************************************************
  277.  *  Method:
  278.  *
  279.  *
  280.  *  Purpose:
  281.  *
  282.  *
  283.  *  Parameters: 
  284.  *
  285.  *
  286.  *  Return value:
  287.  *
  288.  *
  289.  *  Notes:
  290.  *
  291.  ***************************************************************************************/
  292. /* public static */
  293. HRESULT ProfilerCallback::CreateObject( REFIID riid, void **ppInterface )
  294. {
  295.     HRESULT hr = S_OK;
  296.     
  297.        
  298.     if ( (riid == IID_IUnknown) || (riid == IID_ICorProfilerCallback) )
  299.     {           
  300.         ProfilerCallback *pProfilerCallback;
  301.         
  302.                 
  303.         pProfilerCallback = new ProfilerCallback();
  304.         if ( pProfilerCallback != NULL )
  305.         {
  306.             pProfilerCallback->AddRef();
  307.             *ppInterface = static_cast<ICorProfilerCallback *>( pProfilerCallback );
  308.         }
  309.         else
  310.             hr = E_OUTOFMEMORY;
  311.     }
  312.     else
  313.         hr = E_NOINTERFACE;
  314.     
  315.  
  316.     return hr;
  317.  
  318. } // ProfilerCallback::CreateObject
  319.  
  320. /***************************************************************************************
  321.  ********************                                               ********************
  322.  ********************       Callbacks With Non Trivial                 ********************
  323.  ********************         Implementation Below                   ********************
  324.  ********************                                               ********************
  325.  ***************************************************************************************/
  326. /***************************************************************************************
  327.  *  Method:
  328.  *
  329.  *
  330.  *  Purpose:
  331.  *
  332.  *
  333.  *  Parameters: 
  334.  *
  335.  *
  336.  *  Return value:
  337.  *
  338.  *
  339.  *  Notes:
  340.  *
  341.  ***************************************************************************************/
  342. /* public */
  343. HRESULT ProfilerCallback::Initialize( IUnknown *pICorProfilerInfoUnk )
  344. {
  345.     TEXT_OUTLN( "CLR Profiler General Code Profiler Sample" ) 
  346.     
  347.     HRESULT hr;
  348.  
  349.     
  350.     hr = pICorProfilerInfoUnk->QueryInterface( IID_ICorProfilerInfo,
  351.                                                (void **)&m_pProfilerInfo );   
  352.     if ( SUCCEEDED( hr ) )
  353.     {
  354.         DWORD dwRequestedEvents = m_dwEventMask;
  355.  
  356.         hr = m_pProfilerInfo->SetEventMask(dwRequestedEvents);
  357.  
  358.         if ( SUCCEEDED( hr ) )
  359.         {
  360.             //
  361.             // Set the function hooks for enter, leave and tail calls
  362.             //
  363.             hr = m_pProfilerInfo->SetEnterLeaveFunctionHooks ( (FunctionEnter *)&EnterNaked,
  364.                                                                (FunctionLeave *)&LeaveNaked,
  365.                                                                (FunctionTailcall *)&TailcallNaked );        
  366.             if ( SUCCEEDED( hr ) )
  367.             {
  368.                 //
  369.                 // Set the hooks for a function mapper
  370.                 //
  371.                 hr = m_pProfilerInfo->SetFunctionIDMapper( (FunctionIDMapper *)&FunctionMapper );            
  372.     
  373.                 if ( FAILED( hr ) )
  374.                     Failure( "ICorProfilerInfo::SetFunctionIDMapper() FAILED" );
  375.             }
  376.             else
  377.                 Failure( "ICorProfilerInfo::SetEnterLeaveFunctionHooks() FAILED" );
  378.         }
  379.         else
  380.             Failure( "ICorProfilerInfo::SetEventMask() FAILED" );
  381.     }       
  382.     else
  383.         Failure( "Allocation for Profiler Test FAILED" );           
  384.               
  385.               
  386.     return S_OK;
  387.  
  388. } // ProfilerCallback::Initialize
  389.  
  390.  
  391. /***************************************************************************************
  392.  *  Method:
  393.  *
  394.  *
  395.  *  Purpose:
  396.  *
  397.  *
  398.  *  Parameters: 
  399.  *
  400.  *
  401.  *  Return value:
  402.  *
  403.  *
  404.  *  Notes:
  405.  *
  406.  ***************************************************************************************/
  407. /* public */
  408. HRESULT ProfilerCallback::Shutdown()
  409. {
  410.     m_dwShutdown++;
  411.     DumpTables();
  412.     return S_OK;          
  413.  
  414. } // ProfilerCallback::Shutdown
  415.  
  416.  
  417. /***************************************************************************************
  418.  *  Method:
  419.  *
  420.  *
  421.  *  Purpose:
  422.  *
  423.  *
  424.  *  Parameters: 
  425.  *
  426.  *
  427.  *  Return value:
  428.  *
  429.  *
  430.  *  Notes:
  431.  *
  432.  ***************************************************************************************/
  433. /* public */
  434. HRESULT ProfilerCallback::DllDetachShutdown()
  435. {
  436.     //
  437.     // If no shutdown came at DLL_DETACH, release yourself
  438.     // this scenario will happen with any INTEROP program that
  439.     // an unmanaged client uses a managed debuggee
  440.     //
  441.     m_dwShutdown++;
  442.     if ( (m_dwShutdown == 1) && (g_pCallbackObject != NULL) )
  443.     {
  444.         DumpTables();
  445.         g_pCallbackObject->Release();    
  446.         g_pCallbackObject = NULL;
  447.     }
  448.  
  449.     
  450.     return S_OK;          
  451.  
  452. } // ProfilerCallback::DllExitShutdown
  453.  
  454.  
  455. /***************************************************************************************
  456.  ********************                                               ********************
  457.  ******************** Callbacks With Default Implementation Below   ********************
  458.  ********************                                               ********************
  459.  ***************************************************************************************/
  460.  
  461. /***************************************************************************************
  462.  *    Method:
  463.  *
  464.  *
  465.  *    Purpose:
  466.  *
  467.  *
  468.  *    Parameters: 
  469.  *
  470.  *
  471.  *    Return value:
  472.  *
  473.  *
  474.  *    Notes:
  475.  *
  476.  ***************************************************************************************/
  477. /* public */
  478. HRESULT ProfilerCallback::AppDomainCreationStarted( AppDomainID appDomainID )
  479. {
  480.     
  481.     //
  482.     // Note that the appDomain is just being loaded so we don't expect the
  483.     // data structure (representing the appDomain) to be complete
  484.     // here. We have to wait until the creation is complete before attempting 
  485.     // to get any info on the appDomain. 
  486.     //
  487.     // When we have a system Domain, then we can retrieve the full 
  488.     // information at this point but for any other user-defined domains 
  489.     // IcorProfilerInfo::GetAppDomain Info() will return hr == CORPROF_E_DATAINCOMPLETE.
  490.     //
  491.     // The reason for the different behavior is that the events for the system AppDomains
  492.     // are send delayed after the actual AppDomain has been created and all 
  493.     // the info is already available
  494.     //
  495.  
  496.     return S_OK;
  497.  
  498. } // ProfilerCallback::AppDomainCreationStarted
  499.  
  500.  
  501. /***************************************************************************************
  502.  *    Method:
  503.  *
  504.  *
  505.  *    Purpose:
  506.  *
  507.  *
  508.  *    Parameters: 
  509.  *
  510.  *
  511.  *    Return value:
  512.  *
  513.  *
  514.  *    Notes:
  515.  *
  516.  ***************************************************************************************/
  517. /* public */
  518. HRESULT ProfilerCallback::AppDomainCreationFinished( AppDomainID appDomainID,
  519.                                                      HRESULT hrStatus )
  520. {
  521.  
  522.     _ASSERT_( SUCCEEDED( hrStatus ) );
  523.  
  524.     try
  525.     {   
  526.          AddAppDomain( appDomainID );       
  527.     }    
  528.        catch ( BaseException *exception )
  529.     {
  530.         exception->ReportFailure();
  531.         delete exception;
  532.           Failure();    
  533.     }
  534.     
  535.  
  536.     return S_OK;
  537.  
  538. } // ProfilerCallback::AppDomainCreationFinished
  539.  
  540.  
  541. /***************************************************************************************
  542.  *    Method:
  543.  *
  544.  *
  545.  *    Purpose:
  546.  *
  547.  *
  548.  *    Parameters: 
  549.  *
  550.  *
  551.  *    Return value:
  552.  *
  553.  *
  554.  *    Notes:
  555.  *
  556.  ***************************************************************************************/
  557. /* public */
  558. HRESULT ProfilerCallback::AppDomainShutdownStarted( AppDomainID appDomainID )
  559. {
  560.     //
  561.     // At this point we can still use any information related to the 
  562.     // appDomain that started shutting down. 
  563.     //
  564.     return S_OK;
  565.  
  566. } // ProfilerCallback::AppDomainShutdownStarted
  567.  
  568.       
  569.  
  570. /***************************************************************************************
  571.  *    Method:
  572.  *
  573.  *
  574.  *    Purpose:
  575.  *
  576.  *
  577.  *    Parameters: 
  578.  *
  579.  *
  580.  *    Return value:
  581.  *
  582.  *
  583.  *    Notes:
  584.  *
  585.  ***************************************************************************************/
  586. /* public */
  587. HRESULT ProfilerCallback::AppDomainShutdownFinished( AppDomainID appDomainID,
  588.                                                      HRESULT hrStatus )
  589. {
  590.     //
  591.     // The information related to an appDomain is not valid at this point
  592.     // We will mark the entry of the table as stale so we protect the profiler from
  593.     // accessing invalid data
  594.     //
  595.     _ASSERT_( SUCCEEDED( hrStatus ) );
  596.  
  597.     try
  598.     {   
  599.          RemoveAppDomain( appDomainID );       
  600.     }    
  601.        catch ( BaseException *exception )
  602.     {
  603.         exception->ReportFailure();
  604.         delete exception;
  605.           Failure();    
  606.     }
  607.     
  608.     return S_OK;
  609.  
  610. } // ProfilerCallback::AppDomainShutdownFinished
  611.  
  612.  
  613. /***************************************************************************************
  614.  *    Method:
  615.  *
  616.  *
  617.  *    Purpose:
  618.  *
  619.  *
  620.  *    Parameters: 
  621.  *
  622.  *
  623.  *    Return value:
  624.  *
  625.  *
  626.  *    Notes:
  627.  *
  628.  ***************************************************************************************/
  629. /* public */
  630. HRESULT ProfilerCallback::AssemblyLoadStarted( AssemblyID assemblyID )
  631. {
  632.     
  633.     //
  634.     // See AppDomainCreationStarted callback
  635.     //
  636.     return S_OK;
  637.  
  638. } // ProfilerCallback::AssemblyLoadStarted
  639.  
  640.  
  641. /***************************************************************************************
  642.  *    Method:
  643.  *
  644.  *
  645.  *    Purpose:
  646.  *
  647.  *
  648.  *    Parameters: 
  649.  *
  650.  *
  651.  *    Return value:
  652.  *
  653.  *
  654.  *    Notes:
  655.  *
  656.  ***************************************************************************************/
  657. /* public */
  658. HRESULT ProfilerCallback::AssemblyLoadFinished( AssemblyID assemblyID,
  659.                                                 HRESULT hrStatus )
  660. {
  661.     _ASSERT_( SUCCEEDED( hrStatus ) );
  662.  
  663.     try
  664.     {   
  665.          AddAssembly( assemblyID );       
  666.     }    
  667.        catch ( BaseException *exception )
  668.     {
  669.         exception->ReportFailure();
  670.         delete exception;
  671.           Failure();    
  672.     }
  673.  
  674.     
  675.     return S_OK;
  676.  
  677. } // ProfilerCallback::AssemblyLoadFinished
  678.  
  679.  
  680. /***************************************************************************************
  681.  *    Method:
  682.  *
  683.  *
  684.  *    Purpose:
  685.  *
  686.  *
  687.  *    Parameters: 
  688.  *
  689.  *
  690.  *    Return value:
  691.  *
  692.  *
  693.  *    Notes:
  694.  *
  695.  ***************************************************************************************/
  696. /* public */
  697. HRESULT ProfilerCallback::AssemblyUnloadStarted( AssemblyID assemblyID )
  698. {
  699.     //
  700.     // At this point we can still use any information related to the 
  701.     // assembly that started getting unloaded. 
  702.     //
  703.     return S_OK;
  704.  
  705. } // ProfilerCallback::AssemblyUnLoadStarted
  706.  
  707.       
  708. /***************************************************************************************
  709.  *    Method:
  710.  *
  711.  *
  712.  *    Purpose:
  713.  *
  714.  *
  715.  *    Parameters: 
  716.  *
  717.  *
  718.  *    Return value:
  719.  *
  720.  *
  721.  *    Notes:
  722.  *
  723.  ***************************************************************************************/
  724. /* public */
  725. HRESULT ProfilerCallback::AssemblyUnloadFinished( AssemblyID assemblyID,
  726.                                                   HRESULT hrStatus )
  727. {
  728.     //
  729.     // The information related to an assembly is not valid at this point
  730.     // We will mark the entry of the table as stale so we protect the profiler from
  731.     // accessing invalid data
  732.     //
  733.     _ASSERT_( SUCCEEDED( hrStatus ) );
  734.  
  735.     try
  736.     {   
  737.          RemoveAssembly( assemblyID );       
  738.     }    
  739.        catch ( BaseException *exception )
  740.     {
  741.         exception->ReportFailure();
  742.         delete exception;
  743.           Failure();    
  744.     }
  745.  
  746.  
  747.     return S_OK;
  748.  
  749. } // ProfilerCallback::AssemblyUnLoadFinished
  750.  
  751.  
  752. /***************************************************************************************
  753.  *    Method:
  754.  *
  755.  *
  756.  *    Purpose:
  757.  *
  758.  *
  759.  *    Parameters: 
  760.  *
  761.  *
  762.  *    Return value:
  763.  *
  764.  *
  765.  *    Notes:
  766.  *
  767.  ***************************************************************************************/
  768. /* public */
  769. HRESULT ProfilerCallback::ModuleLoadStarted( ModuleID moduleID )
  770. {
  771.     //
  772.     // The module is just being loaded so we don't expect the
  773.     // data structure (representing the module) to be complete.
  774.     // Calls to ICorProfilerInfo::GetModuleInfo wiil return 
  775.     // CORPROF_E_DATAINCOMPLETE at all times
  776.     //
  777.     return S_OK;
  778.  
  779. } // ProfilerCallback::ModuleLoadStarted
  780.  
  781.  
  782. /***************************************************************************************
  783.  *    Method:
  784.  *
  785.  *
  786.  *    Purpose:
  787.  *
  788.  *
  789.  *    Parameters: 
  790.  *
  791.  *
  792.  *    Return value:
  793.  *
  794.  *
  795.  *    Notes:
  796.  *
  797.  ***************************************************************************************/
  798. /* public */
  799. HRESULT ProfilerCallback::ModuleLoadFinished( ModuleID moduleID,
  800.                                               HRESULT hrStatus )
  801. {
  802.     _ASSERT_( SUCCEEDED( hrStatus ) );
  803.  
  804.     try
  805.     {   
  806.          AddModule( moduleID );       
  807.     }    
  808.        catch ( BaseException *exception )
  809.     {
  810.         exception->ReportFailure();
  811.         delete exception;
  812.        
  813.           Failure();    
  814.     }
  815.  
  816.  
  817.     return S_OK;
  818.  
  819. } // ProfilerCallback::ModuleLoadFinished
  820.  
  821.  
  822. /***************************************************************************************
  823.  *    Method:
  824.  *
  825.  *
  826.  *    Purpose:
  827.  *
  828.  *
  829.  *    Parameters: 
  830.  *
  831.  *
  832.  *    Return value:
  833.  *
  834.  *
  835.  *    Notes:
  836.  *
  837.  ***************************************************************************************/
  838. /* public */
  839. HRESULT ProfilerCallback::ModuleUnloadStarted( ModuleID moduleID )
  840. {
  841.        //
  842.     // At htis point we can use the information stored for the specific module.
  843.     // This is the correct spot to release the metadata interface for the module
  844.     //
  845.        ReleaseModuleMDInterface( moduleID );                                 
  846.  
  847.        
  848.     return S_OK;
  849.  
  850. } // ProfilerCallback::ModuleUnloadStarted
  851.       
  852.  
  853. /***************************************************************************************
  854.  *    Method:
  855.  *
  856.  *
  857.  *    Purpose:
  858.  *
  859.  *
  860.  *    Parameters: 
  861.  *
  862.  *
  863.  *    Return value:
  864.  *
  865.  *
  866.  *    Notes:
  867.  *
  868.  ***************************************************************************************/
  869. /* public */
  870. HRESULT ProfilerCallback::ModuleUnloadFinished( ModuleID moduleID,
  871.                                                 HRESULT hrStatus )
  872. {
  873.     //
  874.     // The information related to a module is not valid at this point
  875.     // We will mark the entry of the table as stale so we protect the profiler from
  876.     // accessing invalid data
  877.     //
  878.     _ASSERT_( SUCCEEDED( hrStatus ) );
  879.  
  880.     try
  881.     {   
  882.          RemoveModule( moduleID );       
  883.     }    
  884.        catch ( BaseException *exception )
  885.     {
  886.         exception->ReportFailure();
  887.         delete exception;
  888.        
  889.           Failure();    
  890.     }
  891.  
  892.     
  893.     return S_OK;
  894.  
  895. } // ProfilerCallback::ModuleUnloadFinished
  896.  
  897.  
  898. /***************************************************************************************
  899.  *    Method:
  900.  *
  901.  *
  902.  *    Purpose:
  903.  *
  904.  *
  905.  *    Parameters: 
  906.  *
  907.  *
  908.  *    Return value:
  909.  *
  910.  *
  911.  *    Notes:
  912.  *
  913.  ***************************************************************************************/
  914. /* public */
  915. HRESULT ProfilerCallback::ModuleAttachedToAssembly( ModuleID moduleID,
  916.                                                     AssemblyID assemblyID )
  917. {
  918.     //
  919.     // The assemblyID information is not always availabe at the ModuleLoadFinished 
  920.     // callback. We need to wait for the ModuleAttachedToAssembly() notification 
  921.     // before attempting to    read the information related to the assemblyID. See the
  922.     // Profiling Documentation for more details
  923.     //
  924.     _ASSERT_( assemblyID != PROFILER_PARENT_UNKNOWN );
  925.  
  926.     try
  927.     {   
  928.         UpdateAssemblyInModule( moduleID, assemblyID );                   
  929.     }    
  930.     catch ( BaseException *exception )
  931.     {
  932.         exception->ReportFailure();
  933.         delete exception;
  934.    
  935.           Failure();    
  936.     }
  937.  
  938.     
  939.     return S_OK;
  940.  
  941. } // ProfilerCallback::ModuleAttachedToAssembly
  942.  
  943.  
  944. /***************************************************************************************
  945.  *    Method:
  946.  *
  947.  *
  948.  *    Purpose:
  949.  *
  950.  *
  951.  *    Parameters: 
  952.  *
  953.  *
  954.  *    Return value:
  955.  *
  956.  *
  957.  *    Notes:
  958.  *
  959.  ***************************************************************************************/
  960. /* public */
  961. HRESULT ProfilerCallback::ClassLoadStarted( ClassID classID )
  962. {
  963.     //
  964.     // The class is just being loaded so we don't expect the
  965.     // data structure (representing the module) to be complete.
  966.     // Calls to ICorProfilerInfo::GetClassInfo wiil return 
  967.     // CORPROF_E_DATAINCOMPLETE at all times
  968.     //
  969.     return S_OK;
  970.  
  971. } // ProfilerCallback::ClassLoadStarted
  972.  
  973.  
  974. /***************************************************************************************
  975.  *    Method:
  976.  *
  977.  *
  978.  *    Purpose:
  979.  *
  980.  *
  981.  *    Parameters: 
  982.  *
  983.  *
  984.  *    Return value:
  985.  *
  986.  *
  987.  *    Notes:
  988.  *
  989.  ***************************************************************************************/
  990. /* public */
  991. HRESULT ProfilerCallback::ClassLoadFinished( ClassID classID, 
  992.                                              HRESULT hrStatus )
  993. {
  994.  
  995.     _ASSERT_( SUCCEEDED( hrStatus ) );
  996.  
  997.     try
  998.     {    
  999.            AddClass( classID );       
  1000.        }
  1001.     catch ( BaseException *exception )
  1002.     {        
  1003.         exception->ReportFailure();
  1004.         delete exception;
  1005.         
  1006.         Failure();    
  1007.     }
  1008.  
  1009.  
  1010.     return S_OK;
  1011.  
  1012. } // ProfilerCallback::ClassLoadFinished
  1013.  
  1014.  
  1015. /***************************************************************************************
  1016.  *    Method:
  1017.  *
  1018.  *
  1019.  *    Purpose:
  1020.  *
  1021.  *
  1022.  *    Parameters: 
  1023.  *
  1024.  *
  1025.  *    Return value:
  1026.  *
  1027.  *
  1028.  *    Notes:
  1029.  *
  1030.  ***************************************************************************************/
  1031. /* public */
  1032. HRESULT ProfilerCallback::ClassUnloadStarted( ClassID classID )
  1033. {
  1034.     //
  1035.     // At this point we can still use any information related to the 
  1036.     // class that started getting unloaded. 
  1037.     //
  1038.     return S_OK;
  1039.  
  1040. } // ProfilerCallback::ClassUnloadStarted
  1041.  
  1042.  
  1043. /***************************************************************************************
  1044.  *    Method:
  1045.  *
  1046.  *
  1047.  *    Purpose:
  1048.  *
  1049.  *
  1050.  *    Parameters: 
  1051.  *
  1052.  *
  1053.  *    Return value:
  1054.  *
  1055.  *
  1056.  *    Notes:
  1057.  *
  1058.  ***************************************************************************************/
  1059. /* public */
  1060. HRESULT ProfilerCallback::ClassUnloadFinished( ClassID classID, 
  1061.                                                HRESULT hrStatus )
  1062. {
  1063.     _ASSERT_( SUCCEEDED( hrStatus ) );
  1064.  
  1065.     try
  1066.     {    
  1067.            RemoveClass( classID );       
  1068.        }
  1069.     catch ( BaseException *exception )
  1070.     {        
  1071.         exception->ReportFailure();
  1072.         delete exception;
  1073.         
  1074.         Failure();    
  1075.     }
  1076.  
  1077.  
  1078.     return S_OK;
  1079.  
  1080. } // ProfilerCallback::ClassUnloadFinished
  1081.  
  1082.  
  1083. /***************************************************************************************
  1084.  *    Method:
  1085.  *
  1086.  *
  1087.  *    Purpose:
  1088.  *
  1089.  *
  1090.  *    Parameters: 
  1091.  *
  1092.  *
  1093.  *    Return value:
  1094.  *
  1095.  *
  1096.  *    Notes:
  1097.  *
  1098.  ***************************************************************************************/
  1099. /* public */
  1100. HRESULT ProfilerCallback::FunctionUnloadStarted( FunctionID functionID )
  1101. {
  1102.     //
  1103.     // This callback is not implemented yet
  1104.     //
  1105.     return S_OK;
  1106.  
  1107. } // ProfilerCallback::FunctionUnloadStarted
  1108.  
  1109.  
  1110. /***************************************************************************************
  1111.  *    Method:
  1112.  *
  1113.  *
  1114.  *    Purpose:
  1115.  *
  1116.  *
  1117.  *    Parameters: 
  1118.  *
  1119.  *
  1120.  *    Return value:
  1121.  *
  1122.  *
  1123.  *    Notes:
  1124.  *
  1125.  ***************************************************************************************/
  1126. /* public */
  1127. HRESULT ProfilerCallback::JITCompilationStarted( FunctionID functionID,
  1128.                                                  BOOL fIsSafeToBlock )
  1129. {
  1130.     //
  1131.     // This is a safe spot to use Get/setILFunctionbody, before the function
  1132.     // gets JIT-compiled. We are not making use of those API's in the present sample
  1133.     // Code Profiler
  1134.     //
  1135.     try
  1136.     {              
  1137.          AddFunction( functionID );       
  1138.     }
  1139.     catch ( BaseException *exception )
  1140.     {
  1141.         exception->ReportFailure();
  1142.         delete exception;
  1143.        
  1144.           Failure();    
  1145.     }
  1146.  
  1147.     return S_OK;
  1148.  
  1149. } // ProfilerCallback::JITCompilationStarted
  1150.  
  1151.  
  1152. /***************************************************************************************
  1153.  *  Method:
  1154.  *
  1155.  *
  1156.  *  Purpose:
  1157.  *
  1158.  *
  1159.  *  Parameters: 
  1160.  *
  1161.  *
  1162.  *  Return value:
  1163.  *
  1164.  *
  1165.  *  Notes:
  1166.  *
  1167.  ***************************************************************************************/
  1168. /* public */
  1169. HRESULT ProfilerCallback::JITCompilationFinished( FunctionID functionID,
  1170.                                                   HRESULT hrStatus,
  1171.                                                   BOOL fIsSafeToBlock )
  1172. {
  1173.     //
  1174.     // Add the function entry to the table that we maintain. All the information should
  1175.     // be available at this point. If the fucntion has been prejitted and the search
  1176.     // returned success, we will never hit that callback 
  1177.     //
  1178.     _ASSERT_( SUCCEEDED( hrStatus ) );
  1179.  
  1180.  
  1181.     try
  1182.     {              
  1183.          UpdateFunction( functionID, JITTED );       
  1184.     }
  1185.     catch ( BaseException *exception )
  1186.     {
  1187.         exception->ReportFailure();
  1188.         delete exception;
  1189.        
  1190.           Failure();    
  1191.     }
  1192.  
  1193.     return S_OK;
  1194.  
  1195. } // ProfilerCallback::JITCompilationFinished
  1196.  
  1197.  
  1198. /***************************************************************************************
  1199.  *    Method:
  1200.  *
  1201.  *
  1202.  *    Purpose:
  1203.  *
  1204.  *
  1205.  *    Parameters: 
  1206.  *
  1207.  *
  1208.  *    Return value:
  1209.  *
  1210.  *
  1211.  *    Notes:
  1212.  *
  1213.  ***************************************************************************************/
  1214. /* public */
  1215. HRESULT ProfilerCallback::JITCachedFunctionSearchStarted( FunctionID functionID,
  1216.                                                           BOOL *pbUseCachedFunction )
  1217. {
  1218.     //
  1219.     // If you found a prejitted version of a function then use it
  1220.     //
  1221.     *pbUseCachedFunction = TRUE;
  1222.  
  1223.     try
  1224.     {              
  1225.          AddFunction( functionID );       
  1226.     }
  1227.     catch ( BaseException *exception )
  1228.     {
  1229.         exception->ReportFailure();
  1230.         delete exception;
  1231.        
  1232.           Failure();    
  1233.     }
  1234.  
  1235.     
  1236.     return S_OK;
  1237.     
  1238. } // ProfilerCallback::JITCachedFunctionSearchStarted
  1239.  
  1240.  
  1241. /***************************************************************************************
  1242.  *    Method:
  1243.  *
  1244.  *
  1245.  *    Purpose:
  1246.  *
  1247.  *
  1248.  *    Parameters: 
  1249.  *
  1250.  *
  1251.  *    Return value:
  1252.  *
  1253.  *
  1254.  *    Notes:
  1255.  *
  1256.  ***************************************************************************************/
  1257. /* public */
  1258. HRESULT ProfilerCallback::JITCachedFunctionSearchFinished( FunctionID functionID,
  1259.                                                            COR_PRF_JIT_CACHE result )
  1260. {
  1261.     //
  1262.     // Add the function entry to the table that we maintain only if the search
  1263.     // has been successful. All the information should be available at this point.
  1264.     // If the fucntion has not been found, we will receive normal JIT compilation
  1265.     // started and finished callbacks 
  1266.     //
  1267.  
  1268.     if ( result != COR_PRF_CACHED_FUNCTION_NOT_FOUND )
  1269.     {
  1270.         try
  1271.         {              
  1272.              UpdateFunction( functionID, PREJITTED );       
  1273.         }
  1274.         catch ( BaseException *exception )
  1275.         {
  1276.             exception->ReportFailure();
  1277.             delete exception;
  1278.            
  1279.               Failure();    
  1280.         }
  1281.     }
  1282.     // else we will JIT the function so we will receive JIT events
  1283.  
  1284.     return S_OK;
  1285.     
  1286. } // ProfilerCallback::JITCachedFunctionSearchFinished
  1287.  
  1288.  
  1289. /***************************************************************************************
  1290.  *    Method:
  1291.  *
  1292.  *
  1293.  *    Purpose:
  1294.  *
  1295.  *
  1296.  *    Parameters: 
  1297.  *
  1298.  *
  1299.  *    Return value:
  1300.  *
  1301.  *
  1302.  *    Notes:
  1303.  *
  1304.  ***************************************************************************************/
  1305. /* public */
  1306. HRESULT ProfilerCallback::JITFunctionPitched( FunctionID functionID )
  1307. {
  1308.     //
  1309.     // We have pitched a function, mark its entry as pitched.
  1310.     // We will rejit the function if it is needed again. We mark it here
  1311.     // as pitched so we will not fail when we will attempt to add an entry 
  1312.     // that already exists in the JitCompilationFinished callback
  1313.     //
  1314.     try
  1315.     {              
  1316.          MarkFunctionAsPitched( functionID );       
  1317.     }
  1318.     catch ( BaseException *exception )
  1319.     {
  1320.         exception->ReportFailure();
  1321.         delete exception;
  1322.        
  1323.           Failure();    
  1324.     }
  1325.  
  1326.     
  1327.     return S_OK;
  1328.     
  1329. } // ProfilerCallback::JITFunctionPitched
  1330.  
  1331.  
  1332. /***************************************************************************************
  1333.  *    Method:
  1334.  *
  1335.  *
  1336.  *    Purpose:
  1337.  *
  1338.  *
  1339.  *    Parameters: 
  1340.  *
  1341.  *
  1342.  *    Return value:
  1343.  *
  1344.  *
  1345.  *    Notes:
  1346.  *
  1347.  ***************************************************************************************/
  1348. /* public */
  1349. HRESULT ProfilerCallback::JITInlining( FunctionID callerID,
  1350.                                        FunctionID calleeID,
  1351.                                        BOOL *pfShouldInline )
  1352. {
  1353.     //
  1354.     // We disabled the inliner globally, it is an error if we hit that code
  1355.     //
  1356.     _ASSERT_( !"JitInlining Callback Ocurred" );
  1357.  
  1358.     return S_OK;
  1359.  
  1360. } // ProfilerCallback::JITInlining
  1361.  
  1362.  
  1363. /***************************************************************************************
  1364.  *    Method:
  1365.  *
  1366.  *
  1367.  *    Purpose:
  1368.  *
  1369.  *
  1370.  *    Parameters: 
  1371.  *
  1372.  *
  1373.  *    Return value:
  1374.  *
  1375.  *
  1376.  *    Notes:
  1377.  *
  1378.  ***************************************************************************************/
  1379. /* public */
  1380. HRESULT ProfilerCallback::UnmanagedToManagedTransition( FunctionID functionID,
  1381.                                                         COR_PRF_TRANSITION_REASON reason )
  1382. {
  1383.     //
  1384.     // Update the status of thread.
  1385.     //
  1386.     try
  1387.     {              
  1388.          UpdateTransitionState( MANAGED );       
  1389.     }
  1390.     catch ( BaseException *exception )
  1391.     {
  1392.         exception->ReportFailure();
  1393.         delete exception;
  1394.        
  1395.           Failure();    
  1396.     }
  1397.  
  1398.  
  1399.     return S_OK;
  1400.  
  1401. } // ProfilerCallback::UnmanagedToManagedTransition
  1402.  
  1403.  
  1404. /***************************************************************************************
  1405.  *    Method:
  1406.  *
  1407.  *
  1408.  *    Purpose:
  1409.  *
  1410.  *
  1411.  *    Parameters: 
  1412.  *
  1413.  *
  1414.  *    Return value:
  1415.  *
  1416.  *
  1417.  *    Notes:
  1418.  *
  1419.  ***************************************************************************************/
  1420. /* public */
  1421. HRESULT ProfilerCallback::ManagedToUnmanagedTransition( FunctionID functionID,
  1422.                                                         COR_PRF_TRANSITION_REASON reason )
  1423. {
  1424.     //
  1425.     // Update the status of thread.
  1426.     //
  1427.     try
  1428.     {              
  1429.          UpdateTransitionState( UNMANAGED );       
  1430.     }
  1431.     catch ( BaseException *exception )
  1432.     {
  1433.         exception->ReportFailure();
  1434.         delete exception;
  1435.        
  1436.           Failure();    
  1437.     }
  1438.  
  1439.  
  1440.     return S_OK;
  1441.  
  1442. } // ProfilerCallback::ManagedToUnmanagedTransition
  1443.  
  1444.  
  1445. /***************************************************************************************
  1446.  *    Method:
  1447.  *
  1448.  *
  1449.  *    Purpose:
  1450.  *
  1451.  *
  1452.  *    Parameters: 
  1453.  *
  1454.  *
  1455.  *    Return value:
  1456.  *
  1457.  *
  1458.  *    Notes:
  1459.  *
  1460.  ***************************************************************************************/
  1461. /* public */ 
  1462. HRESULT ProfilerCallback::ThreadCreated( ThreadID threadID )
  1463. {
  1464.     //
  1465.     // A thread has been created, its Id is valid to use immediately.
  1466.     //
  1467.     try
  1468.     {              
  1469.          AddThread( threadID );       
  1470.     }
  1471.     catch ( BaseException *exception )
  1472.     {
  1473.         exception->ReportFailure();
  1474.         delete exception;
  1475.        
  1476.           Failure();    
  1477.     }
  1478.  
  1479.  
  1480.     return S_OK; 
  1481.     
  1482. } // ProfilerCallback::ThreadCreated
  1483.  
  1484.  
  1485. /***************************************************************************************
  1486.  *    Method:
  1487.  *
  1488.  *
  1489.  *    Purpose:
  1490.  *
  1491.  *
  1492.  *    Parameters: 
  1493.  *
  1494.  *
  1495.  *    Return value:
  1496.  *
  1497.  *
  1498.  *    Notes:
  1499.  *
  1500.  ***************************************************************************************/
  1501. /* public */
  1502. HRESULT ProfilerCallback::ThreadDestroyed( ThreadID threadID )
  1503. {
  1504.     //
  1505.     // A thread has been destroyed, mark its entry as invalid.
  1506.     //
  1507.     try
  1508.     {              
  1509.          RemoveThread( threadID );       
  1510.     }
  1511.     catch ( BaseException *exception )
  1512.     {
  1513.         exception->ReportFailure();
  1514.         delete exception;
  1515.        
  1516.           Failure();    
  1517.     }
  1518.  
  1519.  
  1520.     return S_OK;
  1521.     
  1522. } // ProfilerCallback::ThreadDestroyed
  1523.  
  1524.  
  1525. /***************************************************************************************
  1526.  *    Method:
  1527.  *
  1528.  *
  1529.  *    Purpose:
  1530.  *
  1531.  *
  1532.  *    Parameters: 
  1533.  *
  1534.  *
  1535.  *    Return value:
  1536.  *
  1537.  *
  1538.  *    Notes:
  1539.  *
  1540.  ***************************************************************************************/
  1541. /* public */
  1542. HRESULT ProfilerCallback::ThreadAssignedToOSThread( ThreadID managedThreadID,
  1543.                                                     DWORD osThreadID ) 
  1544. {
  1545.     //
  1546.     // A Runtime thread has changed Win32 thread that is assigned to.
  1547.     //
  1548.     try
  1549.     {              
  1550.          UpdateOSThreadID( managedThreadID, osThreadID );       
  1551.     }
  1552.     catch ( BaseException *exception )
  1553.     {
  1554.         exception->ReportFailure();
  1555.         delete exception;
  1556.        
  1557.           Failure();    
  1558.     }
  1559.  
  1560.  
  1561.     return S_OK;
  1562.     
  1563. } // ProfilerCallback::ThreadAssignedToOSThread
  1564.  
  1565.  
  1566. /***************************************************************************************
  1567.  *    Method:
  1568.  *
  1569.  *
  1570.  *    Purpose:
  1571.  *
  1572.  *
  1573.  *    Parameters: 
  1574.  *
  1575.  *
  1576.  *    Return value:
  1577.  *
  1578.  *
  1579.  *    Notes:
  1580.  *
  1581.  ***************************************************************************************/
  1582. /* public */
  1583. HRESULT ProfilerCallback::RemotingClientInvocationStarted()
  1584. {
  1585.     //
  1586.     // This callback is not monitored - default implementation
  1587.     //
  1588.     return S_OK;
  1589.     
  1590. } // ProfilerCallback::RemotingClientInvocationStarted
  1591.  
  1592.  
  1593. /***************************************************************************************
  1594.  *    Method:
  1595.  *
  1596.  *
  1597.  *    Purpose:
  1598.  *
  1599.  *
  1600.  *    Parameters: 
  1601.  *
  1602.  *
  1603.  *    Return value:
  1604.  *
  1605.  *
  1606.  *    Notes:
  1607.  *
  1608.  ***************************************************************************************/
  1609. /* public */
  1610. HRESULT ProfilerCallback::RemotingClientSendingMessage( GUID *pCookie,
  1611.                                                         BOOL fIsAsync )
  1612. {
  1613.     //
  1614.     // This callback is not monitored - default implementation
  1615.     //
  1616.     return S_OK;
  1617.     
  1618. } // ProfilerCallback::RemotingClientSendingMessage
  1619.  
  1620.  
  1621. /***************************************************************************************
  1622.  *    Method:
  1623.  *
  1624.  *
  1625.  *    Purpose:
  1626.  *
  1627.  *
  1628.  *    Parameters: 
  1629.  *
  1630.  *
  1631.  *    Return value:
  1632.  *
  1633.  *
  1634.  *    Notes:
  1635.  *
  1636.  ***************************************************************************************/
  1637. /* public */
  1638. HRESULT ProfilerCallback::RemotingClientReceivingReply(    GUID *pCookie,
  1639.                                                         BOOL fIsAsync )
  1640. {
  1641.     //
  1642.     // This callback is not monitored - default implementation
  1643.     //
  1644.     return S_OK;
  1645.     
  1646. } // ProfilerCallback::RemotingClientReceivingReply
  1647.  
  1648.  
  1649. /***************************************************************************************
  1650.  *    Method:
  1651.  *
  1652.  *
  1653.  *    Purpose:
  1654.  *
  1655.  *
  1656.  *    Parameters: 
  1657.  *
  1658.  *
  1659.  *    Return value:
  1660.  *
  1661.  *
  1662.  *    Notes:
  1663.  *
  1664.  ***************************************************************************************/
  1665. /* public */
  1666. HRESULT ProfilerCallback::RemotingClientInvocationFinished()
  1667. {
  1668.     //
  1669.     // This callback is not monitored - default implementation
  1670.     //
  1671.    return S_OK;
  1672.     
  1673. } // ProfilerCallback::RemotingClientInvocationFinished
  1674.  
  1675.  
  1676. /***************************************************************************************
  1677.  *    Method:
  1678.  *
  1679.  *
  1680.  *    Purpose:
  1681.  *
  1682.  *
  1683.  *    Parameters: 
  1684.  *
  1685.  *
  1686.  *    Return value:
  1687.  *
  1688.  *
  1689.  *    Notes:
  1690.  *
  1691.  ***************************************************************************************/
  1692. /* public */
  1693. HRESULT ProfilerCallback::RemotingServerReceivingMessage( GUID *pCookie,
  1694.                                                           BOOL fIsAsync )
  1695. {
  1696.     //
  1697.     // This callback is not monitored - default implementation
  1698.     //
  1699.     return S_OK;
  1700.     
  1701. } // ProfilerCallback::RemotingServerReceivingMessage
  1702.  
  1703.  
  1704. /***************************************************************************************
  1705.  *    Method:
  1706.  *
  1707.  *
  1708.  *    Purpose:
  1709.  *
  1710.  *
  1711.  *    Parameters: 
  1712.  *
  1713.  *
  1714.  *    Return value:
  1715.  *
  1716.  *
  1717.  *    Notes:
  1718.  *
  1719.  ***************************************************************************************/
  1720. /* public */
  1721. HRESULT ProfilerCallback::RemotingServerInvocationStarted()
  1722. {
  1723.     //
  1724.     // This callback is not monitored - default implementation
  1725.     //
  1726.     return S_OK;
  1727.     
  1728. } // ProfilerCallback::RemotingServerInvocationStarted
  1729.  
  1730.  
  1731. /***************************************************************************************
  1732.  *    Method:
  1733.  *
  1734.  *
  1735.  *    Purpose:
  1736.  *
  1737.  *
  1738.  *    Parameters: 
  1739.  *
  1740.  *
  1741.  *    Return value:
  1742.  *
  1743.  *
  1744.  *    Notes:
  1745.  *
  1746.  ***************************************************************************************/
  1747. /* public */
  1748. HRESULT ProfilerCallback::RemotingServerInvocationReturned()
  1749. {
  1750.     //
  1751.     // This callback is not monitored - default implementation
  1752.     //
  1753.     return S_OK;
  1754.     
  1755. } // ProfilerCallback::RemotingServerInvocationReturned
  1756.  
  1757.  
  1758. /***************************************************************************************
  1759.  *    Method:
  1760.  *
  1761.  *
  1762.  *    Purpose:
  1763.  *
  1764.  *
  1765.  *    Parameters: 
  1766.  *
  1767.  *
  1768.  *    Return value:
  1769.  *
  1770.  *
  1771.  *    Notes:
  1772.  *
  1773.  ***************************************************************************************/
  1774. /* public */
  1775. HRESULT ProfilerCallback::RemotingServerSendingReply( GUID *pCookie,
  1776.                                                       BOOL fIsAsync )
  1777. {
  1778.     //
  1779.     // This callback is not monitored - default implementation
  1780.     //
  1781.     return S_OK;
  1782.  
  1783. } // ProfilerCallback::RemotingServerSendingReply
  1784.  
  1785.  
  1786. /***************************************************************************************
  1787.  *    Method:
  1788.  *
  1789.  *
  1790.  *    Purpose:
  1791.  *
  1792.  *
  1793.  *    Parameters: 
  1794.  *
  1795.  *
  1796.  *    Return value:
  1797.  *
  1798.  *
  1799.  *    Notes:
  1800.  *
  1801.  ***************************************************************************************/
  1802. /* public */
  1803. HRESULT ProfilerCallback::RuntimeSuspendStarted( COR_PRF_SUSPEND_REASON suspendReason )
  1804. {
  1805.     //
  1806.     // This callback is not monitored - default implementation
  1807.     //
  1808.     return S_OK;
  1809.     
  1810. } // ProfilerCallback::RuntimeSuspendStarted
  1811.  
  1812.  
  1813. /***************************************************************************************
  1814.  *    Method:
  1815.  *
  1816.  *
  1817.  *    Purpose:
  1818.  *
  1819.  *
  1820.  *    Parameters: 
  1821.  *
  1822.  *
  1823.  *    Return value:
  1824.  *
  1825.  *
  1826.  *    Notes:
  1827.  *
  1828.  ***************************************************************************************/
  1829. /* public */
  1830. HRESULT ProfilerCallback::RuntimeSuspendFinished()
  1831. {
  1832.     //
  1833.     // This callback is not monitored - default implementation
  1834.     //
  1835.     return S_OK;
  1836.     
  1837. } // ProfilerCallback::RuntimeSuspendFinished
  1838.  
  1839.  
  1840. /***************************************************************************************
  1841.  *    Method:
  1842.  *
  1843.  *
  1844.  *    Purpose:
  1845.  *
  1846.  *
  1847.  *    Parameters: 
  1848.  *
  1849.  *
  1850.  *    Return value:
  1851.  *
  1852.  *
  1853.  *    Notes:
  1854.  *
  1855.  ***************************************************************************************/
  1856. /* public */
  1857. HRESULT ProfilerCallback::RuntimeSuspendAborted()
  1858. {
  1859.     //
  1860.     // This callback is not monitored - default implementation
  1861.     //
  1862.     return S_OK;
  1863.     
  1864. } // ProfilerCallback::RuntimeSuspendAborted
  1865.  
  1866.  
  1867. /***************************************************************************************
  1868.  *    Method:
  1869.  *
  1870.  *
  1871.  *    Purpose:
  1872.  *
  1873.  *
  1874.  *    Parameters: 
  1875.  *
  1876.  *
  1877.  *    Return value:
  1878.  *
  1879.  *
  1880.  *    Notes:
  1881.  *
  1882.  ***************************************************************************************/
  1883. /* public */
  1884. HRESULT ProfilerCallback::RuntimeResumeStarted()
  1885. {
  1886.     //
  1887.     // This callback is not monitored - default implementation
  1888.     //
  1889.     return S_OK;
  1890.     
  1891. } // ProfilerCallback::RuntimeResumeStarted
  1892.  
  1893.  
  1894. /***************************************************************************************
  1895.  *    Method:
  1896.  *
  1897.  *
  1898.  *    Purpose:
  1899.  *
  1900.  *
  1901.  *    Parameters: 
  1902.  *
  1903.  *
  1904.  *    Return value:
  1905.  *
  1906.  *
  1907.  *    Notes:
  1908.  *
  1909.  ***************************************************************************************/
  1910. /* public */
  1911. HRESULT ProfilerCallback::RuntimeResumeFinished()
  1912. {
  1913.     //
  1914.     // This callback is not monitored - default implementation
  1915.     //
  1916.     return S_OK;
  1917.     
  1918. } // ProfilerCallback::RuntimeResumeFinished
  1919.  
  1920.  
  1921. /***************************************************************************************
  1922.  *    Method:
  1923.  *
  1924.  *
  1925.  *    Purpose:
  1926.  *
  1927.  *
  1928.  *    Parameters: 
  1929.  *
  1930.  *
  1931.  *    Return value:
  1932.  *
  1933.  *
  1934.  *    Notes:
  1935.  *
  1936.  ***************************************************************************************/
  1937. /* public */
  1938. HRESULT ProfilerCallback::RuntimeThreadSuspended( ThreadID threadID )
  1939. {
  1940.     //
  1941.     // This callback is not monitored - default implementation
  1942.     //
  1943.     return S_OK;
  1944.     
  1945. } // ProfilerCallback::RuntimeThreadSuspended
  1946.  
  1947.  
  1948. /***************************************************************************************
  1949.  *    Method:
  1950.  *
  1951.  *
  1952.  *    Purpose:
  1953.  *
  1954.  *
  1955.  *    Parameters: 
  1956.  *
  1957.  *
  1958.  *    Return value:
  1959.  *
  1960.  *
  1961.  *    Notes:
  1962.  *
  1963.  ***************************************************************************************/
  1964. /* public */
  1965. HRESULT ProfilerCallback::RuntimeThreadResumed( ThreadID threadID )
  1966. {
  1967.     //
  1968.     // This callback is not monitored - default implementation
  1969.     //
  1970.     return S_OK;
  1971.     
  1972. } // ProfilerCallback::RuntimeThreadResumed
  1973.  
  1974.  
  1975. /***************************************************************************************
  1976.  *    Method:
  1977.  *
  1978.  *
  1979.  *    Purpose:
  1980.  *
  1981.  *
  1982.  *    Parameters: 
  1983.  *
  1984.  *
  1985.  *    Return value:
  1986.  *
  1987.  *
  1988.  *    Notes:
  1989.  *
  1990.  ***************************************************************************************/
  1991. /* public */
  1992. HRESULT ProfilerCallback::MovedReferences( ULONG cmovedObjectIDRanges,
  1993.                                            ObjectID oldObjectIDRangeStart[],
  1994.                                            ObjectID newObjectIDRangeStart[],
  1995.                                            ULONG cObjectIDRangeLength[] )
  1996. {
  1997.     //
  1998.     // This callback is not monitored - default implementation
  1999.     //
  2000.     return S_OK;
  2001.  
  2002. } // ProfilerCallback::MovedReferences
  2003.  
  2004.  
  2005. /***************************************************************************************
  2006.  *    Method:
  2007.  *
  2008.  *
  2009.  *    Purpose:
  2010.  *
  2011.  *
  2012.  *    Parameters: 
  2013.  *
  2014.  *
  2015.  *    Return value:
  2016.  *
  2017.  *
  2018.  *    Notes:
  2019.  *
  2020.  ***************************************************************************************/
  2021. /* public */
  2022. HRESULT ProfilerCallback::ObjectAllocated( ObjectID objectID,
  2023.                                            ClassID classID )
  2024. {
  2025.     //
  2026.     // This callback is not implemented yet
  2027.     //
  2028.     return S_OK;
  2029.  
  2030. } // ProfilerCallback::ObjectAllocated
  2031.  
  2032.  
  2033. /***************************************************************************************
  2034.  *    Method:
  2035.  *
  2036.  *
  2037.  *    Purpose:
  2038.  *
  2039.  *
  2040.  *    Parameters: 
  2041.  *
  2042.  *
  2043.  *    Return value:
  2044.  *
  2045.  *
  2046.  *    Notes:
  2047.  *
  2048.  ***************************************************************************************/
  2049. /* public */
  2050. HRESULT ProfilerCallback::ObjectsAllocatedByClass( ULONG classCount,
  2051.                                                    ClassID classIDs[],
  2052.                                                    ULONG objects[] )
  2053. {
  2054.     //
  2055.     // This callback is not monitored - default implementation
  2056.     //
  2057.     return S_OK;
  2058.  
  2059. } // ProfilerCallback::ObjectsAllocatedByClass
  2060.  
  2061.  
  2062. /***************************************************************************************
  2063.  *    Method:
  2064.  *
  2065.  *
  2066.  *    Purpose:
  2067.  *
  2068.  *
  2069.  *    Parameters: 
  2070.  *
  2071.  *
  2072.  *    Return value:
  2073.  *
  2074.  *
  2075.  *    Notes:
  2076.  *
  2077.  ***************************************************************************************/
  2078. /* public */
  2079. HRESULT ProfilerCallback::ObjectReferences( ObjectID objectID,
  2080.                                             ClassID classID,
  2081.                                             ULONG objectRefs,
  2082.                                             ObjectID objectRefIDs[] )
  2083. {
  2084.     //
  2085.     // This callback is not monitored - default implementation
  2086.     //
  2087.     return S_OK;
  2088.  
  2089. } // ProfilerCallback::ObjectReferences
  2090.  
  2091.  
  2092. /***************************************************************************************
  2093.  *    Method:
  2094.  *
  2095.  *
  2096.  *    Purpose:
  2097.  *
  2098.  *
  2099.  *    Parameters: 
  2100.  *
  2101.  *
  2102.  *    Return value:
  2103.  *
  2104.  *
  2105.  *    Notes:
  2106.  *
  2107.  ***************************************************************************************/
  2108. /* public */
  2109. HRESULT ProfilerCallback::RootReferences( ULONG rootRefs,
  2110.                                           ObjectID rootRefIDs[] )
  2111. {
  2112.     //
  2113.     // This callback is not monitored - default implementation
  2114.     //
  2115.     return S_OK;
  2116.  
  2117. } // ProfilerCallback::RootReferences
  2118.  
  2119.  
  2120. /***************************************************************************************
  2121.  *    Method:
  2122.  *
  2123.  *
  2124.  *    Purpose:
  2125.  *
  2126.  *
  2127.  *    Parameters: 
  2128.  *
  2129.  *
  2130.  *    Return value:
  2131.  *
  2132.  *
  2133.  *    Notes:
  2134.  *
  2135.  ***************************************************************************************/
  2136. /* public */
  2137. HRESULT ProfilerCallback::ExceptionThrown( ObjectID thrownObjectID )
  2138. {
  2139.     //
  2140.     // We are not extracting information about exceptions - default implementation
  2141.     //
  2142.     return S_OK;
  2143.  
  2144. } // ProfilerCallback::ExceptionThrown 
  2145.  
  2146.  
  2147. /***************************************************************************************
  2148.  *    Method:
  2149.  *
  2150.  *
  2151.  *    Purpose:
  2152.  *
  2153.  *
  2154.  *    Parameters: 
  2155.  *
  2156.  *
  2157.  *    Return value:
  2158.  *
  2159.  *
  2160.  *    Notes:
  2161.  *
  2162.  ***************************************************************************************/
  2163. /* public */
  2164. HRESULT ProfilerCallback::ExceptionUnwindFunctionEnter( FunctionID functionID )
  2165. {
  2166.     //
  2167.     // We have to push the function ID to the stack related to the thread that
  2168.     // invoked the ExceptionUnwindFunctionEnter() callback. We need to cache the
  2169.     // functionID because in case of nested callback we will not which function's
  2170.     // counters to update  
  2171.     //
  2172.     try
  2173.     {
  2174.         UpdateUnwindStack( &functionID, PUSH ); 
  2175.        }
  2176.     catch ( BaseException *exception )
  2177.     {        
  2178.         exception->ReportFailure();
  2179.         delete exception;
  2180.         
  2181.         Failure();               
  2182.     }
  2183.  
  2184.  
  2185.     return S_OK;
  2186.  
  2187. } // ProfilerCallback::ExceptionUnwindFunctionEnter
  2188.  
  2189.  
  2190. /***************************************************************************************
  2191.  *    Method:
  2192.  *
  2193.  *
  2194.  *    Purpose:
  2195.  *
  2196.  *
  2197.  *    Parameters: 
  2198.  *
  2199.  *
  2200.  *    Return value:
  2201.  *
  2202.  *
  2203.  *    Notes:
  2204.  *
  2205.  ***************************************************************************************/
  2206. /* public */
  2207. HRESULT ProfilerCallback::ExceptionUnwindFunctionLeave( )
  2208. {
  2209.     //
  2210.     // We have to pop the function ID from the stack related to the thread that
  2211.     // invoked the ExceptionUnwindFunctionLeave() callback. We will use this function 
  2212.     // ID to update its counters after we do a search in the function's list. 
  2213.     // 
  2214.     try
  2215.     {
  2216.         FunctionID functionID;
  2217.         
  2218.         
  2219.         //
  2220.         // Pop the last function that was pushed to th thread's unwind stack
  2221.         // and update the function's counters 
  2222.         //
  2223.         UpdateUnwindStack( &functionID, POP );
  2224.         UpdateEnterExitCounters( functionID, UNWIND );
  2225.        }
  2226.     catch ( BaseException *exception )
  2227.     {        
  2228.         exception->ReportFailure();
  2229.         delete exception;
  2230.         
  2231.         Failure();               
  2232.     }
  2233.  
  2234.  
  2235.     return S_OK;
  2236.  
  2237. } // ProfilerCallback::ExceptionUnwindFunctionLeave
  2238.  
  2239.  
  2240. /***************************************************************************************
  2241.  *    Method:
  2242.  *
  2243.  *
  2244.  *    Purpose:
  2245.  *
  2246.  *
  2247.  *    Parameters: 
  2248.  *
  2249.  *
  2250.  *    Return value:
  2251.  *
  2252.  *
  2253.  *    Notes:
  2254.  *
  2255.  ***************************************************************************************/
  2256. /* public */
  2257. HRESULT ProfilerCallback::ExceptionSearchFunctionEnter( FunctionID functionID )
  2258. {
  2259.     //
  2260.     // We are not extracting information about exceptions - default implementation
  2261.     //
  2262.     return S_OK;
  2263.  
  2264. } // ProfilerCallback::ExceptionSearchFunctionEnter
  2265.  
  2266.  
  2267. /***************************************************************************************
  2268.  *    Method:
  2269.  *
  2270.  *
  2271.  *    Purpose:
  2272.  *
  2273.  *
  2274.  *    Parameters: 
  2275.  *
  2276.  *
  2277.  *    Return value:
  2278.  *
  2279.  *
  2280.  *    Notes:
  2281.  *
  2282.  ***************************************************************************************/
  2283. /* public */
  2284. HRESULT ProfilerCallback::ExceptionSearchFunctionLeave()
  2285. {
  2286.     //
  2287.     // We are not extracting information about exceptions - default implementation
  2288.     //
  2289.     return S_OK;
  2290.  
  2291. } // ProfilerCallback::ExceptionSearchFunctionLeave
  2292.  
  2293.  
  2294. /***************************************************************************************
  2295.  *    Method:
  2296.  *
  2297.  *
  2298.  *    Purpose:
  2299.  *
  2300.  *
  2301.  *    Parameters: 
  2302.  *
  2303.  *
  2304.  *    Return value:
  2305.  *
  2306.  *
  2307.  *    Notes:
  2308.  *
  2309.  ***************************************************************************************/
  2310. /* public */
  2311. HRESULT ProfilerCallback::ExceptionSearchFilterEnter( FunctionID functionID )
  2312. {
  2313.     //
  2314.     // We are not extracting information about exceptions - default implementation
  2315.     //
  2316.     return S_OK;
  2317.  
  2318. } // ProfilerCallback::ExceptionSearchFilterEnter
  2319.  
  2320.  
  2321. /***************************************************************************************
  2322.  *    Method:
  2323.  *
  2324.  *
  2325.  *    Purpose:
  2326.  *
  2327.  *
  2328.  *    Parameters: 
  2329.  *
  2330.  *
  2331.  *    Return value:
  2332.  *
  2333.  *
  2334.  *    Notes:
  2335.  *
  2336.  ***************************************************************************************/
  2337. /* public */
  2338. HRESULT ProfilerCallback::ExceptionSearchFilterLeave()
  2339. {
  2340.     //
  2341.     // We are not extracting information about exceptions - default implementation
  2342.     //
  2343.     return S_OK;
  2344.  
  2345. } // ProfilerCallback::ExceptionSearchFilterLeave 
  2346.  
  2347.  
  2348. /***************************************************************************************
  2349.  *    Method:
  2350.  *
  2351.  *
  2352.  *    Purpose:
  2353.  *
  2354.  *
  2355.  *    Parameters: 
  2356.  *
  2357.  *
  2358.  *    Return value:
  2359.  *
  2360.  *
  2361.  *    Notes:
  2362.  *
  2363.  ***************************************************************************************/
  2364. /* public */
  2365. HRESULT ProfilerCallback::ExceptionSearchCatcherFound( FunctionID functionID )
  2366. {
  2367.     //
  2368.     // We are not extracting information about exceptions - default implementation
  2369.     //
  2370.     return S_OK;
  2371.  
  2372. } // ProfilerCallback::ExceptionSearchCatcherFound
  2373.  
  2374.  
  2375. /***************************************************************************************
  2376.  *  Method:
  2377.  *
  2378.  *
  2379.  *  Purpose:
  2380.  *
  2381.  *
  2382.  *  Parameters:
  2383.  *
  2384.  *
  2385.  *  Return value:
  2386.  *
  2387.  *
  2388.  *  Notes:
  2389.  *
  2390.  ***************************************************************************************/
  2391. /* public */
  2392. HRESULT ProfilerCallback::ExceptionCLRCatcherFound()
  2393. {
  2394.     return S_OK;
  2395. }
  2396.  
  2397.  
  2398. /***************************************************************************************
  2399.  *  Method:
  2400.  *
  2401.  *
  2402.  *  Purpose:
  2403.  *
  2404.  *
  2405.  *  Parameters:
  2406.  *
  2407.  *
  2408.  *  Return value:
  2409.  *
  2410.  *
  2411.  *  Notes:
  2412.  *
  2413.  ***************************************************************************************/
  2414. /* public */
  2415. HRESULT ProfilerCallback::ExceptionCLRCatcherExecute()
  2416. {
  2417.     return S_OK;
  2418. }
  2419.  
  2420.  
  2421. /***************************************************************************************
  2422.  *    Method:
  2423.  *
  2424.  *
  2425.  *    Purpose:
  2426.  *
  2427.  *
  2428.  *    Parameters: 
  2429.  *
  2430.  *
  2431.  *    Return value:
  2432.  *
  2433.  *
  2434.  *    Notes:
  2435.  *
  2436.  ***************************************************************************************/
  2437. /* public */
  2438. HRESULT ProfilerCallback::ExceptionOSHandlerEnter( FunctionID functionID )
  2439. {
  2440.     //
  2441.     // We are not extracting information about exceptions - default implementation
  2442.     //
  2443.     return S_OK;
  2444.  
  2445. } // ProfilerCallback::ExceptionOSHandlerEnter
  2446.  
  2447.     
  2448. /***************************************************************************************
  2449.  *    Method:
  2450.  *
  2451.  *
  2452.  *    Purpose:
  2453.  *
  2454.  *
  2455.  *    Parameters: 
  2456.  *
  2457.  *
  2458.  *    Return value:
  2459.  *
  2460.  *
  2461.  *    Notes:
  2462.  *
  2463.  ***************************************************************************************/
  2464. /* public */
  2465. HRESULT ProfilerCallback::ExceptionOSHandlerLeave( FunctionID functionID )
  2466. {
  2467.     //
  2468.     // We are not extracting information about exceptions - default implementation
  2469.     //
  2470.     return S_OK;
  2471.  
  2472. } // ProfilerCallback::ExceptionOSHandlerLeave
  2473.  
  2474.  
  2475. /***************************************************************************************
  2476.  *    Method:
  2477.  *
  2478.  *
  2479.  *    Purpose:
  2480.  *
  2481.  *
  2482.  *    Parameters: 
  2483.  *
  2484.  *
  2485.  *    Return value:
  2486.  *
  2487.  *
  2488.  *    Notes:
  2489.  *
  2490.  ***************************************************************************************/
  2491. /* public */
  2492. HRESULT ProfilerCallback::ExceptionUnwindFinallyEnter( FunctionID functionID )
  2493. {
  2494.     //
  2495.     // We are not extracting information about exceptions - default implementation
  2496.     //
  2497.     return S_OK;
  2498.  
  2499. } // ProfilerCallback::ExceptionUnwindFinallyEnter
  2500.  
  2501.  
  2502. /***************************************************************************************
  2503.  *    Method:
  2504.  *
  2505.  *
  2506.  *    Purpose:
  2507.  *
  2508.  *
  2509.  *    Parameters: 
  2510.  *
  2511.  *
  2512.  *    Return value:
  2513.  *
  2514.  *
  2515.  *    Notes:
  2516.  *
  2517.  ***************************************************************************************/
  2518. /* public */
  2519. HRESULT ProfilerCallback::ExceptionUnwindFinallyLeave()
  2520. {
  2521.     //
  2522.     // We are not extracting information about exceptions - default implementation
  2523.     //
  2524.     return S_OK;
  2525.  
  2526. } // ProfilerCallback::ExceptionUnwindFinallyLeave
  2527.  
  2528.  
  2529. /***************************************************************************************
  2530.  *    Method:
  2531.  *
  2532.  *
  2533.  *    Purpose:
  2534.  *
  2535.  *
  2536.  *    Parameters: 
  2537.  *
  2538.  *
  2539.  *    Return value:
  2540.  *
  2541.  *
  2542.  *    Notes:
  2543.  *
  2544.  ***************************************************************************************/
  2545. /* public */
  2546. HRESULT ProfilerCallback::ExceptionCatcherEnter( FunctionID functionID,
  2547.                                                  ObjectID objectID )
  2548. {
  2549.     //
  2550.     // We are not extracting information about exceptions - default implementation
  2551.     //
  2552.     return S_OK;
  2553.  
  2554. } // ProfilerCallback::ExceptionCatcherEnter
  2555.  
  2556.  
  2557. /***************************************************************************************
  2558.  *    Method:
  2559.  *
  2560.  *
  2561.  *    Purpose:
  2562.  *
  2563.  *
  2564.  *    Parameters: 
  2565.  *
  2566.  *
  2567.  *    Return value:
  2568.  *
  2569.  *
  2570.  *    Notes:
  2571.  *
  2572.  ***************************************************************************************/
  2573. /* public */
  2574. HRESULT ProfilerCallback::ExceptionCatcherLeave()
  2575. {
  2576.     //
  2577.     // We are not extracting information about exceptions - default implementation
  2578.     //
  2579.     return S_OK;
  2580.  
  2581. } // ProfilerCallback::ExceptionCatcherLeave
  2582.  
  2583.  
  2584. /***************************************************************************************
  2585.  *    Method:
  2586.  *
  2587.  *
  2588.  *    Purpose:
  2589.  *
  2590.  *
  2591.  *    Parameters: 
  2592.  *
  2593.  *
  2594.  *    Return value:
  2595.  *
  2596.  *
  2597.  *    Notes:
  2598.  *
  2599.  ***************************************************************************************/
  2600. /* public */
  2601. HRESULT ProfilerCallback::COMClassicVTableCreated( ClassID wrappedClassID,
  2602.                                                     REFGUID implementedIID,
  2603.                                                     void *pVTable,
  2604.                                                     ULONG cSlots )
  2605. {
  2606.     return S_OK;
  2607.  
  2608. } // ProfilerCallback::COMClassicVTableCreated
  2609.  
  2610.  
  2611. /***************************************************************************************
  2612.  *    Method:
  2613.  *
  2614.  *
  2615.  *    Purpose:
  2616.  *
  2617.  *
  2618.  *    Parameters: 
  2619.  *
  2620.  *
  2621.  *    Return value:
  2622.  *
  2623.  *
  2624.  *    Notes:
  2625.  *
  2626.  ***************************************************************************************/
  2627. /* public */
  2628. HRESULT ProfilerCallback::COMClassicVTableDestroyed( ClassID wrappedClassID,
  2629.                                                       REFGUID implementedIID,
  2630.                                                       void *pVTable )
  2631. {
  2632.     return S_OK;
  2633.  
  2634. } // ProfilerCallback::COMClassicVTableDestroyed
  2635.  
  2636.  
  2637. /***************************************************************************************
  2638.  *  Method:
  2639.  *
  2640.  *
  2641.  *  Purpose:
  2642.  *
  2643.  *
  2644.  *  Parameters: 
  2645.  *
  2646.  *
  2647.  *  Return value:
  2648.  *
  2649.  *
  2650.  *  Notes:
  2651.  *
  2652.  ***************************************************************************************/
  2653. /* public */
  2654. void ProfilerCallback::Enter( FunctionID functionID )
  2655. {
  2656.     g_pCallbackObject->UpdateEnterExitCounters( functionID, ENTER );
  2657.  
  2658. } // ProfilerCallback::Enter
  2659.  
  2660.  
  2661. /***************************************************************************************
  2662.  *  Method:
  2663.  *
  2664.  *
  2665.  *  Purpose:
  2666.  *
  2667.  *
  2668.  *  Parameters: 
  2669.  *
  2670.  *
  2671.  *  Return value:
  2672.  *
  2673.  *
  2674.  *  Notes:
  2675.  *
  2676.  ***************************************************************************************/
  2677. /* public */
  2678. void ProfilerCallback::Leave( FunctionID functionID )
  2679. {
  2680.     g_pCallbackObject->UpdateEnterExitCounters( functionID, LEAVE );
  2681.  
  2682. } // ProfilerCallback::Leave
  2683.  
  2684.  
  2685. /***************************************************************************************
  2686.  *    Method:
  2687.  *
  2688.  *
  2689.  *    Purpose:
  2690.  *
  2691.  *
  2692.  *    Parameters: 
  2693.  *
  2694.  *
  2695.  *    Return value:
  2696.  *
  2697.  *
  2698.  *    Notes:
  2699.  *
  2700.  ***************************************************************************************/
  2701. /* public */
  2702. void ProfilerCallback::Tailcall( FunctionID functionID )
  2703. {
  2704.     g_pCallbackObject->UpdateEnterExitCounters( functionID, TAIL );
  2705.  
  2706. } // ProfilerCallback::Tailcall
  2707.  
  2708.  
  2709. /***************************************************************************************
  2710.  *    Method:
  2711.  *
  2712.  *
  2713.  *    Purpose:
  2714.  *
  2715.  *
  2716.  *    Parameters: 
  2717.  *
  2718.  *
  2719.  *    Return value:
  2720.  *
  2721.  *
  2722.  *    Notes:
  2723.  *
  2724.  ***************************************************************************************/
  2725. /* public */
  2726. UINT_PTR ProfilerCallback::FunctionMapper( FunctionID functionID,
  2727.                                            BOOL *pbHookFunction )
  2728. {
  2729.     //
  2730.     // Use a default function mapper implementation
  2731.     //
  2732.     *pbHookFunction = TRUE;    
  2733.  
  2734.  
  2735.     return (UINT_PTR) functionID;
  2736.  
  2737. } // ProfilerCallback::FunctionMapper
  2738.  
  2739.  
  2740. /***************************************************************************************
  2741.  ********************                                               ********************
  2742.  ********************              DllMain/ClassFactory             ********************
  2743.  ********************                                               ********************
  2744.  ***************************************************************************************/ 
  2745. #include "dllmain.hpp"
  2746.  
  2747. // End of File
  2748.  
  2749.