ICorDebugVariableHome 接口

表示函数的局部变量或参数。

Methods

方法 Description
GetArgumentIndex 方法 获取函数参数的索引。
GetCode 方法 获取包含此 ICorDebugVariableHome 对象的“ICorDebugCode”实例。
GetLiveRange 方法 获取此变量的生存期的本机范围。
GetLocationType 方法 获取变量的本机位置的类型。
GetOffset 方法 获取变量基寄存器的偏移量。
GetRegister 方法 获取包含位置类型的变量的寄存器,以及具有位置类型的VLT_REGISTERVLT_REGISTER_RELATIVE变量的基寄存器。
GetSlotIndex 方法 获取本地变量的托管槽索引。

Example

以下代码片段使用名为 pCode4 的 ICorDebugCode4 对象。

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;
    }
}

要求

平台: 请参阅 .NET 支持的作系统

页眉: CorDebug.idl、CorDebug.h

图书馆: CorGuids.lib

.NET 版本: 自 .NET Framework 4.6.2 起可用

另请参阅