共用方式為


ICorProfilerInfo

更新:2007 年 11 月

提供方法讓程式碼剖析工具用來與 Common Language Runtime (CLR) 通訊,以控制事件監視及要求資訊。

注意事項:

ICorProfilerInfo 介面中的每個方法都會傳回 HRESULT,以表示成功或失敗。請參閱 CorError.h,取得可能傳回碼的清單。

interface ICorProfilerInfo : IUnknown
{
    HRESULT GetClassFromObject(
        [in]  ObjectID objectId,
        [out] ClassID *pClassId);

    HRESULT GetClassFromToken(
        [in]  ModuleID  moduleId,
        [in]  mdTypeDef typeDef,
        [out] ClassID   *pClassId);
        
    HRESULT GetCodeInfo(
        [in]  FunctionID functionId,
        [out] LPCBYTE    *pStart,
        [out] ULONG      *pcSize);
        
    HRESULT GetEventMask(
        [out] DWORD *pdwEvents);

    HRESULT GetFunctionFromIP(
        [in]  LPCBYTE    ip,
        [out] FunctionID *pFunctionId);

    HRESULT GetFunctionFromToken(
        [in]  ModuleID   moduleId,
        [in]  mdToken    token,
        [out] FunctionID *pFunctionId);

    HRESULT GetHandleFromThread(
        [in]  ThreadID threadId,
        [out] HANDLE  *phThread);

    HRESULT GetObjectSize(
        [in]  ObjectID objectId,
        [out] ULONG  *pcSize);
      
    HRESULT IsArrayClass(
        [in]  ClassID        classId,
        [out] CorElementType *pBaseElemType,
        [out] ClassID        *pBaseClassId,
        [out] ULONG          *pcRank);

    HRESULT GetThreadInfo(
        [in]  ThreadID threadId,
        [out] DWORD    *pdwWin32ThreadId);

    HRESULT GetCurrentThreadID(
        [out] ThreadID *pThreadId);

    HRESULT GetClassIDInfo(
        [in]  ClassID   classId,
        [out] ModuleID  *pModuleId,
        [out] mdTypeDef *pTypeDefToken);

    HRESULT GetFunctionInfo(
        [in]  FunctionID functionId,
        [out] ClassID    *pClassId,
        [out] ModuleID   *pModuleId,
        [out] mdToken    *pToken);

    HRESULT SetEventMask(
        [in] DWORD dwEvents);
    
    HRESULT SetEnterLeaveFunctionHooks(
        [in] FunctionEnter    *pFuncEnter,
        [in] FunctionLeave    *pFuncLeave,
        [in] FunctionTailcall *pFuncTailcall);

    HRESULT SetFunctionIDMapper(
        [in] FunctionIDMapper *pFunc);
    
    HRESULT GetTokenAndMetaDataFromFunction(
        [in]  FunctionID functionId,
        [in]  REFIID     riid,
        [out] IUnknown   **ppImport,
        [out] mdToken    *pToken);
      
    HRESULT GetModuleInfo(
        [in]  ModuleID   moduleId,
        [out] LPCBYTE    *ppBaseLoadAddress,
        [in]  ULONG      cchName,
        [out] ULONG      *pcchName,
        [out, size_is(cchName), length_is(*pcchName)]
              WCHAR      szName[] ,
        [out] AssemblyID *pAssemblyId);
        
    HRESULT GetModuleMetaData(
        [in]  ModuleID moduleId,
                [in]  DWORD    dwOpenFlags,
        [in]  REFIID   riid,
                [out] IUnknown **ppOut);
      
    HRESULT GetILFunctionBody(
        [in]  ModuleID    moduleId,
        [in]  mdMethodDef methodId,
        [out] LPCBYTE     *ppMethodHeader,
        [out] ULONG       *pcbMethodSize);

    HRESULT GetILFunctionBodyAllocator(
        [in]  ModuleID      moduleId,
        [out] IMethodMalloc **ppMalloc);
    
