ICorProfilerInfo

更新:2007 年 11 月

为代码探查器提供方法,以便与公共语言运行库 (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 方法

初始化进程内调试支持。此方法在 .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。

ICorProfilerInfo::GetEventMask 方法

获取探查器要为其接收来自 CLR 的事件通知的当前事件类别。

ICorProfilerInfo::GetFunctionFromIP 方法

将托管代码指令指针映射到 FunctionID

ICorProfilerInfo::GetFunctionFromToken 方法

获取函数的 ID。此方法在 .NET Framework 2.0 版中已过时。改用 ICorProfilerInfo2::GetFunctionFromTokenAndTypeArgs 方法。

ICorProfilerInfo::GetFunctionInfo 方法

获取指定函数的父类和元数据标记。

ICorProfilerInfo::GetHandleFromThread 方法

将线程的 ID 映射到 Win32 线程句柄。

ICorProfilerInfo::GetILFunctionBody 方法

获取一个指向 Microsoft 中间语言 (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 方法

指定要在托管函数的“enter”、“leave”和“tailcall”挂钩上调用的探查器实现的函数。

ICorProfilerInfo::SetEventMask 方法

设置一个指定事件类型的值,探查器将为该类事件接收来自 CLR 的通知。

ICorProfilerInfo::SetFunctionIDMapper 方法

指定将要调用以便将 FunctionID 值映射到替代值的探查器实现的函数,这些替代值将传递给探查器的函数入口/出口挂钩。

ICorProfilerInfo::SetFunctionReJIT 方法

未实现。不要使用。

ICorProfilerInfo::SetILFunctionBody 方法

替换指定模块中的指定函数体。

ICorProfilerInfo::SetILInstrumentedCodeMap 方法

指定指定函数的原始 MSIL 的偏移量如何映射到该函数探查器修改的 MSIL 的新偏移量。

备注

探查器调用 ICorProfilerInfo 接口中的方法以便与 CLR 通信,从而控制事件监视和请求信息。

ICorProfilerInfo 接口的方法由 CLR 使用自由线程的模型来实现。每个方法都会返回一个指示成功或失败的 HRESULT。有关可能的返回代码的列表,请参见 CorError.h。

在初始化期间,CLR 会通过探查器的 ICorProfilerCallback::Initialize 实现向每个代码探查器传递一个 ICorProfilerInfo 接口。代码探查器随后可以调用 ICorProfilerInfo 接口的方法,以获取有关正在 CLR 的控制下执行的托管代码的信息。

要求

**平台:**请参见 .NET Framework 系统要求

**头文件:**CorProf.idl

**库:**CorGuids.lib

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

请参见

参考

ICorProfilerInfo2

其他资源

分析接口