ICorDebugVariableHome 介面ICorDebugVariableHome Interface

表示函數的區域變數或引數。Represents a local variable or argument of a function.

方法Methods

方法Method 描述Description
GetArgumentIndex 方法GetArgumentIndex Method 取得函數引數的索引。Gets the index of a function argument.
GetCode 方法GetCode Method 取得包含這個物件的 "ICorDebugCode" 實例 ICorDebugVariableHomeGets the "ICorDebugCode" instance that contains this ICorDebugVariableHome object.
GetLiveRange 方法GetLiveRange Method 取得這個變數的存留原生範圍。Gets the native range over which this variable is live.
GetLocationType 方法GetLocationType Method 取得變數原生位置的型別。Gets the type of the variable's native location.
GetOffset 方法GetOffset Method 取得變數基底暫存器的位移。Gets the offset from the base register for a variable.
GetRegister 方法GetRegister Method 取得暫存器,其中包含位置類型為的變數 VLT_REGISTER ,以及位置類型為之變數的基底暫存器 VLT_REGISTER_RELATIVEGets the register that contains a variable with a location type of VLT_REGISTER, and the base register for a variable with a location type of VLT_REGISTER_RELATIVE.
GetSlotIndex 方法GetSlotIndex Method 取得本機變數的 managed 位置索引。Gets the managed slot-index of a local variable.

範例Example

下列程式碼片段會使用名為的 ICorDebugCode4 物件 pCode4The following code fragment uses the ICorDebugCode4 object named pCode4.

ICorDebugCode4 *pCode4 = NULL;  
pCode->QueryInterface(IID_ICorDebugCode4, &pCode4);  
  
ICorDebugVariableEnum *pVarLocEnum = NULL;  
pCode4->EnumerateVariableHomes(&pVarLocEnum);  
  
// retrieve local variables and arguments  
ULONG celt = 0;  
pVarLocEnum->GetCount(&celt);  
ICorDebugVariableHome **homes = new ICorDebugVariableHome *[celt];  
ULONG celtFetched = 0;  
pVarLocEnum->Next(celt, homes, &celtFetched);  
  
for (int i = 0; i < celtFetched; i++)  
{  
    VariableLocationType locType = VLT_INVALID;  
    homes[i].GetLocationType(&locType);  
    switch (locType)  
    {  
    case VLT_REGISTER:  
        CorDebugRegister register = 0;  
        locals[i].GetRegister(&register);  
        // now we know which register it is in  
        break;  
    case VLT_REGISTER_RELATIVE:  
        CorDebugRegister baseRegister = 0;  
        LONG offset = 0;  
        locals[i].GetRegister(&register);  
        locals[i].GetOffset(&offset);  
        // now we know the register-relative offset  
        break;  
    case VLT_INVALID:  
        // handle case where we can't access the location  
        break;  
    }  
}  

需求Requirements

平台: 請參閱 系統需求Platforms: See System Requirements.

標頭: CorDebug.idl、CorDebug.hHeader: CorDebug.idl, CorDebug.h

程式庫: CorGuids.libLibrary: CorGuids.lib

.NET Framework 版本:自 4.6.2 起可用Available since 4.6.2.NET Framework Versions: 自 4.6.2 起可用Available since 4.6.2

另請參閱See also