Share via


IDebugMethodField::EnumLocals

Creates an enumerator for selected local variables of the method.

HRESULT EnumLocals( 
   IDebugAddress*     pAddress,
   IEnumDebugFields** ppLocals
);
int EnumLocals(
   IDebugAddress        pAddress, 
   out IEnumDebugFields ppLocals
);

Parameters

  • pAddress
    [in] An IDebugAddress object representing the debug address that selects the context or scope from which to get the locals.

  • ppLocals
    [out] Returns an IEnumDebugFields object representing a list of the locals; otherwise, returns a null value if there are no locals.

Return Value

If successful, returns S_OK or returns S_FALSE if there are no locals. Otherwise, returns an error code.

Remarks

Only the variables defined within the block that contains the given debug address are enumerated. If all locals including any compiler-generated locals are needed, call the IDebugMethodField::EnumAllLocals method.

A method can contain multiple scoping contexts or blocks. For example, the following contrived method contains three scopes, the two inner blocks and the method body itself.

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

The IDebugMethodField object represents the func method itself. Calling the EnumLocals method with an IDebugAddress set to the Inner Scope 1 address returns an enumeration containing the temp1 variable, for example.

See Also

Reference

IDebugMethodField

IDebugAddress

IEnumDebugFields

IDebugMethodField::EnumAllLocals