    HRESULT SetILFunctionBody(
        [in] ModuleID    moduleId,
        [in] mdMethodDef methodid,
        [in] LPCBYTE     pbNewILMethodHeader);

    HRESULT GetAppDomainInfo(
        [in]  AppDomainID appDomainId,
        [in]  ULONG       cchName,
        [out] ULONG       *pcchName,
        [out, size_is(cchName), length_is(*pcchName)]
              WCHAR       szName[] ,
        [out] ProcessID   *pProcessId);

    HRESULT GetAssemblyInfo(
        [in]  AssemblyID  assemblyId,
        [in]  ULONG       cchName,
        [out] ULONG       *pcchName,
        [out, size_is(cchName), length_is(*pcchName)]
              WCHAR       szName[] ,
        [out] AppDomainID *pAppDomainId,
        [out] ModuleID    *pModuleId);
      
    HRESULT SetFunctionReJIT(
        [in] FunctionID functionId);

    HRESULT ForceGC();
        
    HRESULT SetILInstrumentedCodeMap(
        [in]                         FunctionID functionId,
        [in]                         BOOL       fStartJit,
        [in]                         ULONG      cILMapEntries,
        [in, size_is(cILMapEntries)] COR_IL_MAP rgILMapEntries[] );
      
    HRESULT GetInprocInspectionInterface(
        [out] IUnknown **ppicd);

    HRESULT GetInprocInspectionIThisThread(
        [out] IUnknown **ppicd);

    HRESULT GetThreadContext(
        [in]  ThreadID  threadId,
        [out] ContextID *pContextId);
    
    HRESULT BeginInprocDebugging(
        [in]  BOOL   fThisThreadOnly,
        [out] DWORD *pdwProfilerContext);
      
    HRESULT EndInprocDebugging(
        [in]  DWORD dwProfilerContext);
      
    HRESULT GetILToNativeMapping(
        [in] FunctionID functionId,
        [in] ULONG32 cMap,
        [out] ULONG32 *pcMap,
        [out, size_is(cMap), length_is(*pcMap)]
            COR_DEBUG_IL_TO_NATIVE_MAP map[]);
}

方法

方法

描述

ICorProfilerInfo::BeginInprocDebugging 方法

初始化同處理序 (In-Process) 偵錯支援。這個方法在 .NET Framework 2.0 版中已過時。

ICorProfilerInfo::EndInprocDebugging 方法

關閉同處理序偵錯工作階段。這個方法在 .NET Framework 2.0 版中已過時。

ICorProfilerInfo::ForceGC 方法

強制在執行階段內發生記憶體回收。

ICorProfilerInfo::GetAppDomainInfo 方法

取得指定之應用程式定義域的資訊。

ICorProfilerInfo::GetAssemblyInfo 方法

取得與指定之組件有關的資訊。

ICorProfilerInfo::GetClassFromObject 方法

取得物件的 ClassID

(根據它的 ObjectID)。

ICorProfilerInfo::GetClassFromToken 方法

根據中繼資料語彙基元,取得類別 ID。這個方法在 .NET Framework 2.0 版中已過時。改用 ICorProfilerInfo2::GetClassFromTokenAndTypeArgs 方法。

ICorProfilerInfo::GetClassIDInfo 方法

取得指定之類別的父模組和中繼資料語彙基元。

ICorProfilerInfo::GetCodeInfo 方法

取得與指定之函式 ID 關聯的機器碼延伸。這個方法已過時。改用 ICorProfilerInfo2::GetCodeInfo2 方法。

ICorProfilerInfo::GetCurrentThreadID 方法

取得目前執行緒的 ID (如果是 Managed 執行緒)。

ICorProfilerInfo::GetEventMask 方法

取得分析工具要從 CLR 接收事件告知的目前事件分類。

ICorProfilerInfo::GetFunctionFromIP 方法

將 Managed 程式碼指令指標對應到 FunctionID

ICorProfilerInfo::GetFunctionFromToken 方法

取得函式 ID。這個方法在 .NET Framework 2.0 版中已過時。改用 ICorProfilerInfo2::GetFunctionFromTokenAndTypeArgs 方法。

