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 自變數所指定位址空間內的位置。 這可能與location自變數所提供的位置不同。

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 介面