ICorProfilerInfo2

更新:2007 年 11 月

提供一些方法,以便代码探查器可以通过与公共语言运行库 (CLR) 通信来控制事件监视和请求信息。ICorProfilerInfo2 接口是 ICorProfilerInfo 接口的扩展。也就是说,它提供在 .NET Framework 2.0 版及更高版本中受支持的新方法。

interface ICorProfilerInfo2 : ICorProfilerInfo
{
    HRESULT DoStackSnapshot(
        [in] ThreadID thread,
        [in] StackSnapshotCallback *callback,
        [in] ULONG32 infoFlags,
        [in] void *clientData,
        [in, size_is(contextSize), length_is(contextSize)] BYTE context[],
        [in] ULONG32 contextSize);

    HRESULT SetEnterLeaveFunctionHooks2(
        [in] FunctionEnter2    *pFuncEnter,
        [in] FunctionLeave2    *pFuncLeave,
        [in] FunctionTailcall2 *pFuncTailcall);

    HRESULT GetFunctionInfo2(
        [in] FunctionID funcId,
        [in] COR_PRF_FRAME_INFO frameInfo,
        [out] ClassID *pClassId,
        [out] ModuleID *pModuleId,
        [out] mdToken *pToken,
        [in] ULONG32 cTypeArgs,
        [out] ULONG32 *pcTypeArgs,
        [out] ClassID typeArgs[]);

    HRESULT GetStringLayout(
        [out] ULONG *pBufferLengthOffset,
        [out] ULONG *pStringLengthOffset,
        [out] ULONG *pBufferOffset);

    HRESULT GetClassLayout(
        [in]  ClassID classID,
        [in, out] COR_FIELD_OFFSET rFieldOffset[],
        [in] ULONG cFieldOffset,
        [out] ULONG *pcFieldOffset,
        [out] ULONG *pulClassSize);

    HRESULT GetClassIDInfo2(
        [in] ClassID classId,
        [out] ModuleID *pModuleId,
        [out] mdTypeDef *pTypeDefToken,
        [out] ClassID *pParentClassId,
        [in] ULONG32 cNumTypeArgs,
        [out] ULONG32 *pcNumTypeArgs,
        [out] ClassID typeArgs[]);

    HRESULT GetCodeInfo2(
        [in] FunctionID functionID,
        [in] ULONG32 cCodeInfos,
        [out] ULONG32 *pcCodeInfos,
        [out, size_is(cCodeInfos), length_is(*pcCodeInfos)]
                COR_PRF_CODE_INFO codeInfos[]);

        HRESULT GetClassFromTokenAndTypeArgs(
        [in] ModuleID moduleID,
        [in] mdTypeDef typeDef,
        [in] ULONG32 cTypeArgs,
        [in, size_is(cTypeArgs)] ClassID typeArgs[],
        [out] ClassID* pClassID);

    HRESULT GetFunctionFromTokenAndTypeArgs(
        [in] ModuleID moduleID,
        [in] mdMethodDef funcDef,
        [in] ClassID classId,
        [in] ULONG32 cTypeArgs,
        [in, size_is(cTypeArgs)] ClassID typeArgs[],
        [out] FunctionID* pFunctionID);

    HRESULT EnumModuleFrozenObjects(
        [in] ModuleID moduleID,
        [out] ICorProfilerObjectEnum** ppEnum);

    HRESULT GetArrayObjectInfo(
        [in] ObjectID objectId,
        [in] ULONG32 cDimensions,
        [out, size_is(cDimensions), length_is(cDimensions)] ULONG32 pDimensionSizes[],
        [out, size_is(cDimensions), length_is(cDimensions)] int pDimensionLowerBounds[],
        [out] BYTE **ppData);

    HRESULT GetBoxClassLayout(
        [in] ClassID classId,
        [out] ULONG32 *pBufferOffset);

    HRESULT GetThreadAppDomain(
        [in] ThreadID threadId,
        [out] AppDomainID *pAppDomainId);

    HRESULT GetRVAStaticAddress(
        [in] ClassID classId,
        [in] mdFieldDef fieldToken,
        [out] void **ppAddress);

    HRESULT GetAppDomainStaticAddress(
        [in] ClassID classId,
        [in] mdFieldDef fieldToken,
        [in] AppDomainID appDomainId,
        [out] void **ppAddress);

    HRESULT GetThreadStaticAddress(
        [in] ClassID classId,
        [in] mdFieldDef fieldToken,
        [in] ThreadID threadId,
        [out] void **ppAddress);