ICorProfilerInfo::GetFunctionInfo 方法

取得指定之函式的父類別和中繼資料語彙基元。

ICorProfilerInfo::GetHandleFromThread 方法

將執行緒 ID 對應至 Win32 執行緒控制代碼。

ICorProfilerInfo::GetILFunctionBody 方法

取得 Microsoft Intermediate Language (MSIL) 程式碼中方法主體的指標 (從其標頭開始)。

ICorProfilerInfo::GetILFunctionBodyAllocator 方法

取得介面,這個介面會提供方法來配置要用來交換 MSIL 程式碼中之方法主體的記憶體。

ICorProfilerInfo::GetILToNativeMapping 方法

針對指定之函式中所包含的程式碼,取得從 MSIL 位移到原生位移的對應。

ICorProfilerInfo::GetInprocInspectionInterface 方法

取得可以針對 ICorDebugProcess 介面查詢的物件。這個方法在 .NET Framework 2.0 版中已過時。

ICorProfilerInfo::GetInprocInspectionIThisThread 方法

取得可以針對 ICorDebugThread 介面查詢的物件。這個方法在 .NET Framework 2.0 版中已過時。

ICorProfilerInfo::GetModuleInfo 方法

取得與指定模組有關的資訊。

ICorProfilerInfo::GetModuleMetaData 方法

取得對應到指定模組的中繼資料介面執行個體。

ICorProfilerInfo::GetObjectSize 方法

取得指定之物件的大小。

ICorProfilerInfo::GetThreadContext 方法

取得目前與指定的執行緒有關聯的內容識別。

ICorProfilerInfo::GetThreadInfo 方法

取得指定執行緒的目前 Win32 執行緒識別。

ICorProfilerInfo::GetTokenAndMetadataFromFunction 方法

取得指定之函式的中繼資料語彙基元,以及可用在此語彙基元的中繼資料介面執行個體。

ICorProfilerInfo::IsArrayClass 方法

判斷指定的類別是否為陣列類別。

ICorProfilerInfo::SetEnterLeaveFunctionHooks 方法

指定要在 Managed 函式之 "enter"、"leave" 和 "tailcall" 攔截程序上呼叫的分析工具實作函式。

ICorProfilerInfo::SetEventMask 方法

設定值,指定分析工具要從 CLR 接收告知的事件型別。

ICorProfilerInfo::SetFunctionIDMapper 方法

指定將呼叫的分析工具實作函式,以便將 FunctionID 值對應至替代值,這些值會傳遞至分析工具的函式 entry/exit 攔截。

ICorProfilerInfo::SetFunctionReJIT 方法

尚未實作。不要使用。

ICorProfilerInfo::SetILFunctionBody 方法

在指定的模組中取代指定的函式主體。

ICorProfilerInfo::SetILInstrumentedCodeMap 方法

指定指定之函式原始 MSIL 的位移如何對應至此函式已由分析工具修改之 MSIL 的新位移。

備註

分析工具會呼叫 ICorProfilerInfo 介面中的方法與 CLR 通訊,以控制事件監視及要求資訊。

ICorProfilerInfo 介面的方法由 CLR 透過無限制執行緒模型實作。每個方法會傳回 HRESULT 以表示成功或失敗。請參閱 CorError.h,取得可能傳回碼的清單。

CLR 會在初始化期間透過分析工具的 ICorProfilerCallback::Initialize 實作,將 ICorProfilerInfo 介面傳遞至每個程式碼剖析工具。程式碼剖析工具就可以呼叫 ICorProfilerInfo 介面的方法,以取得在 CLR 控制下執行的 Managed 程式碼相關資訊。

需求

**平台:**請參閱 .NET Framework 系統需求

**標頭:**CorProf.idl

**程式庫:**CorGuids.lib

**.NET Framework 版本:**3.5 SP1、3.5、3.0 SP1、3.0、2.0 SP1、2.0

請參閱

參考

ICorProfilerInfo2

其他資源

分析介面