IDebugHostSymbols::GetMostDerivedObject 方法 (dbgmodel.h)

GetMostDerivedObject 将使用调试器的类型系统从其静态类型确定对象的运行时类型。 此方法仅使用类型系统层中提供的符号信息和启发式信息来执行此分析。 这些信息可能包括C++ RTTI(运行时类型信息)或对象虚拟函数表形状的分析。 它不包括 IModelObject上的首选运行时类型概念等内容。

如果分析找不到运行时类型,或者找不到与传入方法的静态类型不同的运行时类型,则输入位置和类型可能会传出。由于这些原因,该方法不会失败。

语法

HRESULT GetMostDerivedObject(
  IDebugHostContext *pContext,
  Location          ___location,
  IDebugHostType    *objectType,
  Location          *derivedLocation,
  IDebugHostType    **derivedType
);

参数

pContext

给定位置有效的上下文。 如果未指定此值,则假定上下文与 objectType 提供的上下文相同。

___location

静态类型化对象在 pContext 参数或 objectType 参数给出的地址空间中的位置。

objectType

位于给定位置的对象静态类型。

derivedLocation

运行时类型化对象在 pContext 参数或 objectType 参数给定的地址空间中的位置。 这可能与位置参数给出的位置相同,也可能不相同。

derivedType

将在此处返回对象的运行时类型。 这可能与在 objectType 参数中传递的类型相同,也可能不相同。

返回值

此方法返回指示成功或失败的 HRESULT。

言论

示例代码

ComPtr<IDebugHost> spHost;           /* get the host */
ComPtr<IDebugHostType> spStaticType; /* get the static (compile time) type of 
                                     some object (see IModelObject::GetTargetInfo) */
Location staticLocation;             /* get the static ___location of some object
                                        (see IModelObject::GetTargetInfo) */

ComPtr<IDebugHostSymbols> spSym;
if (SUCCEEDED(spHost.As(&spSym)))
{
    ComPtr<IDebugHostType> spRuntimeType;
    Location runtimeLocation;
    if (SUCCEEDED(spSym->GetMostDerivedObject(USE_CURRENT_HOST_CONTEXT,
                                              spStaticType.Get(), 
                                              staticLocation, 
                                              &spRuntimeType, 
                                              &runtimeLocation)))
    {
        // spRuntimeType contains the runtime type of the object as 
        // determined from type system means (e.g.: RTTI or v-table analysis)
        // runtimeLocation contains the ___location of the runtime type of the object
    }
}

要求

要求 价值
标头 dbgmodel.h

另请参阅

IDebugHostSymbols 接口