    HRESULT GetContextStaticAddress(
        [in] ClassID classId,
        [in] mdFieldDef fieldToken,
        [in] ContextID contextId,
        [out] void **ppAddress);

    HRESULT GetStaticFieldInfo(
        [in] ClassID classId,
        [in] mdFieldDef fieldToken,
        [out] COR_PRF_STATIC_TYPE *pFieldInfo);

    HRESULT GetGenerationBounds(
        [in] ULONG cObjectRanges,
        [out] ULONG *pcObjectRanges,
        [out, size_is(cObjectRanges), length_is(*pcObjectRanges)] COR_PRF_GC_GENERATION_RANGE ranges[]);

    HRESULT GetObjectGeneration(
        [in] ObjectID objectId,
        [out] COR_PRF_GC_GENERATION_RANGE *range);

    HRESULT GetNotifiedExceptionClauseInfo(
        [out] COR_PRF_EX_CLAUSE_INFO *pinfo);
}

方法

方法

说明

ICorProfilerInfo2::DoStackSnapshot 方法

审核指定线程的堆栈,以便向探查器报告托管调用帧。

ICorProfilerInfo2::EnumModuleFrozenObjects 方法

获取一个允许对指定模块中的冻结对象进行迭代的枚举数。

ICorProfilerInfo2::GetAppDomainStaticAddress 方法

获取指定应用程序域静态字段在指定应用程序域范围内的地址。

ICorProfilerInfo2::GetArrayObjectInfo 方法

获取有关数组对象的详细信息。

ICorProfilerInfo2::GetBoxClassLayout 方法

获取有关已装箱的指定值类型的类布局的信息。

ICorProfilerInfo2::GetClassFromTokenAndTypeArgs 方法

使用指定的元数据标记和任何类型参数的 ClassID 值获取类型的 ClassID

ICorProfilerInfo2::GetClassIDInfo2 方法

获取指定泛型类的父模块、该类的元数据标记、其父类的 ClassID 以及该类的每个类型参数的 ClassID(如果存在)。

ICorProfilerInfo2::GetClassLayout 方法

获取有关由指定类定义的字段在内存中的布局的信息。即,此方法获取该类的字段的偏移量。

ICorProfilerInfo2::GetCodeInfo2 方法

获取与指定的 FunctionID 关联的本机代码的范围。

ICorProfilerInfo2::GetContextStaticAddress 方法

获取指定上下文范围内的指定上下文静态字段的地址。

ICorProfilerInfo2::GetFunctionFromTokenAndTypeArgs 方法

使用指定的元数据标记、包含类和任意类型参数的 ClassID 值来获取某个函数的 FunctionID

ICorProfilerInfo2::GetFunctionInfo2 方法

获取函数的父类、元数据标记以及每个类型参数的 ClassID(如果存在)。

ICorProfilerInfo2::GetGenerationBounds 方法

获取组成垃圾回收的堆的代的内存区域(堆的段)。

ICorProfilerInfo2::GetNotifiedExceptionClauseInfo 方法

获取即将运行或刚运行的异常子句 (catch/finally/filter) 的本机地址和帧信息。

ICorProfilerInfo2::GetObjectGeneration 方法

获取包含指定对象的堆的段。

ICorProfilerInfo2::GetRVAStaticAddress 方法

获取指定的相对虚拟地址 (RVA) 静态字段的地址。

ICorProfilerInfo2::GetStaticFieldInfo 方法

获取指定字段在其中为静态字段的范围。

ICorProfilerInfo2::GetStringLayout 方法

获取有关字符串对象的布局的信息。

ICorProfilerInfo2::GetThreadAppDomain 方法

获取指定线程当前正在其中执行代码的应用程序域的 ID。

ICorProfilerInfo2::GetThreadStaticAddress 方法

获取指定线程范围内的指定线程静态字段的地址。

ICorProfilerInfo2::SetEnterLeaveFunctionHooks2 方法

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

备注

探查器通过调用 ICorProfilerInfo2 接口中的方法与 CLR 通信,以此来控制事件监视和请求信息。

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

在初始化过程中,CLR 会使用每个代码探查器的 ICorProfilerCallback::Initialize 实现向该探查器传递一个 ICorProfilerInfo2 接口。这样,代码探查器便可以调用 ICorProfilerInfo2 接口的方法,以获取有关要在 CLR 的控制下执行的托管代码的信息。

要求

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

**头文件:**CorProf.idl

**库:**CorGuids.lib

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

请参见

参考

ICorProfilerInfo

其他资源

分析接口