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

  1. /****************************************************************************************
  2.  * Copyright (c) Microsoft Corporation.  All Rights Reserved.
  3.  *
  4.  * File:
  5.  *  ProfilerHelper.h
  6.  *
  7.  * Description:
  8.  *    
  9.  *
  10.  *
  11.  ***************************************************************************************/
  12. #ifndef __PROFILERHELPER_H__
  13. #define __PROFILERHELPER_H__
  14.  
  15.  
  16. /***************************************************************************************
  17.  ********************                                               ********************
  18.  ********************              Type Definitions                 ********************
  19.  ********************                                               ********************
  20.  ***************************************************************************************/
  21.  
  22. enum TransitionState
  23.     UNINITIALIZED,
  24.     MANAGED, 
  25.     UNMANAGED
  26. };
  27.  
  28. enum StackAction
  29.     PUSH, 
  30.     POP 
  31. };
  32.  
  33. enum FunctionCounters
  34.     ENTER, 
  35.     LEAVE, 
  36.     TAIL, 
  37.     UNWIND
  38. };
  39.  
  40. enum JitStatus
  41.     NONE,
  42.     JITTED, 
  43.     PREJITTED,
  44. };
  45.  
  46. /***************************************************************************************
  47.  ********************                                               ********************
  48.  ********************             StackBaseInfo Declaration         ********************
  49.  ********************                                               ********************
  50.  ***************************************************************************************/
  51. class StackBaseInfo
  52. {
  53.     public:
  54.     
  55.         StackBaseInfo( ULONG id );         
  56.         virtual ~StackBaseInfo();
  57.                 
  58.         
  59.     public:
  60.             
  61.          StackBaseInfo *Clone();
  62.          void Dump();
  63.         
  64.         
  65.      public:
  66.     
  67.         ULONG m_id;
  68.  
  69.     
  70. }; // StackBaseInfo
  71.  
  72.  
  73. /***************************************************************************************
  74.  ********************                                               ********************
  75.  ********************             BaseInfo Declaration              ********************
  76.  ********************                                               ********************
  77.  ***************************************************************************************/
  78. class BaseInfo
  79. {
  80.     public:
  81.     
  82.         BaseInfo( ULONG id );         
  83.         virtual ~BaseInfo();
  84.                 
  85.         
  86.     public:
  87.             
  88.         virtual void Dump();
  89.         BOOL Compare( ULONG key );
  90.         
  91.         
  92.      public:
  93.     
  94.         ULONG m_id;
  95.         BOOL  m_isValid;
  96.         WCHAR m_name[MAX_LENGTH];
  97.     
  98. }; // BaseInfo
  99.  
  100.  
  101. /***************************************************************************************
  102.  ********************                                               ********************
  103.  ********************            AppDomainInfo Declaration          ********************
  104.  ********************                                               ********************
  105.  ***************************************************************************************/
  106. class AppDomainInfo :
  107.     public BaseInfo
  108. {
  109.     public:
  110.  
  111.         AppDomainInfo( AppDomainID appDomainID );
  112.            virtual ~AppDomainInfo();
  113.       
  114.  
  115.     public:
  116.     
  117.         void Dump();        
  118.         
  119.         
  120.     public:    
  121.                        
  122.         ProcessID m_processID;            
  123.                        
  124. }; // AppDomainInfo
  125.  
  126.  
  127.  
  128. /***************************************************************************************
  129.  ********************                                               ********************
  130.  ********************            AssemblyInfo  Declaration          ********************
  131.  ********************                                               ********************
  132.  ***************************************************************************************/
  133. class AssemblyInfo :
  134.     public BaseInfo
  135. {
  136.     public:
  137.  
  138.         AssemblyInfo( AssemblyID assemblyID );
  139.            virtual ~AssemblyInfo();
  140.       
  141.  
  142.     public:
  143.     
  144.         void Dump();        
  145.         
  146.         
  147.     public:    
  148.                        
  149.         ModuleID    m_moduleID;
  150.         AppDomainID    m_appDomainID;
  151.                        
  152. }; // AssemblyInfo
  153.  
  154.  
  155. /***************************************************************************************
  156.  ********************                                               ********************
  157.  ********************            ModuleInfo Declaration             ********************
  158.  ********************                                               ********************
  159.  ***************************************************************************************/
  160. class ModuleInfo :
  161.     public BaseInfo
  162. {
  163.     public:
  164.  
  165.         ModuleInfo( ModuleID moduleID );
  166.            virtual ~ModuleInfo();
  167.       
  168.  
  169.     public:
  170.     
  171.         void Dump();        
  172.         
  173.         
  174.     public:    
  175.                        
  176.         AssemblyID        m_assemblyID;    
  177.         IMetaDataImport    *m_pMDImport;    
  178.         LPCBYTE            m_pBaseLoadAddress;        
  179.                        
  180. }; // ModuleInfo
  181.  
  182.  
  183. /***************************************************************************************
  184.  ********************                                               ********************
  185.  ********************             ClassInfo Declaration             ********************
  186.  ********************                                               ********************
  187.  ***************************************************************************************/
  188. class ClassInfo :
  189.     public BaseInfo
  190. {
  191.     public:
  192.  
  193.         ClassInfo( ClassID classID );
  194.            virtual ~ClassInfo();
  195.       
  196.  
  197.     public:
  198.     
  199.         void Dump();        
  200.         
  201.         
  202.     public:    
  203.                    
  204.         mdTypeDef m_token;
  205.            ModuleID  m_moduleID;    
  206.                        
  207. }; // ClassInfo
  208.  
  209.  
  210. /***************************************************************************************
  211.  ********************                                               ********************
  212.  ********************            ThreadInfo Declaration             ********************
  213.  ********************                                               ********************
  214.  ***************************************************************************************/
  215. class ThreadInfo :
  216.     public BaseInfo
  217. {
  218.     public:
  219.  
  220.         ThreadInfo( ThreadID threadID );         
  221.         virtual ~ThreadInfo();
  222.         
  223.  
  224.     public:
  225.     
  226.         virtual void Dump();
  227.                 
  228.         
  229.     public:    
  230.                 
  231.         // 
  232.         // Once a thread dies, it is possible for its ID to be re-used
  233.         // We will remeber the originalID in order to print the information
  234.         // for each thread in the end of the run.
  235.         //
  236.         DWORD m_originalTID;
  237.         
  238.         HANDLE                    m_hThread;
  239.         TransitionState            m_status;
  240.         DWORD                     m_win32ThreadID;
  241.         CStack<StackBaseInfo *> *m_pLatestUnwoundFunction;
  242.                 
  243. }; // ThreadInfo
  244.  
  245.  
  246. /***************************************************************************************
  247.  ********************                                               ********************
  248.  ********************          FunctionInfo Declaration             ********************
  249.  ********************                                               ********************
  250.  ***************************************************************************************/
  251. class FunctionInfo :
  252.     public BaseInfo
  253. {
  254.     public:
  255.  
  256.         FunctionInfo( FunctionID functionID );
  257.            virtual ~FunctionInfo();
  258.       
  259.  
  260.     public:
  261.     
  262.         void Dump();     
  263.         
  264.         
  265.     public:    
  266.                                         
  267.         // function counters
  268.         LONG         m_enter;
  269.         LONG         m_left;
  270.         LONG         m_tail;
  271.         LONG         m_unwind;
  272.  
  273.         // jit related information
  274.         JitStatus    m_jitStatus;
  275.         BOOL         m_isPitched;
  276.  
  277.         // other info
  278.         mdToken      m_token;               
  279.         ClassID      m_classID;
  280.         ModuleID     m_moduleID; 
  281.         ULONG        m_codeSize;
  282.         LPCBYTE      m_pStartAddress;
  283.         
  284. }; // FunctionInfo
  285.  
  286.  
  287. /***************************************************************************************
  288.  ********************                                               ********************
  289.  ********************              PrfInfo Declaration              ********************
  290.  ********************                                               ********************
  291.  ***************************************************************************************/
  292. class PrfInfo
  293. {             
  294.     public:
  295.     
  296.         PrfInfo();                     
  297.         virtual ~PrfInfo();                      
  298.                       
  299.                    
  300.     // methods
  301.        
  302.        public:
  303.                     
  304.         // tables
  305.         void DumpTables();
  306.         void Failure( char *message = NULL );
  307.  
  308.         // class methods
  309.         void AddClass( ClassID classID );
  310.         void RemoveClass( ClassID classID );
  311.  
  312.         // thread methods
  313.         void AddThread( ThreadID threadID );                        
  314.         void RemoveThread( ThreadID threadID );
  315.         void UpdateTransitionState( TransitionState state );                        
  316.         void UpdateOSThreadID( ThreadID managedThreadID, DWORD osThreadID );
  317.         void UpdateUnwindStack( FunctionID *functionID, StackAction action );
  318.         
  319.         // module methods
  320.         void AddModule( ModuleID moduleID );                 
  321.         void RemoveModule( ModuleID moduleID );                 
  322.         void ReleaseModuleMDInterface( ModuleID moduleID );
  323.         void UpdateAssemblyInModule( ModuleID moduleID, AssemblyID assemblyID );
  324.  
  325.         // function methods
  326.         void AddFunction( FunctionID functionID ); 
  327.         void UpdateFunction( FunctionID functionID, JitStatus status ); 
  328.         void RemoveFunction( FunctionID functionID );
  329.         void MarkFunctionAsPitched( FunctionID functionID );
  330.         void UpdateEnterExitCounters( FunctionID functionID, FunctionCounters which );
  331.  
  332.         // assembly methods
  333.         void AddAssembly( AssemblyID assemblyID );                                    
  334.         void RemoveAssembly( AssemblyID assemblyID );                                    
  335.  
  336.         // appdomain methods
  337.         void AddAppDomain( AppDomainID appDomainID );
  338.         void RemoveAppDomain( AppDomainID appDomainID );
  339.  
  340.  
  341.       private:
  342.     
  343.         void _GetClassInfoHelper( ClassInfo **ppClassInfo );
  344.         void _GetThreadInfoHelper( ThreadInfo **ppThreadInfo );
  345.         void _GetModuleInfoHelper( ModuleInfo **ppModuleInfo );           
  346.         void _GetFunctionInfoHelper( FunctionInfo **ppFunctionInfo );
  347.         void _GetAssemblyInfoHelper( AssemblyInfo **ppAssemblyInfo );        
  348.         void _SetAppDomainName( AppDomainID AppDomainID );
  349.         void _GetAppDomainInfoHelper( AppDomainInfo **ppAppDomainInfo );
  350.  
  351.  
  352.     // data memebers
  353.  
  354.     protected:    
  355.  
  356.         DWORD m_dwEventMask;
  357.         ICorProfilerInfo *m_pProfilerInfo;
  358.  
  359.         // tables         
  360.         SList<ClassInfo *, ClassID> *m_pClassTable;
  361.         SList<ThreadInfo *, ThreadID> *m_pThreadTable;
  362.         SList<ModuleInfo *, ModuleID> *m_pModuleTable;
  363.         SList<FunctionInfo *, FunctionID> *m_pFunctionTable;
  364.         SList<AssemblyInfo *, AssemblyID> *m_pAssemblyTable;
  365.         SList<AppDomainInfo *, AppDomainID> *m_pAppDomainTable; 
  366.  
  367.     private:
  368.  
  369.         CRITICAL_SECTION m_criticalSection;
  370.  
  371. }; // PrfInfo
  372.  
  373.  
  374. #endif // __PROFILERHELPER_H___
  375.  
  376. // End of File