IDebugMethodField::EnumLocals

为方法的选定局部变量创建枚举器。

语法

int EnumLocals(
    IDebugAddress        pAddress,
    out IEnumDebugFields ppLocals
);

参数

pAddress
[in]一个 IDebugAddress 对象,该对象表示用于选择要从中获取局部变量的上下文或作用域的调试地址。

ppLocals
[out]返回一个 表示局部变量列表的 IEnumDebugFields 对象;否则,如果没有局部变量,则返回 null 值。

返回值

如果成功,则返回S_OK,如果没有局部变量,则返回S_FAL标准版。 否则,返回错误代码。

备注

仅枚举在包含给定调试地址的块中定义的变量。 如果需要所有局部变量(包括任何编译器生成的局部变量),请调用 EnumAllLocals 方法。

方法可以包含多个范围上下文或块。 例如,以下已尝试的方法包含三个范围,即两个内部块和方法主体本身。

public void func(int index)
{
    // Method body scope
    int a = 0;
    if (index == 1)
    {
        // Inner scope 1
        int temp1 = a;
    }
    else
    {
        // Inner scope 2
        int temp2 = a;
    }
}

IDebugMethodField 对象表示func方法本身。 EnumLocals例如,调用 IDebugAddress 设置为Inner Scope 1地址的方法将返回包含变量的temp1枚举。

另请参阅